Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Read receipts are not created on the first time a user reads a room #30610

Merged
merged 16 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 11 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/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 });
}
Loading