feat: chat.getMessageByFileId endpoint - #41939
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: 69b6688 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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📜 Recent review details⏰ Context from checks skipped due to timeout. (5)
🔇 Additional comments (1)
WalkthroughChangesFile-Based Message Lookup
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This change adds a scoped endpoint for retrieving a message by file ID with documented access and error behavior; no actionable merge-blocking risk remains beyond normal checks and review. Sequence Diagram(s)sequenceDiagram
participant Client
participant chat.getMessageByFileId
participant Messages
participant Rooms
Client->>chat.getMessageByFileId: Request with fileId
chat.getMessageByFileId->>Messages: Find message by fileId
Messages-->>chat.getMessageByFileId: Message and room reference
chat.getMessageByFileId->>Rooms: Check requester access
Rooms-->>chat.getMessageByFileId: Access result
chat.getMessageByFileId-->>Client: Normalized message or error response
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Warning Errors were encountered while retrieving linked issues. Errors (1)
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 |
|
@CodeRabbit review |
|
|
✅ Action performedReview finished.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #41939 +/- ##
===========================================
- Coverage 69.35% 69.31% -0.04%
===========================================
Files 4254 4254
Lines 168675 168682 +7
Branches 30046 30105 +59
===========================================
- Hits 116977 116929 -48
- Misses 46525 46581 +56
+ Partials 5173 5172 -1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Adds GET /v1/chat.getMessageByFileId, which returns the message a file was sent in, given the file id.
Uploads don't store a reference to their message — the link only exists in the other direction (message.file._id /
message.files[]._id), so there was no way for a client holding a file id to reach its message. The endpoint resolves it
server-side using the existing Messages.getMessageByFileId, the same lookup chat.delete already uses when it receives a fileId.
GET /v1/chat.getMessageByFileId?fileId=
Returns 404 when no message references the file and 403 when the caller can't access the message's room (canAccessRoomIdAsync,
the same check chat.getMessage uses). The message goes through normalizeMessagesForUser before being returned, so the payload
matches chat.getMessage.
Covered by end-to-end API tests in apps/meteor/tests/end-to-end/api/chat.ts: happy path, missing/empty fileId, unknown file, no
room access, and unauthenticated.
Proposed changes (including videos or screenshots)
Issue(s)
https://rocketchat.atlassian.net/browse/SUP-1106
Steps to test or reproduce
Further comments
Summary by CodeRabbit
New Features
Tests