v1.18.x
barisusakli 11 years ago
parent bb997e18a0
commit e459592ac9

@ -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);
},
db[following ? 'setRemove' : 'setAdd']('tid:' + tid + ':followers', uid, function(err) { function (exists, next) {
if (typeof callback === 'function') { if (!exists) {
callback(err, !following); return next(new Error('[[error:no-topic]]'));
} }
topics.isFollowing(tid, uid, next);
},
function (isFollowing, next) {
db[isFollowing ? 'setRemove' : 'setAdd']('tid:' + tid + ':followers', uid, function(err) {
next(err, !isFollowing);
}); });
}); }
], callback);
}; };
}(exports)); }(exports));

Loading…
Cancel
Save