From f054a4f44d93326ba7d11c6338e135a3113da469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 6 Mar 2023 09:44:21 -0500 Subject: [PATCH] fix: get cid from pid instead of passing in --- public/src/client/topic/postTools.js | 2 +- src/socket.io/posts/tools.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/src/client/topic/postTools.js b/public/src/client/topic/postTools.js index e9b5602145..c9d57854b8 100644 --- a/public/src/client/topic/postTools.js +++ b/public/src/client/topic/postTools.js @@ -41,7 +41,7 @@ define('forum/topic/postTools', [ const pid = postEl.attr('data-pid'); const index = parseInt(postEl.attr('data-index'), 10); - socket.emit('posts.loadPostTools', { pid: pid, cid: ajaxify.data.cid }, async (err, data) => { + socket.emit('posts.loadPostTools', { pid: pid }, async (err, data) => { if (err) { return alerts.error(err); } diff --git a/src/socket.io/posts/tools.js b/src/socket.io/posts/tools.js index db6e432fa6..4ff69e7fc0 100644 --- a/src/socket.io/posts/tools.js +++ b/src/socket.io/posts/tools.js @@ -14,15 +14,15 @@ const utils = require('../../utils'); module.exports = function (SocketPosts) { SocketPosts.loadPostTools = async function (socket, data) { - if (!data || !data.pid || !data.cid) { + if (!data || !data.pid) { throw new Error('[[error:invalid-data]]'); } - + const cid = await posts.getCidByPid(data.pid); const results = await utils.promiseParallel({ posts: posts.getPostFields(data.pid, ['deleted', 'bookmarks', 'uid', 'ip', 'flagId']), isAdmin: user.isAdministrator(socket.uid), isGlobalMod: user.isGlobalModerator(socket.uid), - isModerator: user.isModerator(socket.uid, data.cid), + isModerator: user.isModerator(socket.uid, cid), canEdit: privileges.posts.canEdit(data.pid, socket.uid), canDelete: privileges.posts.canDelete(data.pid, socket.uid), canPurge: privileges.posts.canPurge(data.pid, socket.uid),