Skip to content

Commit

Permalink
feat: pass post object to filter:post.tools
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Feb 19, 2021
1 parent ed503b8 commit ed3d9dc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/socket.io/posts/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ module.exports = function (SocketPosts) {
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.hooks.fire('filter:post.tools', { pid: data.pid, uid: socket.uid, tools: [] }),
postSharing: social.getActivePostSharing(),
history: posts.diffs.exists(data.pid),
canViewInfo: privileges.global.can('view:users:info', socket.uid),
});

const postData = results.posts;
postData.tools = results.tools.tools;
postData.bookmarked = results.bookmarked;
postData.selfPost = socket.uid && socket.uid === postData.uid;
postData.display_edit_tools = results.canEdit.flag;
Expand All @@ -58,6 +56,13 @@ module.exports = function (SocketPosts) {
if (!results.isAdmin && !results.canViewInfo) {
postData.ip = undefined;
}
const tools = await plugins.hooks.fire('filter:post.tools', {
pid: data.pid,
post: postData,
uid: socket.uid,
tools: [],
});
postData.tools = tools.tools;
return results;
};

Expand Down

0 comments on commit ed3d9dc

Please sign in to comment.