fix: update post cache clearing logic to call helper function

regression from 8cf9617630
This commit is contained in:
Julian Lam
2024-05-28 12:01:30 -04:00
parent f2e43e894b
commit 547fc17dcf
3 changed files with 4 additions and 6 deletions

View File

@@ -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 }),

View File

@@ -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);

View File

@@ -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);