From 2600c69185933525d894f34d89985aa0fd070214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Fri, 23 Aug 2019 15:57:31 +0200 Subject: [PATCH] Change code after @mattwr18 suggestions Co-Authored-By: mattwr18 --- .../handleNotifications/handleNotificationsMiddleware.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/backend/src/middleware/handleNotifications/handleNotificationsMiddleware.js b/backend/src/middleware/handleNotifications/handleNotificationsMiddleware.js index b56a1384e..dcd1be1d9 100644 --- a/backend/src/middleware/handleNotifications/handleNotificationsMiddleware.js +++ b/backend/src/middleware/handleNotifications/handleNotificationsMiddleware.js @@ -1,20 +1,19 @@ -import { UserInputError } from 'apollo-server' import extractMentionedUsers from './notifications/extractMentionedUsers' import extractHashtags from './hashtags/extractHashtags' const notifyUsers = async (label, id, idsOfUsers, reason, context) => { if (!idsOfUsers.length) return - // Done here, because Neode validation is not working. + // Checked here, because it does not go through GraphQL checks at all in this file. const reasonsAllowed = ['mentioned_in_post', 'mentioned_in_comment', 'comment_on_post'] if (!reasonsAllowed.includes(reason)) { - throw new UserInputError('Notification reason is not allowed!') + throw new Error('Notification reason is not allowed!') } if ( (label === 'Post' && reason !== 'mentioned_in_post') || (label === 'Comment' && !['mentioned_in_comment', 'comment_on_post'].includes(reason)) ) { - throw new UserInputError('Notification fits not to reason!') + throw new Error('Notification does not fit the reason!') } const session = context.driver.session()