feat(chat): add room-type-agnostic chat.history endpoint#40981
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 |
🦋 Changeset detectedLatest commit: 992cb21 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
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 |
c2546e8 to
6247a46
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #40981 +/- ##
========================================
Coverage 70.08% 70.08%
========================================
Files 3357 3357
Lines 129543 129534 -9
Branches 22474 22475 +1
========================================
+ Hits 90787 90790 +3
+ Misses 35456 35442 -14
- Partials 3300 3302 +2
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Add a new `GET /v1/chat.history` REST endpoint that returns a room's
message history by `roomId` regardless of room type (channel, private
group or DM), mirroring the behavior of `channels.history`,
`groups.history` and `im.history` without requiring the caller to know
the room type beforehand.
It reuses `getChannelHistory`, which resolves access via
`Authorization.canReadRoom`, so the same `{ rid, ts }`-indexed range
query is used for any room. This provides a performant REST replacement
for the deprecated `loadMissedMessages` DDP method, whose deprecation
notice now points to `/v1/chat.history`.
Replace the `chat.syncMessages` REST call in the reconnect hook with the new `GET /v1/chat.history` endpoint. On reconnection the hook now fetches only messages created after the newest loaded message's timestamp (`ts`) via a single indexed range query, instead of scanning `_updatedAt` plus the trash collection.
6247a46 to
daa2272
Compare
chat.history replaces the deprecated loadMissedMessages DDP method only. The reconnect hook must keep chat.syncMessages so it still reconciles edits and deletions made while offline.
Proposed changes
Adds a new
GET /api/v1/chat.historyREST endpoint that returns a room's message history byroomIdregardless of room type (channel, private group or DM), and switches the reconnect hook to use it.Today, fetching message history over REST requires the caller to know the room type and hit the matching endpoint (
channels.history,groups.history,im.history). This endpoint removes that requirement: it accepts onlyroomIdand resolves access throughAuthorization.canReadRoom, just like the underlyinggetChannelHistory.Why
It is a performant REST replacement for the deprecated
loadMissedMessagesDDP method:{ rid, ts }-indexed range query (ts > oldest) — a single, efficient range scan.chat.syncMessages(which queries_updatedAt+ the trash collection to reconcile edits/reactions/deletions),chat.historyreturns only messages by creation time.The
loadMissedMessagesdeprecation notice now points to/v1/chat.history.Usage
Params:
roomId(required),latest,oldest,inclusive,count,offset,unreads,showThreadMessages.How to test
chat.historyreturns the history of a channel and a private group via the same endpoint (room-type agnostic).oldestfilters to messages created after the timestamp.countlimits the page size.roomId-> 400; inaccessible room -> 403.E2E tests added under
[/chat.history]inapps/meteor/tests/end-to-end/api/chat.ts.