mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-06-22 22:40:22 +02:00
fix: #12751, topics:recent zset not updated when tid moved in/out of cid -1
This commit is contained in:
@@ -76,14 +76,14 @@ module.exports = function (Topics) {
|
|||||||
// Topics in /world are excluded from /recent
|
// Topics in /world are excluded from /recent
|
||||||
const cid = await Topics.getTopicField(tid, 'cid');
|
const cid = await Topics.getTopicField(tid, 'cid');
|
||||||
if (cid === -1) {
|
if (cid === -1) {
|
||||||
return;
|
return await db.sortedSetRemove('topics:recent', data.tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugins.hooks.hasListeners('filter:topics.updateRecent')) {
|
if (plugins.hooks.hasListeners('filter:topics.updateRecent')) {
|
||||||
data = await plugins.hooks.fire('filter:topics.updateRecent', data);
|
data = await plugins.hooks.fire('filter:topics.updateRecent', data);
|
||||||
}
|
}
|
||||||
if (data && data.tid && data.timestamp) {
|
if (data && data.tid && data.timestamp) {
|
||||||
await db.sortedSetAdd(`topics:recent`, data.timestamp, data.tid);
|
await db.sortedSetAdd('topics:recent', data.timestamp, data.tid);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -285,6 +285,12 @@ module.exports = function (Topics) {
|
|||||||
Topics.updateCategoryTagsCount([oldCid, cid], tags),
|
Topics.updateCategoryTagsCount([oldCid, cid], tags),
|
||||||
Topics.events.log(tid, { type: 'move', uid: data.uid, fromCid: oldCid }),
|
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);
|
const hookData = _.clone(data);
|
||||||
hookData.fromCid = oldCid;
|
hookData.fromCid = oldCid;
|
||||||
hookData.toCid = cid;
|
hookData.toCid = cid;
|
||||||
|
|||||||
Reference in New Issue
Block a user