From b49ace99eb0443e11db235ed83e383dd3bde6cf9 Mon Sep 17 00:00:00 2001 From: riley Date: Tue, 16 May 2017 16:38:30 -0600 Subject: [PATCH] add permission for EDIT_COMMENT --- graph/mutators/comment.js | 6 +++--- perms/mutationReducer.js | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/graph/mutators/comment.js b/graph/mutators/comment.js index e35080314..538bba931 100644 --- a/graph/mutators/comment.js +++ b/graph/mutators/comment.js @@ -99,7 +99,7 @@ const resolveNewCommentStatus = async (context, {asset_id, body}, wordlist = {}, if (wordlist.banned) { return 'REJECTED'; } - + if (settings.premodLinksEnable && linkify.test(body)) { return 'PREMOD'; } @@ -229,7 +229,7 @@ const edit = async (context, {id, asset_id, edit: {body}}) => { const [wordlist, settings] = await filterNewComment(context, {asset_id, body}); // Determine the new status of the comment. - const status = await resolveNewCommentStatus(context, {asset_id, body}, wordlist, settings); + const status = await resolveNewCommentStatus(context, {asset_id, body}, wordlist, settings); // Execute the edit. await CommentsService.edit(id, context.user.id, {body, status}); @@ -264,7 +264,7 @@ module.exports = (context) => { mutators.Comment.removeCommentTag = (action) => removeCommentTag(context, action); } - if (context.user && context.user.can('mutation:editComment')) { + if (context.user && context.user.can('EDIT_COMMENT')) { mutators.Comment.edit = (action) => edit(context, action); } diff --git a/perms/mutationReducer.js b/perms/mutationReducer.js index 0078c327b..b589bde90 100644 --- a/perms/mutationReducer.js +++ b/perms/mutationReducer.js @@ -8,6 +8,7 @@ module.exports = { CREATE_ACTION: 'CREATE_ACTION', DELETE_ACTION: 'DELETE_ACTION', EDIT_NAME: 'EDIT_NAME', + EDIT_COMMENT: 'EDIT_COMMENT', SET_USER_STATUS: 'SET_USER_STATUS', SUSPEND_USER: 'SUSPEND_USER', SET_COMMENT_STATUS: 'SET_COMMENT_STATUS', @@ -25,6 +26,8 @@ module.exports = { return true; case this.EDIT_NAME: return true; + case this.EDIT_COMMENT: + return true; case this.UPDATE_USER_ROLES: return check(user, ['ADMIN']); case this.SET_USER_STATUS: