mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
Don't decrease postCount when purging post from a deleted topic
This commit is contained in:
@@ -2,10 +2,9 @@
|
|||||||
|
|
||||||
var async = require('async'),
|
var async = require('async'),
|
||||||
db = require('../database'),
|
db = require('../database'),
|
||||||
|
topics = require('../topics'),
|
||||||
plugins = require('../plugins');
|
plugins = require('../plugins');
|
||||||
|
|
||||||
|
|
||||||
module.exports = function(Posts) {
|
module.exports = function(Posts) {
|
||||||
|
|
||||||
Posts.purge = function(pid, callback) {
|
Posts.purge = function(pid, callback) {
|
||||||
@@ -56,11 +55,17 @@ module.exports = function(Posts) {
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parseInt(postData.deleted, 10) === 0) {
|
topics.getTopicFields(postData.tid, ['deleted'], function(err, topicData) {
|
||||||
db.decrObjectField('global', 'postCount', callback);
|
if (err) {
|
||||||
} else {
|
return callback(err);
|
||||||
callback();
|
}
|
||||||
}
|
|
||||||
|
if (parseInt(postData.deleted, 10) === 0 && parseInt(topicData.deleted, 10) !== 1) {
|
||||||
|
db.decrObjectField('global', 'postCount', callback);
|
||||||
|
} else {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -124,4 +129,4 @@ module.exports = function(Posts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ module.exports = function(Topics) {
|
|||||||
db.decrObjectField('category:' + topicData.cid, 'topic_count', next);
|
db.decrObjectField('category:' + topicData.cid, 'topic_count', next);
|
||||||
},
|
},
|
||||||
function(next) {
|
function(next) {
|
||||||
updateGlobalCounters(tid, -1, next);
|
db.decrObjectField('global', 'topicCount', next);
|
||||||
}
|
}
|
||||||
], callback);
|
], callback);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user