mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-09 07:25:46 +01:00
closes #1893
This commit is contained in:
@@ -221,17 +221,23 @@ var winston = require('winston'),
|
|||||||
};
|
};
|
||||||
|
|
||||||
ThreadTools.toggleFollow = function(tid, uid, callback) {
|
ThreadTools.toggleFollow = function(tid, uid, callback) {
|
||||||
topics.isFollowing(tid, uid, function(err, following) {
|
callback = callback || function() {};
|
||||||
if (err) {
|
async.waterfall([
|
||||||
return callback(err);
|
function (next) {
|
||||||
|
ThreadTools.exists(tid, next);
|
||||||
|
},
|
||||||
|
function (exists, next) {
|
||||||
|
if (!exists) {
|
||||||
|
return next(new Error('[[error:no-topic]]'));
|
||||||
}
|
}
|
||||||
|
topics.isFollowing(tid, uid, next);
|
||||||
db[following ? 'setRemove' : 'setAdd']('tid:' + tid + ':followers', uid, function(err) {
|
},
|
||||||
if (typeof callback === 'function') {
|
function (isFollowing, next) {
|
||||||
callback(err, !following);
|
db[isFollowing ? 'setRemove' : 'setAdd']('tid:' + tid + ':followers', uid, function(err) {
|
||||||
|
next(err, !isFollowing);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
], callback);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}(exports));
|
}(exports));
|
||||||
|
|||||||
Reference in New Issue
Block a user