Skip to content

Node.js based forum software built for the modern web

refactor: remove posts.tools.purge

Barış Soner Uşaklıed092bf6b583
diff --git a/src/posts/tools.js b/src/posts/tools.js
index d184bb1018..daa5bde189 100644
--- a/src/posts/tools.js
+++ b/src/posts/tools.js
@@ -41,13 +41,4 @@ module.exports = function (Posts) {
}
return post;
}
-
- Posts.tools.purge = async function (uid, pid) {
- const canPurge = await privileges.posts.canPurge(pid, uid);
- if (!canPurge) {
- throw new Error('[[error:no-privileges]]');
- }
- require('./cache').del(pid);
- await Posts.purge(pid, uid);
- };
};
diff --git a/src/socket.io/posts/tools.js b/src/socket.io/posts/tools.js
index 86eb42087e..3255722efe 100644
--- a/src/socket.io/posts/tools.js
+++ b/src/socket.io/posts/tools.js
@@ -131,7 +131,12 @@ module.exports = function (SocketPosts) {
const postData = await posts.getPostFields(data.pid, ['toPid', 'tid']);
postData.pid = data.pid;
- await posts.tools.purge(socket.uid, data.pid);
+ const canPurge = await privileges.posts.canPurge(data.pid, socket.uid);
+ if (!canPurge) {
+ throw new Error('[[error:no-privileges]]');
+ }
+ require('../../posts/cache').del(data.pid);
+ await posts.purge(data.pid, socket.uid);
websockets.in('topic_' + postData.tid).emit('event:post_purged', postData);
const topicData = await topics.getTopicFields(postData.tid, ['title', 'cid']);