From e74954407f1d5e5542ec485ec28219b54fa1a126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 11 Feb 2020 15:30:15 -0500 Subject: [PATCH] fix: #8157, update recent tid when post is moved --- src/topics/fork.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/topics/fork.js b/src/topics/fork.js index 53cecfaa7c..40edecf6b8 100644 --- a/src/topics/fork.js +++ b/src/topics/fork.js @@ -5,6 +5,7 @@ const async = require('async'); const db = require('../database'); const posts = require('../posts'); +const categories = require('../categories'); const privileges = require('../privileges'); const plugins = require('../plugins'); const meta = require('../meta'); @@ -101,6 +102,7 @@ module.exports = function (Topics) { await db.sortedSetIncrBy('cid:' + topicData[1].cid + ':tids:posts', 1, toTid); } if (topicData[0].cid === topicData[1].cid) { + await categories.updateRecentTidForCid(topicData[0].cid); return; } const removeFrom = [ @@ -118,6 +120,11 @@ module.exports = function (Topics) { if (postData.votes > 0) { tasks.push(db.sortedSetAdd('cid:' + topicData[1].cid + ':uid:' + postData.uid + ':pids:votes', postData.votes, postData.pid)); } + await Promise.all(tasks); + await Promise.all([ + categories.updateRecentTidForCid(topicData[0].cid), + categories.updateRecentTidForCid(topicData[1].cid), + ]); } };