From 1521d4dbac62f434c2989318474d6b07c1ac5cf3 Mon Sep 17 00:00:00 2001 From: David Herman Date: Fri, 13 Aug 2021 18:32:19 +0200 Subject: [PATCH] fix: Suppress notifications for suspended users (#2448) * fix: Supress notifications for suspended users * spelling Co-authored-by: Tom Moor --- server/services/notifications.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/server/services/notifications.js b/server/services/notifications.js index 3ed340db9..06c911959 100644 --- a/server/services/notifications.js +++ b/server/services/notifications.js @@ -63,6 +63,11 @@ export default class Notifications { event.name === "documents.publish" ? "published" : "updated"; for (const setting of notificationSettings) { + // Suppress notifications for suspended users + if (setting.user.isSuspended) { + continue; + } + // For document updates we only want to send notifications if // the document has been edited by the user with this notification setting // This could be replaced with ability to "follow" in the future @@ -141,14 +146,19 @@ export default class Notifications { ], }); - notificationSettings.forEach((setting) => + notificationSettings.forEach((setting) => { + // Suppress notifications for suspended users + if (setting.user.isSuspended) { + return; + } + mailer.collectionNotification({ to: setting.user.email, eventName: "created", collection, actor: collection.user, unsubscribeUrl: setting.unsubscribeUrl, - }) - ); + }); + }); } }