feat: migrate sendMessage + getReadReceipts callers to REST#40675
feat: migrate sendMessage + getReadReceipts callers to REST#40675ggazzo wants to merge 1 commit into
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #40675 +/- ##
===========================================
- Coverage 69.63% 69.60% -0.04%
===========================================
Files 3338 3339 +1
Lines 123289 123303 +14
Branches 22005 21966 -39
===========================================
- Hits 85850 85821 -29
- Misses 34073 34117 +44
+ Partials 3366 3365 -1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
ba2cfe9 to
274ea6b
Compare
Two methods that resisted the URL-swap pass in the wider DDP -> REST
migration. This PR contains the deeper refactor each needed.
sendMessage
Replace sdk.call('sendMessage', message, previewUrls) with
sdk.rest.post('/v1/chat.sendMessage', { message, previewUrls }).
In the primary send flow (apps/meteor/client/lib/chats/flows/sendMessage.ts)
the response's server-rendered { message } is fed back into
Messages.state via mapMessageFromApi, replacing the optimistic temp
record in the same tick the REST call resolves. That reproduces the
Minimongo replication the DDP method triggered — composer quote
previews unmount, attachment renderers see attachments[] and urls[],
message _updatedAt advances — all without waiting for the
room-messages stream event to arrive separately.
The seven fire-and-forget callsites do not run the optimistic
reconcile and are straight URL swaps:
- apps/meteor/client/hooks/notification/useNotification.ts
- apps/meteor/client/apps/gameCenter/GameCenterInvitePlayersModal.tsx
- apps/meteor/app/slashcommand-asciiarts/client/{lenny,tableflip,unflip,gimme,shrug}.ts
getReadReceipts
Replace useMethod('getReadReceipts') with
useEndpoint('GET', '/v1/chat.getMessageReadReceipts') in
ReadReceiptsModal. Add rid prop and subscribe to
notify-room/<rid>/messagesRead; on event, invalidate the
['read-receipts', messageId] query so the dialog re-fetches when new
receipts land. mapReadReceiptFromApi revives the Date fields the
REST endpoint serializes as strings.
Server-side: ReadReceipt.markMessagesAsRead /
ReadReceipt.markMessageAsReadBySender /
ReadReceipt.storeThreadMessagesReadReceipts no longer fire-and-forget
the storeReadReceipts insertion — they await it. Closes the
read-after-write race the omnichannel-livechat-read-receipts e2e test
exposed: a fast REST GET could observe a partial set of receipts
because the visitor's self-receipt insert was still in flight when the
test opened the Read-Receipts dialog.
274ea6b to
a8c6aa9
Compare
Summary
The two DDP methods that were reverted from #40659 because their client plumbing depends on DDP-specific semantics. This PR contains the deeper refactor each needed.
sendMessagesdk.call('sendMessage', message, previewUrls)→sdk.rest.post('/v1/chat.sendMessage', { message, previewUrls }).apps/meteor/client/lib/chats/flows/sendMessage.ts) feeds the server-rendered{ message }back intoMessages.stateviamapMessageFromApi, replacing the optimistic temp record in the same tick the REST call resolves. Reproduces the Minimongo replication the DDP method triggered.apps/meteor/client/hooks/notification/useNotification.ts(desktop notification reply)apps/meteor/client/apps/gameCenter/GameCenterInvitePlayersModal.tsxgetReadReceiptsuseMethod('getReadReceipts')→useEndpoint('GET', '/v1/chat.getMessageReadReceipts')inReadReceiptsModal.ridprop and subscribes tonotify-room/<rid>/messagesRead; on event, invalidates the['read-receipts', messageId]react-query so the dialog refetches when new receipts land.mapReadReceiptFromApihelper revives theDatefields the REST endpoint serializes as strings.Server-side race fix
ReadReceipt.markMessagesAsRead,markMessageAsReadBySenderandstoreThreadMessagesReadReceiptsno longer fire-and-forget the innerstoreReadReceipts(...)call — theyawaitit. Closes the read-after-write race that theomnichannel-livechat-read-receiptse2e exposed.Test plan