fix: topic crosspost delete and purge handling

This commit is contained in:
Julian Lam
2025-12-29 14:32:34 -05:00
parent 0a0a7da9ba
commit f6cc556d37
3 changed files with 71 additions and 0 deletions

View File

@@ -127,4 +127,14 @@ Crossposts.remove = async function (tid, cid, uid) {
crossposts = await Crossposts.get(tid);
return crossposts;
};
Crossposts.removeAll = async function (tid) {
const crosspostIds = await db.getSortedSetMembers(`tid:${tid}:crossposts`);
const crossposts = await db.getObjects(crosspostIds.map(id => `crosspost:${id}`));
await Promise.all(crossposts.map(async ({ tid, cid, uid }) => {
return Crossposts.remove(tid, cid, uid);
}));
return [];
};

View File

@@ -102,6 +102,7 @@ module.exports = function (Topics) {
Topics.deleteTopicTags(tid),
Topics.events.purge(tid),
Topics.thumbs.deleteAll(tid),
Topics.crossposts.removeAll(tid),
reduceCounters(tid),
]);
plugins.hooks.fire('action:topic.purge', { topic: deletedTopic, uid: uid });