feat: delete diffs on post purge, closes #10291

isekai-main
Barış Soner Uşaklı 3 years ago
parent 503e27f709
commit e9e48a756f

@ -60,6 +60,7 @@ module.exports = function (Posts) {
deletePostFromUsersVotes(pid),
deletePostFromReplies(postData),
deletePostFromGroups(postData),
deletePostDiffs(pid),
db.sortedSetsRemove(['posts:pid', 'posts:votes', 'posts:flagged'], pid),
Posts.uploads.dissociateAll(pid),
]);
@ -144,4 +145,12 @@ module.exports = function (Posts) {
const keys = groupNames[0].map(groupName => `group:${groupName}:member:pids`);
await db.sortedSetsRemove(keys, postData.pid);
}
async function deletePostDiffs(pid) {
const timestamps = await Posts.diffs.list(pid);
await db.deleteAll([
`post:${pid}:diffs`,
...timestamps.map(t => `diff:${pid}.${t}`),
]);
}
};

Loading…
Cancel
Save