refactor: flags object in post tools

v1.18.x
Julian Lam
parent caa78cc1f6
commit fcdbdf63a3

@ -90,9 +90,9 @@
"nodebb-plugin-spam-be-gone": "0.7.2",
"nodebb-rewards-essentials": "0.1.3",
"nodebb-theme-lavender": "5.0.11",
"nodebb-theme-persona": "10.2.2",
"nodebb-theme-persona": "10.2.3",
"nodebb-theme-slick": "1.2.29",
"nodebb-theme-vanilla": "11.2.1",
"nodebb-theme-vanilla": "11.2.2",
"nodebb-widget-essentials": "4.1.1",
"nodemailer": "^6.4.6",
"passport": "^0.4.1",

@ -2,6 +2,7 @@
const posts = require('../../posts');
const topics = require('../../topics');
const flags = require('../../flags');
const events = require('../../events');
const websockets = require('../index');
const socketTopics = require('../topics');
@ -27,6 +28,7 @@ module.exports = function (SocketPosts) {
canDelete: privileges.posts.canDelete(data.pid, socket.uid),
canPurge: privileges.posts.canPurge(data.pid, socket.uid),
canFlag: privileges.posts.canFlag(data.pid, socket.uid),
flagged: flags.exists('post', data.pid, socket.uid), // specifically, whether THIS calling user flagged
bookmarked: posts.hasBookmarked(data.pid, socket.uid),
tools: plugins.fireHook('filter:post.tools', { pid: data.pid, uid: socket.uid, tools: [] }),
postSharing: social.getActivePostSharing(),
@ -48,6 +50,12 @@ module.exports = function (SocketPosts) {
postData.display_ip_ban = (results.isAdmin || results.isGlobalMod) && !postData.selfPost;
postData.display_history = results.history;
postData.toolsVisible = postData.tools.length || postData.display_moderator_tools;
postData.flags = {
flagId: parseInt(results.posts.flagId, 10) || null,
can: results.canFlag.flag,
exists: !!results.posts.flagId,
flagged: results.flagged,
};
if (!results.isAdmin && !results.canViewInfo) {
postData.ip = undefined;

Loading…
Cancel
Save