v1.18.x
Baris Usakli 7 years ago
parent 2f047fa15f
commit f830322ee9

@ -129,8 +129,20 @@ module.exports = function (Topics) {
}; };
Topics.purge = function (tid, uid, callback) { Topics.purge = function (tid, uid, callback) {
var deletedTopic;
async.waterfall([ async.waterfall([
function (next) { function (next) {
async.parallel({
topic: async.apply(Topics.getTopicData, tid),
tags: async.apply(Topics.getTopicTags, tid),
}, next);
},
function (results, next) {
if (!results.topic) {
return callback();
}
deletedTopic = results.topic;
deletedTopic.tags = results.tags;
deleteFromFollowersIgnorers(tid, next); deleteFromFollowersIgnorers(tid, next);
}, },
function (next) { function (next) {
@ -168,10 +180,7 @@ module.exports = function (Topics) {
}); });
}, },
function (next) { function (next) {
Topics.getTopicData(tid, next); plugins.fireHook('action:topic.purge', { topic: deletedTopic, uid: uid });
},
function (topicData, next) {
plugins.fireHook('action:topic.purge', { topic: topicData, uid: uid });
db.delete('topic:' + tid, next); db.delete('topic:' + tid, next);
}, },
], callback); ], callback);

Loading…
Cancel
Save