Skip to content

Node.js based forum software built for the modern web

fixes removePostFromTopic

barisusaklib7f71ca0b47f
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) {