From 547fc17dcf85d3da9f45d5b8cba5a9f82b4eafe0 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 28 May 2024 12:01:30 -0400 Subject: [PATCH] fix: update post cache clearing logic to call helper function regression from 8cf9617630b020bd5d8a002de6090c917f172e63 --- src/api/posts.js | 2 +- src/posts/edit.js | 6 ++---- src/posts/tools.js | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/api/posts.js b/src/api/posts.js index 30b4ba79f6..d136c3bd48 100644 --- a/src/api/posts.js +++ b/src/api/posts.js @@ -239,7 +239,7 @@ postsAPI.purge = async function (caller, data) { if (!canPurge) { throw new Error('[[error:no-privileges]]'); } - require('../posts/cache').del(data.pid); + posts.clearCachedPost(data.pid); await Promise.all([ posts.purge(data.pid, caller.uid), require('.').activitypub.delete.note(caller, { pid: data.pid }), diff --git a/src/posts/edit.js b/src/posts/edit.js index 64c658ca02..a8b702232e 100644 --- a/src/posts/edit.js +++ b/src/posts/edit.js @@ -15,9 +15,7 @@ const slugify = require('../slugify'); const translator = require('../translator'); module.exports = function (Posts) { - pubsub.on('post:edit', (pid) => { - require('./cache').del(pid); - }); + pubsub.on('post:edit', pid => Posts.clearCachedPost(pid)); Posts.edit = async function (data) { const { _activitypub } = data; @@ -92,7 +90,7 @@ module.exports = function (Posts) { plugins.hooks.fire('action:post.edit', { post: { ...returnPostData, _activitypub }, data: data, uid: data.uid }); - require('./cache').del(String(postData.pid)); + Posts.clearCachedPost(String(postData.pid)); pubsub.publish('post:edit', String(postData.pid)); await Posts.parsePost(returnPostData); diff --git a/src/posts/tools.js b/src/posts/tools.js index daa5bde189..e12fa866fa 100644 --- a/src/posts/tools.js +++ b/src/posts/tools.js @@ -33,7 +33,7 @@ module.exports = function (Posts) { } let post; if (isDelete) { - require('./cache').del(pid); + Posts.clearCachedPost(pid); post = await Posts.delete(pid, uid); } else { post = await Posts.restore(pid, uid);