fix: #12751, topics:recent zset not updated when tid moved in/out of cid -1

This commit is contained in:
Julian Lam
2024-08-22 11:17:27 -04:00
parent df6062d8be
commit 76551c7123
2 changed files with 8 additions and 2 deletions

View File

@@ -76,14 +76,14 @@ module.exports = function (Topics) {
// Topics in /world are excluded from /recent
const cid = await Topics.getTopicField(tid, 'cid');
if (cid === -1) {
return;
return await db.sortedSetRemove('topics:recent', data.tid);
}
if (plugins.hooks.hasListeners('filter:topics.updateRecent')) {
data = await plugins.hooks.fire('filter:topics.updateRecent', data);
}
if (data && data.tid && data.timestamp) {
await db.sortedSetAdd(`topics:recent`, data.timestamp, data.tid);
await db.sortedSetAdd('topics:recent', data.timestamp, data.tid);
}
};
};

View File

@@ -285,6 +285,12 @@ module.exports = function (Topics) {
Topics.updateCategoryTagsCount([oldCid, cid], tags),
Topics.events.log(tid, { type: 'move', uid: data.uid, fromCid: oldCid }),
]);
// Update entry in recent topics zset — must come after hash update
if (oldCid === -1 || cid === -1) {
Topics.updateRecent(tid, topicData.lastposttime); // no await req'd
}
const hookData = _.clone(data);
hookData.fromCid = oldCid;
hookData.toCid = cid;