Skip to content

Commit

Permalink
Increase unread message on @here mention
Browse files Browse the repository at this point in the history
  • Loading branch information
sampaiodiego committed May 23, 2017
1 parent 362ac8e commit 099e3db
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/rocketchat-lib/server/lib/notifyUsersOnMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) {
RocketChat.models.Subscriptions.incUnreadOfDirectForRoomIdExcludingUserId(message.rid, message.u._id, 1);
} else {
let toAll = false;
let toHere = false;
const mentionIds = [];
const highlightsIds = [];
const highlights = RocketChat.models.Users.findUsersByUsernamesWithHighlights(room.usernames, { fields: { '_id': 1, 'settings.preferences.highlights': 1 }}).fetch();
Expand All @@ -53,6 +54,9 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) {
if (!toAll && mention._id === 'all') {
toAll = true;
}
if (!toHere && mention._id === 'here') {
toHere = true;
}
if (mention._id !== message.u._id) {
mentionIds.push(mention._id);
}
Expand All @@ -67,7 +71,7 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) {
}
});

if (toAll) {
if (toAll || toHere) {
RocketChat.models.Subscriptions.incUnreadForRoomIdExcludingUserId(room._id, message.u._id);
} else if ((mentionIds && mentionIds.length > 0) || (highlightsIds && highlightsIds.length > 0)) {
RocketChat.models.Subscriptions.incUnreadForRoomIdAndUserIds(room._id, _.compact(_.unique(mentionIds.concat(highlightsIds))));
Expand Down

0 comments on commit 099e3db

Please sign in to comment.