From ae07dfb2cdf18d92607d36aae37bcad3fd74ca39 Mon Sep 17 00:00:00 2001 From: PepeFranco Date: Mon, 30 Oct 2017 16:56:52 -0600 Subject: [PATCH 1/4] 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; From 350e679abf88eca8d95154cd368b93abf25b521c Mon Sep 17 00:00:00 2001 From: PepeFranco Date: Mon, 30 Oct 2017 16:58:51 -0600 Subject: [PATCH 2/4] Added check for user & comments --- graph/mutators/action.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/graph/mutators/action.js b/graph/mutators/action.js index 60f939477..a5bf16051 100644 --- a/graph/mutators/action.js +++ b/graph/mutators/action.js @@ -35,14 +35,16 @@ const createAction = async ({user = {}, pubsub, loaders: {Comments}}, {item_id, // 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) + if(!user.roles){ await UsersService.setStatus(item_id, 'PENDING'); + } } if (comment) { let user = await UsersService.findById(comment.author_id); - if(!user.roles) + if(!user.roles){ pubsub.publish('commentFlagged', comment); + } } return action; From 886a468993c5031b5d36aea8805dc11ef6f218bf Mon Sep 17 00:00:00 2001 From: PepeFranco Date: Tue, 31 Oct 2017 12:56:32 -0600 Subject: [PATCH 3/4] Reverting comment changes --- graph/mutators/action.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/graph/mutators/action.js b/graph/mutators/action.js index a5bf16051..cc1fc0030 100644 --- a/graph/mutators/action.js +++ b/graph/mutators/action.js @@ -41,10 +41,7 @@ const createAction = async ({user = {}, pubsub, loaders: {Comments}}, {item_id, } if (comment) { - let user = await UsersService.findById(comment.author_id); - if(!user.roles){ pubsub.publish('commentFlagged', comment); - } } return action; From f70ccf641aa39283a8c614e905d48ece41239762 Mon Sep 17 00:00:00 2001 From: PepeFranco Date: Tue, 31 Oct 2017 13:29:44 -0600 Subject: [PATCH 4/4] Fixed lint issue --- graph/mutators/action.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graph/mutators/action.js b/graph/mutators/action.js index cc1fc0030..50d62225a 100644 --- a/graph/mutators/action.js +++ b/graph/mutators/action.js @@ -41,7 +41,7 @@ const createAction = async ({user = {}, pubsub, loaders: {Comments}}, {item_id, } if (comment) { - pubsub.publish('commentFlagged', comment); + pubsub.publish('commentFlagged', comment); } return action;