Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/brave-shrimps-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Improved support for higlighted words in threads (rooms are now marked as unread and notifications are sent)
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,6 @@ export function shouldNotifyDesktop({
isHighlighted ||
desktopNotifications === 'all' ||
hasMentionToUser) &&
(!isThread || hasReplyToThread)
(isHighlighted || !isThread || hasReplyToThread)
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,6 @@ export function shouldNotifyEmail({
emailNotifications === 'all' ||
hasMentionToUser ||
(!disableAllMessageNotifications && hasMentionToAll)) &&
(!isThread || hasReplyToThread)
(isHighlighted || !isThread || hasReplyToThread)
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,6 @@ export function shouldNotifyMobile({
isHighlighted ||
mobilePushNotifications === 'all' ||
hasMentionToUser) &&
(!isThread || hasReplyToThread)
(isHighlighted || !isThread || hasReplyToThread)
);
}
2 changes: 1 addition & 1 deletion apps/meteor/app/lib/server/lib/notifyUsersOnMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const incUserMentions = async (rid, roomType, uids, unreadCount) => {
await Subscriptions.incUserMentionsAndUnreadForRoomIdAndUserIds(rid, uids, 1, incUnread);
};

const getUserIdsFromHighlights = async (rid, message) => {
export const getUserIdsFromHighlights = async (rid, message) => {
const highlightOptions = { projection: { 'userHighlights': 1, 'u._id': 1 } };
const subs = await Subscriptions.findByRoomWithUserHighlights(rid, highlightOptions).toArray();

Expand Down
13 changes: 11 additions & 2 deletions apps/meteor/app/threads/server/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { IMessage } from '@rocket.chat/core-typings';
import { isEditedMessage } from '@rocket.chat/core-typings';
import { Messages, Subscriptions, ReadReceipts, NotificationQueue } from '@rocket.chat/models';

import { getMentions } from '../../lib/server/lib/notifyUsersOnMessage';
import { getMentions, getUserIdsFromHighlights } from '../../lib/server/lib/notifyUsersOnMessage';

export async function reply({ tmid }: { tmid?: string }, message: IMessage, parentMessage: IMessage, followers: string[]) {
const { rid, ts, u } = message;
Expand All @@ -19,7 +19,9 @@ export async function reply({ tmid }: { tmid?: string }, message: IMessage, pare
...(Array.isArray(parentMessage.replies) && parentMessage.replies.length ? [u._id] : [parentMessage.u._id, u._id]),
]),
];
const highlightedUserIds = new Set<string>();

(await getUserIdsFromHighlights(rid, message)).forEach((uid) => highlightedUserIds.add(uid));
await Messages.updateRepliesByThreadId(tmid, addToReplies, ts);
await ReadReceipts.setAsThreadById(tmid);

Expand All @@ -35,9 +37,16 @@ export async function reply({ tmid }: { tmid?: string }, message: IMessage, pare
await Subscriptions.addUnreadThreadByRoomIdAndUserIds(rid, repliesFiltered, tmid, {});
}

for await (const userId of mentionIds) {
const mentionedUsers = new Set<string>([...mentionIds, ...highlightedUserIds]);
for await (const userId of mentionedUsers) {
await Subscriptions.addUnreadThreadByRoomIdAndUserIds(rid, [userId], tmid, { userMention: true });
}

const highlightIds = Array.from(highlightedUserIds);
if (highlightIds.length) {
await Subscriptions.setAlertForRoomIdAndUserIds(rid, highlightIds);
await Subscriptions.setOpenForRoomIdAndUserIds(rid, highlightIds);
}
}

export async function follow({ tmid, uid }: { tmid: string; uid: string }) {
Expand Down