Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Notification not working for group mentions and not respecting ignored users #11024

Merged
merged 5 commits into from
Jun 10, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ((hasMentionToAll || hasMentionToHere) && !disableAllMessageNotifications) {
Copy link
Member

@ggazzo ggazzo Jun 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like to make small tests before

} else if (!disableAllMessageNotifications && (hasMentionToAll || hasMentionToHere))

what do you think?

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 === 'mentions') || ((serverPreference === 'all' || hasMentionToAll || hasMentionToHere) && !disableAllMessageNotifications)) {
Copy link
Member

@ggazzo ggazzo Jun 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we really need room.t === 'd' && serverPreference === 'mentions' or just room.t === 'd' here? Because I think as we have serverPreference === 'all' that I think take care of the problem :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we do.. because serverPreference can be nothing

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