mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
refactor: flags object in post tools
This commit is contained in:
@@ -90,9 +90,9 @@
|
|||||||
"nodebb-plugin-spam-be-gone": "0.7.2",
|
"nodebb-plugin-spam-be-gone": "0.7.2",
|
||||||
"nodebb-rewards-essentials": "0.1.3",
|
"nodebb-rewards-essentials": "0.1.3",
|
||||||
"nodebb-theme-lavender": "5.0.11",
|
"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-slick": "1.2.29",
|
||||||
"nodebb-theme-vanilla": "11.2.1",
|
"nodebb-theme-vanilla": "11.2.2",
|
||||||
"nodebb-widget-essentials": "4.1.1",
|
"nodebb-widget-essentials": "4.1.1",
|
||||||
"nodemailer": "^6.4.6",
|
"nodemailer": "^6.4.6",
|
||||||
"passport": "^0.4.1",
|
"passport": "^0.4.1",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const posts = require('../../posts');
|
const posts = require('../../posts');
|
||||||
const topics = require('../../topics');
|
const topics = require('../../topics');
|
||||||
|
const flags = require('../../flags');
|
||||||
const events = require('../../events');
|
const events = require('../../events');
|
||||||
const websockets = require('../index');
|
const websockets = require('../index');
|
||||||
const socketTopics = require('../topics');
|
const socketTopics = require('../topics');
|
||||||
@@ -27,6 +28,7 @@ module.exports = function (SocketPosts) {
|
|||||||
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),
|
||||||
canFlag: privileges.posts.canFlag(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),
|
bookmarked: posts.hasBookmarked(data.pid, socket.uid),
|
||||||
tools: plugins.fireHook('filter:post.tools', { pid: data.pid, uid: socket.uid, tools: [] }),
|
tools: plugins.fireHook('filter:post.tools', { pid: data.pid, uid: socket.uid, tools: [] }),
|
||||||
postSharing: social.getActivePostSharing(),
|
postSharing: social.getActivePostSharing(),
|
||||||
@@ -48,6 +50,12 @@ module.exports = function (SocketPosts) {
|
|||||||
postData.display_ip_ban = (results.isAdmin || results.isGlobalMod) && !postData.selfPost;
|
postData.display_ip_ban = (results.isAdmin || results.isGlobalMod) && !postData.selfPost;
|
||||||
postData.display_history = results.history;
|
postData.display_history = results.history;
|
||||||
postData.toolsVisible = postData.tools.length || postData.display_moderator_tools;
|
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) {
|
if (!results.isAdmin && !results.canViewInfo) {
|
||||||
postData.ip = undefined;
|
postData.ip = undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user