From b7f71ca0b47fd81520b7259479444f304bcdd1cd Mon Sep 17 00:00:00 2001 From: barisusakli Date: Sat, 7 Jun 2014 13:04:30 -0400 Subject: [PATCH] fixes removePostFromTopic remove the pid from the votes set too --- src/topics/fork.js | 10 +++++----- src/topics/posts.js | 9 ++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/topics/fork.js b/src/topics/fork.js index bd9218f875..4d276f16fb 100644 --- a/src/topics/fork.js +++ b/src/topics/fork.js @@ -15,15 +15,15 @@ var async = require('async'), module.exports = function(Topics) { Topics.createTopicFromPosts = function(uid, title, pids, callback) { - if(title) { + if (title) { title = title.trim(); } - if(!title) { + if (!title) { return callback(new Error('[[error:invalid-title]]')); } - if(!pids || !pids.length) { + if (!pids || !pids.length) { return callback(new Error('[[error:invalid-pid]]')); } @@ -39,12 +39,12 @@ module.exports = function(Topics) { } }, function(err, results) { Topics.create({uid: results.postData.uid, title: title, cid: results.cid}, function(err, tid) { - if(err) { + if (err) { return callback(err); } async.eachSeries(pids, move, function(err) { - if(err) { + if (err) { return callback(err); } diff --git a/src/topics/posts.js b/src/topics/posts.js index ca1b0ba4c7..2819c6e647 100644 --- a/src/topics/posts.js +++ b/src/topics/posts.js @@ -131,7 +131,14 @@ module.exports = function(Topics) { }; Topics.removePostFromTopic = function(tid, pid, callback) { - db.sortedSetRemove('tid:' + tid + ':posts', pid, callback); + async.parallel([ + function (next) { + db.sortedSetRemove('tid:' + tid + ':posts', pid, next); + }, + function (next) { + db.sortedSetRemove('tid:' + tid + ':posts:votes', pid, next); + } + ], callback); }; Topics.getPids = function(tid, callback) {