post count fix for post move

v1.18.x
barisusakli 11 years ago
parent 56947b999e
commit 782896997d

@ -75,7 +75,7 @@ module.exports = function(Topics) {
return callback(err || new Error('[[error:no-topic]]')); return callback(err || new Error('[[error:no-topic]]'));
} }
posts.getPostFields(pid, ['deleted', 'tid', 'timestamp', 'votes'], function(err, postData) { posts.getPostFields(pid, ['tid', 'timestamp', 'votes'], function(err, postData) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
@ -89,13 +89,20 @@ module.exports = function(Topics) {
return callback(err); return callback(err);
} }
if(!parseInt(postData.deleted, 10)) { async.parallel([
Topics.decreasePostCount(postData.tid); function(next) {
Topics.increasePostCount(tid); Topics.decreasePostCount(postData.tid, next);
},
function(next) {
Topics.increasePostCount(tid, next);
},
function(next) {
posts.setPostField(pid, 'tid', tid, next);
},
function(next) {
Topics.addPostToTopic(tid, pid, postData.timestamp, postData.votes, next);
} }
], callback);
posts.setPostField(pid, 'tid', tid);
Topics.addPostToTopic(tid, pid, postData.timestamp, postData.votes, callback);
}); });
}); });
}); });

Loading…
Cancel
Save