Skip to content

Commit

Permalink
Merge pull request #7754 from RocketChat/fix-mentions-email-notification
Browse files Browse the repository at this point in the history
[FIX] Fix email on mention
  • Loading branch information
rodrigok authored Sep 5, 2017
2 parents cc2a537 + 1ba25f7 commit c25746c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/rocketchat-lib/server/lib/sendEmailOnMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) {
if (room.t === 'd') {
usersToSendEmail[message.rid.replace(message.u._id, '')] = 'direct';
} else {
const isMentionAll = message.mentions.find((mention) => {
return mention._id === 'all';
});
RocketChat.models.Subscriptions.findWithSendEmailByRoomId(room._id).forEach((sub) => {
if (sub.disableNotifications) {
return delete usersToSendEmail[sub.u._id];
Expand All @@ -55,7 +58,11 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) {
return mention._id === sub.u._id;
});

if (emailNotifications === 'mentions' || mentionedUser) {
if (emailNotifications === 'mentions' && (mentionedUser || isMentionAll)) {
const maxMembersForNotification = RocketChat.settings.get('Notifications_Max_Room_Members');
if (isMentionAll && maxMembersForNotification !== 0 && room.usernames.length > maxMembersForNotification) {
return;
}
return usersToSendEmail[sub.u._id] = 'mention';
}

Expand Down

0 comments on commit c25746c

Please sign in to comment.