diff --git a/packages/rocketchat-lib/server/lib/notifyUsersOnMessage.js b/packages/rocketchat-lib/server/lib/notifyUsersOnMessage.js index f7de5878e46..59de2faa8ec 100644 --- a/packages/rocketchat-lib/server/lib/notifyUsersOnMessage.js +++ b/packages/rocketchat-lib/server/lib/notifyUsersOnMessage.js @@ -16,8 +16,12 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) { if (! highlights || highlights.length == 0) { return false; } var has = false; - highlights.forEach(function (highlight) { - if (message.msg.includes(highlight)) { has = true; } + highlights.some(function (highlight) { + var regexp = new RegExp(s.escapeRegExp(highlight),'i'); + if (regexp.test(message.msg)) { + has = true; + return true; + } }); return has; diff --git a/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js b/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js index a393b1024e1..143af40baa7 100644 --- a/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js +++ b/packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js @@ -42,8 +42,12 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) { if (! highlights || highlights.length == 0) { return false; } var has = false; - highlights.forEach(function (highlight) { - if (message.msg.includes(highlight)) { has = true; } + highlights.some(function (highlight) { + var regexp = new RegExp(s.escapeRegExp(highlight),'i'); + if (regexp.test(message.msg)) { + has = true; + return true; + } }); return has; @@ -259,6 +263,17 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) { }); } } + // if (mentionIds > 0) { + // /* + // Update all other subscriptions of mentioned users to alert their owners and incrementing + // the unread counter for mentions and direct messages + // */ + // if (toAll) { + // RocketChat.models.Subscriptions.incUnreadForRoomIdExcludingUserId(message.rid, user._id, 1); + // } else { + // RocketChat.models.Subscriptions.incUnreadForRoomIdAndUserIds(message.rid, mentionIds, 1); + // } + // } } return message;