mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat(topic-events): clear out topic events when a topic is purged
This commit is contained in:
@@ -98,6 +98,7 @@ module.exports = function (Topics) {
|
|||||||
], tid),
|
], tid),
|
||||||
deleteTopicFromCategoryAndUser(tid),
|
deleteTopicFromCategoryAndUser(tid),
|
||||||
Topics.deleteTopicTags(tid),
|
Topics.deleteTopicTags(tid),
|
||||||
|
Topics.events.purge(tid),
|
||||||
reduceCounters(tid),
|
reduceCounters(tid),
|
||||||
]);
|
]);
|
||||||
plugins.hooks.fire('action:topic.purge', { topic: deletedTopic, uid: uid });
|
plugins.hooks.fire('action:topic.purge', { topic: deletedTopic, uid: uid });
|
||||||
|
|||||||
@@ -129,3 +129,12 @@ Events.log = async (tid, payload) => {
|
|||||||
({ events } = await plugins.hooks.fire('filter:topic.events.log', { events }));
|
({ events } = await plugins.hooks.fire('filter:topic.events.log', { events }));
|
||||||
return events;
|
return events;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Events.purge = async (tid) => {
|
||||||
|
// Should only be called on topic purge
|
||||||
|
const keys = [`topic:${tid}:events`];
|
||||||
|
const eventIds = await db.getSortedSetRange(keys[0], 0, -1);
|
||||||
|
keys.push(...eventIds.map(id => `topicEvent:${id}`));
|
||||||
|
|
||||||
|
db.deleteAll(keys);
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user