From ae07dfb2cdf18d92607d36aae37bcad3fd74ca39 Mon Sep 17 00:00:00 2001 From: PepeFranco Date: Mon, 30 Oct 2017 16:56:52 -0600 Subject: [PATCH] Added check for user & comments --- graph/mutators/action.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/graph/mutators/action.js b/graph/mutators/action.js index 794da581a..60f939477 100644 --- a/graph/mutators/action.js +++ b/graph/mutators/action.js @@ -33,12 +33,16 @@ const createAction = async ({user = {}, pubsub, loaders: {Comments}}, {item_id, if (item_type === 'USERS' && action_type === 'FLAG') { - // Set the user as pending if it was a user flag. - await UsersService.setStatus(item_id, 'PENDING'); + // Set the user as pending if it was a user flag and user has no Admin, Staff or Moderation roles + let user = await UsersService.findById(item_id); + if(!user.roles) + await UsersService.setStatus(item_id, 'PENDING'); } if (comment) { - pubsub.publish('commentFlagged', comment); + let user = await UsersService.findById(comment.author_id); + if(!user.roles) + pubsub.publish('commentFlagged', comment); } return action;