From bdb892bd60a3302a6fdf889b14c495143bfa8f4c Mon Sep 17 00:00:00 2001 From: Tibet Sprague Date: Wed, 23 Nov 2022 10:17:45 -0800 Subject: [PATCH 1/3] Don't send announcement emails or push notifications when notifications are turned off in a group Fixes https://github.com/Hylozoic/hylo-node/issues/893 --- api/models/Activity.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/models/Activity.js b/api/models/Activity.js index 7f0cef64c..7dafbfa0f 100644 --- a/api/models/Activity.js +++ b/api/models/Activity.js @@ -280,11 +280,13 @@ module.exports = bookshelf.Model.extend({ const emailable = membershipsPermitting('sendEmail') const pushable = membershipsPermitting('sendPushNotifications') - if ((!isEmpty(emailable) && !isJustNewPost(activity)) || isAnnouncement(activity)) { + // Send emails if email notifications on and is announcement or + if (!isEmpty(emailable) && (!isJustNewPost(activity) || isAnnouncement(activity))) { notifications.push(Notification.MEDIUM.Email) } - if (isTopic(activity) || !isEmpty(pushable) || isAnnouncement(activity)) { + // XXX: right now all notification types get sent as a push notification. Is this what we want? + if (!isEmpty(pushable)) { notifications.push(Notification.MEDIUM.Push) } From 57217c18becdc3b3befe0621fc6bd097c64cac0a Mon Sep 17 00:00:00 2001 From: Tibet Sprague Date: Wed, 23 Nov 2022 10:18:46 -0800 Subject: [PATCH 2/3] comment --- api/models/Activity.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/models/Activity.js b/api/models/Activity.js index 7dafbfa0f..73f144c00 100644 --- a/api/models/Activity.js +++ b/api/models/Activity.js @@ -280,7 +280,7 @@ module.exports = bookshelf.Model.extend({ const emailable = membershipsPermitting('sendEmail') const pushable = membershipsPermitting('sendPushNotifications') - // Send emails if email notifications on and is announcement or + // Send emails if email notifications on and is announcement or "not just a new post" notification if (!isEmpty(emailable) && (!isJustNewPost(activity) || isAnnouncement(activity))) { notifications.push(Notification.MEDIUM.Email) } From 736352c6740c222f818e23cd97b46e7b1ee72911 Mon Sep 17 00:00:00 2001 From: Tibet Sprague Date: Wed, 23 Nov 2022 11:14:20 -0800 Subject: [PATCH 3/3] CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aeee9f039..9cd7ed91f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Fixed +- Don't send emails or push notifications for Announcements when notifications are turned off in a group + ## [5.0.2] - 2022-11-13 ### Added