Skip to content
Snippets Groups Projects
Commit a3e88a15 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento Committed by GitHub
Browse files

Merge pull request #7059 from RocketChat/increase-onread-for-here-mention

[NEW] Increase unread message count on @here mention
parents dda3cb9d 099e3db1
No related branches found
No related tags found
No related merge requests found
......@@ -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();
......@@ -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);
}
......@@ -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))));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment