mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-09 15:35:47 +01:00
topics.getPids will return mainPid as well
This commit is contained in:
@@ -36,24 +36,15 @@ module.exports = function(Categories) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updatePostCount(tid, oldCid, cid);
|
updatePostCount(tid, oldCid, cid);
|
||||||
async.parallel({
|
topics.getPids(tid, function(err, pids) {
|
||||||
mainPid: function(next) {
|
|
||||||
topics.getTopicField(tid, 'mainPid', next);
|
|
||||||
},
|
|
||||||
pids: function(next) {
|
|
||||||
topics.getPids(tid, next);
|
|
||||||
}
|
|
||||||
}, function(err, results) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return winston.error(err.message);
|
return winston.error(err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!results.mainPid && results.pids && !results.pids.length) {
|
if (pids && !pids.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var pids = [results.mainPid].concat(results.pids);
|
|
||||||
|
|
||||||
var keys = pids.map(function(pid) {
|
var keys = pids.map(function(pid) {
|
||||||
return 'post:' + pid;
|
return 'post:' + pid;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ var winston = require('winston'),
|
|||||||
ThreadTools.purge = function(tid, uid, callback) {
|
ThreadTools.purge = function(tid, uid, callback) {
|
||||||
async.parallel({
|
async.parallel({
|
||||||
topic: function(next) {
|
topic: function(next) {
|
||||||
topics.getTopicFields(tid, ['cid', 'mainPid'], next);
|
topics.getTopicFields(tid, ['cid'], next);
|
||||||
},
|
},
|
||||||
pids: function(next) {
|
pids: function(next) {
|
||||||
topics.getPids(tid, next);
|
topics.getPids(tid, next);
|
||||||
@@ -83,16 +83,9 @@ var winston = require('winston'),
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var pids = [];
|
|
||||||
if (results.topic.mainPid) {
|
|
||||||
pids = [results.topic.mainPid].concat(results.pids);
|
|
||||||
} else {
|
|
||||||
pids = results.pids;
|
|
||||||
}
|
|
||||||
|
|
||||||
async.parallel([
|
async.parallel([
|
||||||
function(next) {
|
function(next) {
|
||||||
async.eachLimit(pids, 10, posts.purge, next);
|
async.eachLimit(results.pids, 10, posts.purge, next);
|
||||||
},
|
},
|
||||||
function(next) {
|
function(next) {
|
||||||
topics.purge(tid, next);
|
topics.purge(tid, next);
|
||||||
|
|||||||
@@ -182,7 +182,22 @@ module.exports = function(Topics) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Topics.getPids = function(tid, callback) {
|
Topics.getPids = function(tid, callback) {
|
||||||
db.getSortedSetRange('tid:' + tid + ':posts', 0, -1, callback);
|
async.parallel({
|
||||||
|
mainPid: function(next) {
|
||||||
|
Topics.getTopicField(tid, 'mainPid', next);
|
||||||
|
},
|
||||||
|
pids: function(next) {
|
||||||
|
db.getSortedSetRange('tid:' + tid + ':posts', 0, -1, next);
|
||||||
|
}
|
||||||
|
}, function(err, results) {
|
||||||
|
if (err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
|
if (results.mainPid) {
|
||||||
|
results.pids = [results.mainPid].concat(results.pids);
|
||||||
|
}
|
||||||
|
callback(null, results.pids);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Topics.increasePostCount = function(tid, callback) {
|
Topics.increasePostCount = function(tid, callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user