diff --git a/apps/meteor/app/lib/server/lib/notifyUsersOnMessage.ts b/apps/meteor/app/lib/server/lib/notifyUsersOnMessage.ts index 80cf172c9dcb1..c7102104e302c 100644 --- a/apps/meteor/app/lib/server/lib/notifyUsersOnMessage.ts +++ b/apps/meteor/app/lib/server/lib/notifyUsersOnMessage.ts @@ -105,7 +105,7 @@ async function updateUsersSubscriptions(message: IMessage, room: IRoom): Promise roomId: room._id, uidsExclude: [message.u._id], uidsInclude: userIds, - onlyRead: !toAll && !toHere && !unreadAllMessages, + onlyRead: !toAll && !toHere && !unreadAllMessages && room.t !== 'd', }).toArray(); // Give priority to user mentions over group mentions @@ -115,7 +115,7 @@ async function updateUsersSubscriptions(message: IMessage, room: IRoom): Promise await Subscriptions.incGroupMentionsAndUnreadForRoomIdExcludingUserId(room._id, message.u._id, 1, groupMentionInc); } - if (!toAll && !toHere && unreadAllMessages) { + if (!toAll && !toHere && (unreadAllMessages || room.t === 'd')) { await Subscriptions.incUnreadForRoomIdExcludingUserIds(room._id, [...userIds, message.u._id], 1); } @@ -127,12 +127,12 @@ async function updateUsersSubscriptions(message: IMessage, room: IRoom): Promise subs.forEach((sub) => { const hasUserMention = userIds.includes(sub.u._id); - const shouldIncUnread = hasUserMention || toAll || toHere || unreadAllMessages; + const shouldIncUnread = hasUserMention || toAll || toHere || unreadAllMessages || room.t === 'd'; void notifyOnSubscriptionChanged( { ...sub, alert: true, - open: true, + // open: true, ...(shouldIncUnread && { unread: sub.unread + 1 }), ...(hasUserMention && { userMentions: sub.userMentions + 1 }), ...((toAll || toHere) && { groupMentions: sub.groupMentions + 1 }),