-
Notifications
You must be signed in to change notification settings - Fork 20
feat: add read receipts support #339
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import type { RoomID, UserID } from '@rocket.chat/federation-room'; | ||
|
|
||
| import type { BaseEDU } from './base'; | ||
|
|
||
| /** | ||
| * Typing receipt EDU as defined in the Matrix specification | ||
| * | ||
| * @see https://spec.matrix.org/latest/server-server-api/#receipts | ||
| */ | ||
| export interface ReceiptEDU extends BaseEDU { | ||
| edu_type: 'm.receipt'; | ||
| content: Record< | ||
| RoomID, | ||
| { | ||
| 'm.read': Record< | ||
| UserID, | ||
| { | ||
| data: { | ||
| thread_id?: string; | ||
| ts: number; | ||
| }; | ||
| event_ids: string[]; | ||
| } | ||
| >; | ||
| } | ||
| >; | ||
| } | ||
|
|
||
| export const isReceiptEDU = (edu: BaseEDU): edu is ReceiptEDU => { | ||
| return edu.edu_type === 'm.receipt'; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
Matrix m.receipt EDU thread_id field specification💡 Result:
In Matrix, the
thread_idfield is part of the read receipt metadata (and related receipt objects) to indicate which thread a receipt applies to.Server-server (
m.receiptEDU)In the federation
m.receiptEDU,thread_idappears under Read Receipt Metadata (data) and is defined as: a string which is the root thread event’s ID, or the literal"main", identifying which thread the receipt is intended to be under. [1]Client-server (
m.receiptephemeral event + /receipt API)In the client-server
m.receiptephemeral event content, each user’s receipt object can include: [2]thread_id(string): the root thread event’s ID or"main".The
POST /_matrix/client/v3/rooms/{roomId}/receipt/{receiptType}/{eventId}endpoint also accepts an optionalthread_idin the request body with the same meaning (root event ID or"main"; omitted = unthreaded). [2]Sources: Matrix Spec server-server receipts (
m.receiptEDU) [1], Matrix Spec client-server receipts (m.receipt) and/receiptendpoint [2].Fix
thread_idfield to be conditionally included, not always present.The code sets
thread_id: threadId || 'main'(line 92), which always includes the field. However, according to the Matrix spec,thread_idshould be omitted when the receipt is unthreaded. Omitting the field results in an unthreaded receipt (default), while settingthread_id: 'main'explicitly targets the main thread—these are distinct states. WhenthreadIdis not provided, the field should be excluded entirely rather than defaulting to'main'.🤖 Prompt for AI Agents