|
|
|
@ -32,7 +32,7 @@ module.exports = function(Topics) {
|
|
|
|
|
db.sortedSetRemove('cid:' + topicData.cid + ':pids', pids, next);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
], function(err, results) {
|
|
|
|
|
], function(err) {
|
|
|
|
|
callback(err);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -79,7 +79,7 @@ module.exports = function(Topics) {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
], function(err, results) {
|
|
|
|
|
], function(err) {
|
|
|
|
|
callback(err);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -109,6 +109,11 @@ module.exports = function(Topics) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Topics.purge = function(tid, uid, callback) {
|
|
|
|
|
async.waterfall([
|
|
|
|
|
function(next) {
|
|
|
|
|
deleteFromFollowersIgnorers(tid, next);
|
|
|
|
|
},
|
|
|
|
|
function(next) {
|
|
|
|
|
async.parallel([
|
|
|
|
|
function(next) {
|
|
|
|
|
db.deleteAll([
|
|
|
|
@ -132,6 +137,8 @@ module.exports = function(Topics) {
|
|
|
|
|
function(next) {
|
|
|
|
|
reduceCounters(tid, next);
|
|
|
|
|
}
|
|
|
|
|
], next);
|
|
|
|
|
}
|
|
|
|
|
], function(err) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
@ -141,6 +148,26 @@ module.exports = function(Topics) {
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function deleteFromFollowersIgnorers(tid, callback) {
|
|
|
|
|
async.waterfall([
|
|
|
|
|
function(next) {
|
|
|
|
|
async.parallel({
|
|
|
|
|
followers: async.apply(db.getSetMembers, 'tid:' + tid + ':followers'),
|
|
|
|
|
ignorers: async.apply(db.getSetMembers, 'tid:' + tid + ':ignorers')
|
|
|
|
|
}, next);
|
|
|
|
|
},
|
|
|
|
|
function(results, next) {
|
|
|
|
|
var followerKeys = results.followers.map(function(uid) {
|
|
|
|
|
return 'uid:' + uid + ':followed_tids';
|
|
|
|
|
});
|
|
|
|
|
var ignorerKeys = results.ignorers.map(function(uid) {
|
|
|
|
|
return 'uid:' + uid + 'ignored_tids';
|
|
|
|
|
});
|
|
|
|
|
db.sortedSetsRemove(followerKeys.concat(ignorerKeys), tid, next);
|
|
|
|
|
}
|
|
|
|
|
], callback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteTopicFromCategoryAndUser(tid, callback) {
|
|
|
|
|
Topics.getTopicFields(tid, ['cid', 'uid'], function(err, topicData) {
|
|
|
|
|
if (err) {
|
|
|
|
|