java-topology/defects/rocketchat/patch/0001.patch

58 lines
1.8 KiB
Diff

--- a/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.ts
+++ b/apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.ts
@@ -73,7 +73,8 @@ export const sendNotification = async ({
if (subscription.u._id === sender._id) {
return;
}
- const hasMentionToUser = mentionIds.includes(subscription.u._id);
+ const hasMentionToUser = mentionIdSet.has(subscription.u._id);
// mute group notifications (@here and @all) if not directly mentioned as well
@@ -57,7 +57,8 @@ export const sendNotification = async ({
subscription,
sender,
hasReplyToThread,
hasMentionToAll,
hasMentionToHere,
message,
notificationMessage,
room,
- mentionIds,
+ mentionIdSet,
disableAllMessageNotifications,
}: {
subscription: SubscriptionAggregation;
sender: Pick<IUser, '_id' | 'name' | 'username'>;
hasReplyToThread: boolean;
hasMentionToAll: boolean;
hasMentionToHere: boolean;
message: AtLeast<IMessage, '_id' | 'u' | 'msg' | 't' | 'attachments'>;
notificationMessage: string;
room: IRoom;
- mentionIds: string[];
+ mentionIdSet: Set<string>;
disableAllMessageNotifications: boolean;
@@ -360,13 +360,15 @@ export async function sendMessageNotifications(message: IMessage, room: IRoom,
const subscriptions = await Subscriptions.col.aggregate<SubscriptionAggregation>([{ $match: query }, lookup, filter, project]).toArray();
+ const mentionIdSet = new Set(mentionIds);
+ const usersInThreadSet = new Set(usersInThread ?? []);
+
subscriptions.forEach(
(subscription) =>
void sendNotification({
subscription,
sender,
hasMentionToAll,
hasMentionToHere,
message,
notificationMessage,
room,
- mentionIds,
+ mentionIdSet,
disableAllMessageNotifications,
- hasReplyToThread: usersInThread?.includes(subscription.u._id),
+ hasReplyToThread: usersInThreadSet.has(subscription.u._id),
}),
);