Skip to content

Commit

Permalink
properly fixing #4583
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlam committed Apr 29, 2016
1 parent bd8fcb5 commit cb1920d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/posts/flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,24 @@ module.exports = function(Posts) {
], pid, next);
});
},
function(next) {
async.series([
function(next) {
db.getSortedSetRange('pid:' + pid + ':flag:uids', 0, -1, function(err, uids) {
async.each(uids, function(uid, next) {
var nid = 'post_flag:' + pid + ':uid:' + uid;
async.parallel([
async.apply(db.delete, 'notifications:' + nid),
async.apply(db.sortedSetRemove, 'notifications', 'post_flag:' + pid + ':uid:' + uid)
], next);
}, next);
});
},
async.apply(db.delete, 'pid:' + pid + ':flag:uids')
], next);
},
async.apply(db.deleteObjectField, 'post:' + pid, 'flags'),
async.apply(db.delete, 'pid:' + pid + ':flag:uids'),
async.apply(db.delete, 'pid:' + pid + ':flag:uid:reason'),
async.apply(db.sortedSetRemove, 'notifications', 'post_flag:' + pid + ':uid:' + uid)
async.apply(db.delete, 'pid:' + pid + ':flag:uid:reason')
], function(err) {
callback(err);
});
Expand Down

0 comments on commit cb1920d

Please sign in to comment.