-
Notifications
You must be signed in to change notification settings - Fork 13.8k
chore: migrate sendMessage + getReadReceipts callers to REST #40675
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
16 commits
Select commit
Hold shift + click to select a range
f86f726
feat: migrate sendMessage + getReadReceipts callers from DDP to REST
ggazzo c2301b1
fix: decrypt server response in E2EE rooms after REST sendMessage
ggazzo 3b92798
fix: stop clobbering messages stream updates after REST sendMessage
ggazzo 18c8117
chore: deprecate sendMessage and getReadReceipts DDP methods
ggazzo 6a5922a
fix(client): dismiss quoted messages optimistically on send
ggazzo 6ea3264
fix(api): disambiguate file attachment branch in MessageAttachment sc…
ggazzo ce82873
fix(lint): order deprecationWarningLogger import before canAccessRoom…
ggazzo 4251a87
fix(client): clear credentials on REST 401 so expired sessions redire…
ggazzo bb4fe00
fix(api): correct getReadReceipts deprecationLogger path after develo…
ggazzo a66a571
chore: fix import order and prettier formatting
ggazzo febd98d
chore: deprecate getThreadMessages DDP method
ggazzo da46336
fix(client): only clear credentials when the 401 came from the curren…
ggazzo 6e1b3a9
fix(client): confirm a dead session with /v1/me before clearing crede…
ggazzo 6a26bc5
revert: drop the REST 401 credential wipe
ggazzo e0d5425
fix(client): clear credentials on a 401 from a mutation, not from boo…
ggazzo 8b884b3
fix(client): await the game-center invite message and stabilize the r…
ggazzo 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
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
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 |
|---|---|---|
|
|
@@ -47,9 +47,13 @@ const process = async (chat: ChatAPI, message: IMessage, previewUrls?: string[], | |
|
|
||
| chat.composer?.clear(); | ||
| await runOptimisticSendMessage(message); | ||
| await sdk.call('sendMessage', message, previewUrls); | ||
|
|
||
| // after the request is complete we can go ahead and mark as sent | ||
| await sdk.rest.post('/v1/chat.sendMessage', { message, previewUrls }); | ||
|
|
||
| // Clear the optimistic `temp` flag only if the messages stream hasn't already | ||
| // replaced the record. Overwriting with the server response can clobber stream | ||
| // updates that arrive first — e.g. read-receipt-driven `unread: false`, async | ||
| // URL/quote attachments, or E2EE decrypt — leading to stale UI state. | ||
|
Comment on lines
+53
to
+56
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Remove the added implementation comments.
As per coding guidelines, “Avoid code comments in the implementation.” 📍 Affects 2 files
🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| Messages.state.update( | ||
| (record) => record._id === message._id && record.temp === true, | ||
| ({ temp: _, ...record }) => record, | ||
|
|
@@ -107,8 +111,13 @@ export const sendMessage = async ( | |
| } | ||
|
|
||
| try { | ||
| await process(chat, message, previewUrls, isSlashCommandAllowed); | ||
| // Dismiss quoted messages optimistically — they are already baked into | ||
| // `message` by composeMessage above, so the composer preview must unmount | ||
| // regardless of whether the send request resolves. Keeping it coupled to a | ||
| // resolved request leaves the quote stuck in the composer when the REST call | ||
| // rejects even though the message was already broadcast over the stream. | ||
| chat.composer?.dismissAllQuotedMessages(); | ||
| await process(chat, message, previewUrls, isSlashCommandAllowed); | ||
| await afterSendMessageCallback(message, message.rid); | ||
| } catch (error) { | ||
| dispatchToastMessage({ type: 'error', message: error }); | ||
|
|
||
32 changes: 24 additions & 8 deletions
32
apps/meteor/client/views/room/modals/ReadReceiptsModal/ReadReceiptsModal.tsx
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
Oops, something went wrong.
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.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Include
PATCHin mutation credential handling.A 401 from a PATCH mutation will not clear stale credentials, unlike the other write methods.
📝 Committable suggestion
🤖 Prompt for AI Agents