Skip to content

Commit

Permalink
[FIX] Notification not working for group mentions and not respecting …
Browse files Browse the repository at this point in the history
…ignored users (#11024)

* Fix @ALL notifications and ignored users

* Execute simple tests first
  • Loading branch information
sampaiodiego authored Jun 10, 2018
1 parent bab922f commit 36689b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const sendNotification = ({
}

// dont send notification to users who ignored the sender
if (Array.isArray(subscription.ignored) && subscription.ignored.find(sender._id)) {
if (Array.isArray(subscription.ignored) && subscription.ignored.includes(sender._id)) {
return;
}

Expand Down Expand Up @@ -199,11 +199,15 @@ function sendAllNotifications(message, room) {
[notificationField]: 'mentions',
'u._id': { $in: mentionIdsWithoutGroups }
});
} else if (!disableAllMessageNotifications && (hasMentionToAll || hasMentionToHere)) {
query.$or.push({
[notificationField]: 'mentions'
});
}

const serverField = kind === 'email' ? 'emailNotificationMode' : `${ kind }Notifications`;
const serverPreference = RocketChat.settings.get(`Accounts_Default_User_Preferences_${ serverField }`);
if ((room.t === 'd' && serverPreference === 'mentions') || (serverPreference === 'all' && !disableAllMessageNotifications)) {
if ((room.t === 'd' && serverPreference !== 'nothing') || (!disableAllMessageNotifications && (serverPreference === 'all' || hasMentionToAll || hasMentionToHere))) {
query.$or.push({
[notificationField]: { $exists: false }
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ RocketChat.models.Subscriptions.findNotificationPreferencesByRoom = function(que
code: 1,

// fields to define if should send a notification
ignored: 1,
audioNotifications: 1,
audioNotificationValue: 1,
desktopNotificationDuration: 1,
Expand Down

0 comments on commit 36689b1

Please sign in to comment.