mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-03-11 22:50:28 +01:00
feat(follow): follow & unfollow in userinfo page
This commit is contained in:
@@ -144,7 +144,7 @@ exports.changeProfilePicture = function (req, res) {
|
||||
if (existingImageUrl !== User.schema.path('profileImageURL').defaultValue) {
|
||||
if (useS3Storage) {
|
||||
try {
|
||||
var { region, bucket, key } = amazonS3URI(existingImageUrl);
|
||||
var {region, bucket, key} = amazonS3URI(existingImageUrl);
|
||||
var params = {
|
||||
Bucket: config.aws.s3.bucket,
|
||||
Key: key
|
||||
@@ -292,3 +292,39 @@ exports.unIdle = function (req, res, next) {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* followTo
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
exports.followTo = function (req, res) {
|
||||
var user = req.user;
|
||||
var toUser = req.model;
|
||||
|
||||
toUser.followers.push(user._id);
|
||||
toUser.save();
|
||||
|
||||
user.following.push(toUser._id);
|
||||
user.save(function (err) {
|
||||
res.json(user);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* unFollowTo
|
||||
* @param req
|
||||
* @param res
|
||||
*/
|
||||
exports.unFollowTo = function (req, res) {
|
||||
var user = req.user;
|
||||
var toUser = req.model;
|
||||
|
||||
toUser.followers.pull(user._id);
|
||||
toUser.save();
|
||||
|
||||
user.following.pull(toUser._id);
|
||||
user.save(function (err) {
|
||||
res.json(user);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user