From dde591c4b34aa6c0e938d970c25a428380d02b93 Mon Sep 17 00:00:00 2001 From: matheusbsilva137 Date: Fri, 13 Oct 2023 17:13:18 -0300 Subject: [PATCH] Use older timestamp so that more messages are marked as read --- apps/meteor/server/lib/readMessages.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/meteor/server/lib/readMessages.ts b/apps/meteor/server/lib/readMessages.ts index 09aea69ca65a..d7c8cf559288 100644 --- a/apps/meteor/server/lib/readMessages.ts +++ b/apps/meteor/server/lib/readMessages.ts @@ -6,7 +6,7 @@ import { callbacks } from '../../lib/callbacks'; export async function readMessages(rid: IRoom['_id'], uid: IUser['_id'], readThreads: boolean): Promise { await callbacks.run('beforeReadMessages', rid, uid); - const projection = { ls: 1, tunread: 1, alert: 1, _updatedAt: 1 }; + const projection = { ls: 1, tunread: 1, alert: 1, ts: 1 }; const sub = await Subscriptions.findOneByRoomIdAndUserId(rid, uid, { projection }); if (!sub) { throw new Error('error-invalid-subscription'); @@ -19,6 +19,6 @@ export async function readMessages(rid: IRoom['_id'], uid: IUser['_id'], readThr await NotificationQueue.clearQueueByUserId(uid); - const lastSeen = sub.ls || sub._updatedAt; + const lastSeen = sub.ls || sub.ts; callbacks.runAsync('afterReadMessages', rid, { uid, lastSeen }); }