From f527f4e7dfc1373d7aa8452db7f91cfe513ff7c2 Mon Sep 17 00:00:00 2001 From: Martin Schoeler Date: Wed, 16 Aug 2017 10:45:28 -0300 Subject: [PATCH 1/2] fix email on mention --- packages/rocketchat-lib/server/lib/sendEmailOnMessage.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js b/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js index 94258f5ae1aa..213483a075cf 100644 --- a/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js +++ b/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js @@ -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]; @@ -55,7 +58,7 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) { return mention._id === sub.u._id; }); - if (emailNotifications === 'mentions' || mentionedUser) { + if (emailNotifications === 'mentions' && (mentionedUser || isMentionAll)) { return usersToSendEmail[sub.u._id] = 'mention'; } From 1ba25f7d5ef4c9b9fbb9ccc87376022976a710b5 Mon Sep 17 00:00:00 2001 From: Martin Schoeler Date: Mon, 4 Sep 2017 13:48:50 -0300 Subject: [PATCH 2/2] Enforce notifications_max_room_members on mention --- packages/rocketchat-lib/server/lib/sendEmailOnMessage.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js b/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js index cbd31bb6790e..78b4c419e4b6 100644 --- a/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js +++ b/packages/rocketchat-lib/server/lib/sendEmailOnMessage.js @@ -59,6 +59,10 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) { }); 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'; }