Skip to content
Snippets Groups Projects
Unverified Commit 099e3db1 authored by Diego Sampaio's avatar Diego Sampaio
Browse files

Increase unread message on @here mention

parent 362ac8ea
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