mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-06 15:42:52 +01:00
closes #3821
This commit is contained in:
@@ -103,6 +103,9 @@ module.exports = function(Topics) {
|
||||
},
|
||||
function(next) {
|
||||
async.parallel([
|
||||
function(next) {
|
||||
updateCategoryPostCount(postData.tid, tid, next);
|
||||
},
|
||||
function(next) {
|
||||
Topics.decreasePostCount(postData.tid, next);
|
||||
},
|
||||
@@ -132,6 +135,24 @@ module.exports = function(Topics) {
|
||||
});
|
||||
};
|
||||
|
||||
function updateCategoryPostCount(oldTid, tid, callback) {
|
||||
Topics.getTopicsFields([oldTid, tid], ['cid'], function(err, topicData) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
if (!topicData[0].cid || !topicData[1].cid) {
|
||||
return callback();
|
||||
}
|
||||
if (parseInt(topicData[0].cid, 10) === parseInt(topicData[1].cid, 10)) {
|
||||
return callback();
|
||||
}
|
||||
async.parallel([
|
||||
async.apply(db.incrObjectFieldBy, 'category:' + topicData[0].cid, 'post_count', -1),
|
||||
async.apply(db.incrObjectFieldBy, 'category:' + topicData[1].cid, 'post_count', 1)
|
||||
], callback);
|
||||
});
|
||||
}
|
||||
|
||||
function updateRecentTopic(tid, callback) {
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
|
||||
Reference in New Issue
Block a user