diff --git a/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js b/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js index 59e757526f8c..309e3f896428 100644 --- a/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js +++ b/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js @@ -194,11 +194,13 @@ function sendAllNotifications(message, room) { }); } - if (RocketChat.settings.get(`Accounts_Default_User_Preferences_${ notificationField }`) === 'all' && !disableAllMessageNotifications) { + 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)) { query.$or.push({ [notificationField]: { $exists: false } }); - } else if (RocketChat.settings.get(`Accounts_Default_User_Preferences_${ notificationField }`) === 'mentions' && mentionIdsWithoutGroups.length) { + } else if (serverPreference === 'mentions' && mentionIdsWithoutGroups.length) { query.$or.push({ [notificationField]: { $exists: false }, 'u._id': { $in: mentionIdsWithoutGroups }