diff --git a/src/posts/delete.js b/src/posts/delete.js index 9cb26b2860..aaf2618186 100644 --- a/src/posts/delete.js +++ b/src/posts/delete.js @@ -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}`), + ]); + } };