diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 6d3a1ff4ea6e..27749b6a2614 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -1418,6 +1418,7 @@ "multi": "multi", "multi_line": "multi line", "Mute_all_notifications": "Mute all notifications", + "Mute_Group_Mentions" : "Mute @all and @here mentions", "mute-user": "Mute User", "mute-user_description": "Permission to mute other users in the same channel", "Mute_Focused_Conversations": "Mute Focused Conversations", @@ -1654,6 +1655,7 @@ "Reason_To_Join": "Reason to Join", "RealName_Change_Disabled": "Your Rocket.Chat administrator has disabled the changing of names", "Receive_alerts": "Receive alerts", + "Receive_Group_Mentions" : "Receive @all and @here mentions", "Record": "Record", "Redirect_URI": "Redirect URI", "Refresh_keys": "Refresh keys", diff --git a/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js b/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js index 779b1c57b888..c4351cc46c7c 100644 --- a/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js +++ b/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js @@ -118,17 +118,21 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) { query = RocketChat.models.Subscriptions.findByRoomIdAndUserIdsOrAllMessages(room._id, userIds); } - query.forEach((sub) => { + query.forEach(sub => { if (sub.disableNotifications) { return delete usersToSendEmail[sub.u._id]; } - const emailNotifications = sub.emailNotifications; + const { emailNotifications, muteGroupMentions } = sub; if (emailNotifications === 'nothing') { return delete usersToSendEmail[sub.u._id]; } + if (isMentionAll && muteGroupMentions) { + return delete usersToSendEmail[sub.u._id]; + } + const mentionedUser = isMentionAll || message.mentions.find(mention => mention._id === sub.u._id); if (emailNotifications === 'default' || emailNotifications == null) { diff --git a/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js b/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js index 33532cb036a9..aee2caa865ff 100644 --- a/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js +++ b/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js @@ -181,7 +181,8 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room, userId) { desktopNotificationDurations: {}, alwaysNotifyAudioUsers: [], dontNotifyAudioUsers: [], - audioNotificationValues: {} + audioNotificationValues: {}, + dontNotifyUsersOnGroupMentions: [] }; /** @@ -248,6 +249,10 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room, userId) { settings.audioNotificationValues[subscription.u._id] = subscription.audioNotificationValue; settings.desktopNotificationDurations[subscription.u._id] = subscription.desktopNotificationDuration; + + if (subscription.muteGroupMentions) { + settings.dontNotifyUsersOnGroupMentions.push(subscription.u._id); + } }); let userIdsForAudio = []; let userIdsToNotify = []; @@ -419,17 +424,21 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room, userId) { status: 1, statusConnection: 1 } - }).forEach(function(user) { - if (['online', 'away', 'busy'].includes(user.status) && !(settings.dontNotifyDesktopUsers || []).includes(user._id)) { - userIdsToNotify.push(user._id); - userIdsForAudio.push(user._id); + }).forEach(function({ status, _id, username, statusConnection }) { // user + if (Array.isArray(settings.dontNotifyUsersOnGroupMentions) && settings.dontNotifyUsersOnGroupMentions.includes(_id)) { + return; + } + + if (['online', 'away', 'busy'].includes(status) && !(settings.dontNotifyDesktopUsers || []).includes(_id)) { + userIdsToNotify.push(_id); + userIdsForAudio.push(_id); } - if (toAll && user.statusConnection !== 'online' && !(settings.dontNotifyMobileUsers || []).includes(user._id)) { - pushUsernames[user._id] = user.username; - return userIdsToPushNotify.push(user._id); + if (toAll && statusConnection !== 'online' && !(settings.dontNotifyMobileUsers || []).includes(_id)) { + pushUsernames[_id] = username; + return userIdsToPushNotify.push(_id); } - if (toAll && user.statusConnection !== 'online') { - userIdsForAudio.push(user._id); + if (toAll && statusConnection !== 'online') { + userIdsForAudio.push(_id); } }); } diff --git a/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.html b/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.html index 59cff0f76060..962ab0c2ef81 100644 --- a/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.html +++ b/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.html @@ -24,6 +24,24 @@ +