fix: get cid from pid instead of passing in

isekai-main
Barış Soner Uşaklı 2 years ago
parent 8c762d3228
commit f054a4f44d

@ -41,7 +41,7 @@ define('forum/topic/postTools', [
const pid = postEl.attr('data-pid'); const pid = postEl.attr('data-pid');
const index = parseInt(postEl.attr('data-index'), 10); 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) { if (err) {
return alerts.error(err); return alerts.error(err);
} }

@ -14,15 +14,15 @@ const utils = require('../../utils');
module.exports = function (SocketPosts) { module.exports = function (SocketPosts) {
SocketPosts.loadPostTools = async function (socket, data) { SocketPosts.loadPostTools = async function (socket, data) {
if (!data || !data.pid || !data.cid) { if (!data || !data.pid) {
throw new Error('[[error:invalid-data]]'); throw new Error('[[error:invalid-data]]');
} }
const cid = await posts.getCidByPid(data.pid);
const results = await utils.promiseParallel({ const results = await utils.promiseParallel({
posts: posts.getPostFields(data.pid, ['deleted', 'bookmarks', 'uid', 'ip', 'flagId']), posts: posts.getPostFields(data.pid, ['deleted', 'bookmarks', 'uid', 'ip', 'flagId']),
isAdmin: user.isAdministrator(socket.uid), isAdmin: user.isAdministrator(socket.uid),
isGlobalMod: user.isGlobalModerator(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), canEdit: privileges.posts.canEdit(data.pid, socket.uid),
canDelete: privileges.posts.canDelete(data.pid, socket.uid), canDelete: privileges.posts.canDelete(data.pid, socket.uid),
canPurge: privileges.posts.canPurge(data.pid, socket.uid), canPurge: privileges.posts.canPurge(data.pid, socket.uid),

Loading…
Cancel
Save