|
|
|
@ -1,6 +1,5 @@
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
const async = require('async');
|
|
|
|
|
const plugins = require('../plugins');
|
|
|
|
|
const posts = require('../posts');
|
|
|
|
|
|
|
|
|
@ -24,11 +23,12 @@ module.exports = function (Topics) {
|
|
|
|
|
const otherTids = tids.sort((a, b) => a - b)
|
|
|
|
|
.filter(tid => tid && parseInt(tid, 10) !== parseInt(mergeIntoTid, 10));
|
|
|
|
|
|
|
|
|
|
await async.eachSeries(otherTids, async (tid) => {
|
|
|
|
|
for (const tid of otherTids) {
|
|
|
|
|
/* eslint-disable no-await-in-loop */
|
|
|
|
|
const pids = await Topics.getPids(tid);
|
|
|
|
|
await async.eachSeries(pids, (pid, next) => {
|
|
|
|
|
Topics.movePostToTopic(uid, pid, mergeIntoTid, next);
|
|
|
|
|
});
|
|
|
|
|
for (const pid of pids) {
|
|
|
|
|
await Topics.movePostToTopic(uid, pid, mergeIntoTid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await Topics.setTopicField(tid, 'mainPid', 0);
|
|
|
|
|
await Topics.delete(tid, uid);
|
|
|
|
@ -37,7 +37,7 @@ module.exports = function (Topics) {
|
|
|
|
|
mergerUid: uid,
|
|
|
|
|
mergedTimestamp: Date.now(),
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
posts.updateQueuedPostsTopic(mergeIntoTid, otherTids),
|
|
|
|
|