Skip to content

Commit

Permalink
fix: Read receipts are not created on the first time a user reads a r…
Browse files Browse the repository at this point in the history
…oom (#30610)

Co-authored-by: Heitor Tanoue <68477006+heitortanoue@users.noreply.github.com>
  • Loading branch information
matheusbsilva137 and heitortanoue committed Oct 17, 2023
1 parent 85ddfb2 commit ff2263a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/weak-cameras-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed issue with message read receipts not being created when accessing a room the first time
5 changes: 3 additions & 2 deletions apps/meteor/server/lib/readMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { callbacks } from '../../lib/callbacks';
export async function readMessages(rid: IRoom['_id'], uid: IUser['_id'], readThreads: boolean): Promise<void> {
await callbacks.run('beforeReadMessages', rid, uid);

const projection = { ls: 1, tunread: 1, alert: 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');
Expand All @@ -19,5 +19,6 @@ export async function readMessages(rid: IRoom['_id'], uid: IUser['_id'], readThr

await NotificationQueue.clearQueueByUserId(uid);

callbacks.runAsync('afterReadMessages', rid, { uid, lastSeen: sub.ls });
const lastSeen = sub.ls || sub.ts;
callbacks.runAsync('afterReadMessages', rid, { uid, lastSeen });
}

0 comments on commit ff2263a

Please sign in to comment.