Node.js based forum software built for the modern web
fix: update post cache clearing logic to call helper function
Julian Lam547fc17dcf85
diff --git a/src/api/posts.js b/src/api/posts.jsindex 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.jsindex 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.jsindex 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);