From a346632fffbfa92e3457627d25ab7a13d21622e9 Mon Sep 17 00:00:00 2001 From: mattwr18 Date: Tue, 18 Feb 2020 23:19:14 +0100 Subject: [PATCH] Avoid running cypher statement if not needed - it just feels safer to not run a cypher statement if there is no user in the idsOfUsers array. Why risk notifications pointing to empty nodes? It doesn't seem like this happens, but I'm not sure how to write a test to verify, and why run cypher statements, if there is no need to? --- backend/src/middleware/notifications/notificationsMiddleware.js | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/middleware/notifications/notificationsMiddleware.js b/backend/src/middleware/notifications/notificationsMiddleware.js index f84e7d392..64eca97c8 100644 --- a/backend/src/middleware/notifications/notificationsMiddleware.js +++ b/backend/src/middleware/notifications/notificationsMiddleware.js @@ -53,6 +53,7 @@ const postAuthorOfComment = async (commentId, { context }) => { } const notifyUsersOfMention = async (label, id, idsOfUsers, reason, context) => { + if (!(idsOfUsers && idsOfUsers.length)) return [] await validateNotifyUsers(label, reason) let mentionedCypher switch (reason) {