chore: migrate chat.followMessage and chat.unfollowMessage to OpenAPI#39225
Conversation
|
Looks like this PR is ready to merge! 🎉 |
🦋 Changeset detectedLatest commit: 365d625 The changes in this PR will be included in the next version bump. This PR includes changesets to release 41 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 infoConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
📜 Recent review details🧰 Additional context used📓 Path-based instructions (1)**/*.{ts,tsx,js}📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
🧠 Learnings (13)📓 Common learnings📚 Learning: 2026-02-24T19:09:01.522ZApplied to files:
📚 Learning: 2026-02-25T20:10:16.987ZApplied to files:
📚 Learning: 2026-01-17T01:51:47.764ZApplied to files:
📚 Learning: 2025-09-19T15:15:04.642ZApplied to files:
📚 Learning: 2026-02-24T19:16:35.307ZApplied to files:
📚 Learning: 2026-02-23T17:53:06.802ZApplied to files:
📚 Learning: 2026-02-24T19:36:55.089ZApplied to files:
📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
📚 Learning: 2026-02-24T19:09:09.561ZApplied to files:
📚 Learning: 2026-02-23T17:53:18.785ZApplied to files:
📚 Learning: 2026-02-24T19:05:56.710ZApplied to files:
🧬 Code graph analysis (1)apps/meteor/app/api/server/v1/chat.ts (2)
🔇 Additional comments (3)
WalkthroughMigrates chat.followMessage and chat.unfollowMessage to OpenAPI-style endpoints with locally-defined AJV validation schemas; removes their public typings from rest-typings and inlines the routes into the Meteor app's chatEndpoints with body validation and boolean success responses. (≈34 words) Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
apps/meteor/app/api/server/v1/chat.ts (2)
409-419: Redundant validation check can be removed.The
if (!mid)check at lines 412-414 is unnecessary because the AJV schema already enforcesmidas required withminLength: 1. When the handler executes,midis guaranteed to be a non-empty string; otherwise, the framework would have already returned a 400 error.♻️ Suggested simplification
async function action() { const { mid } = this.bodyParams; - - if (!mid) { - throw new Meteor.Error('The required "mid" body param is missing.'); - } - await followMessage(this.user, { mid }); return API.v1.success(); },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/meteor/app/api/server/v1/chat.ts` around lines 409 - 419, Remove the redundant runtime check for mid inside the action handler since the AJV schema already guarantees a non-empty string; specifically, delete the if (!mid) { throw new Meteor.Error(...); } block in the async function action() so the handler simply reads const { mid } = this.bodyParams; awaits followMessage(this.user, { mid }); and returns API.v1.success();.
442-452: Same redundant check as above.The
if (!mid)check at lines 445-447 is also redundant for the same reason—AJV schema validation already guaranteesmidis present and non-empty.♻️ Suggested simplification
async function action() { const { mid } = this.bodyParams; - - if (!mid) { - throw new Meteor.Error('The required "mid" body param is missing.'); - } - await unfollowMessage(this.user, { mid }); return API.v1.success(); },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/meteor/app/api/server/v1/chat.ts` around lines 442 - 452, The action function contains a redundant runtime check for mid in this.bodyParams even though AJV validation already ensures mid is present and non-empty; remove the if (!mid) throw new Meteor.Error(...) block from the action function so it simply extracts const { mid } = this.bodyParams, calls await unfollowMessage(this.user, { mid }) and returns API.v1.success(), leaving validation to AJV and keeping the function concise.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@apps/meteor/app/api/server/v1/chat.ts`:
- Around line 409-419: Remove the redundant runtime check for mid inside the
action handler since the AJV schema already guarantees a non-empty string;
specifically, delete the if (!mid) { throw new Meteor.Error(...); } block in the
async function action() so the handler simply reads const { mid } =
this.bodyParams; awaits followMessage(this.user, { mid }); and returns
API.v1.success();.
- Around line 442-452: The action function contains a redundant runtime check
for mid in this.bodyParams even though AJV validation already ensures mid is
present and non-empty; remove the if (!mid) throw new Meteor.Error(...) block
from the action function so it simply extracts const { mid } = this.bodyParams,
calls await unfollowMessage(this.user, { mid }) and returns API.v1.success(),
leaving validation to AJV and keeping the function concise.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.changeset/migrate-chat-follow-unfollow-message.mdapps/meteor/app/api/server/v1/chat.tspackages/rest-typings/src/v1/chat.ts
💤 Files with no reviewable changes (1)
- packages/rest-typings/src/v1/chat.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation
Files:
apps/meteor/app/api/server/v1/chat.ts
🧠 Learnings (12)
📓 Common learnings
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38974
File: apps/meteor/app/api/server/v1/im.ts:220-221
Timestamp: 2026-02-24T19:09:09.561Z
Learning: In RocketChat/Rocket.Chat OpenAPI migration PRs for apps/meteor/app/api/server/v1 endpoints, maintainers prefer to avoid any logic changes; style-only cleanups (like removing inline comments) may be deferred to follow-ups to keep scope tight.
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 35995
File: apps/meteor/app/api/server/v1/rooms.ts:1107-1112
Timestamp: 2026-02-23T17:53:18.785Z
Learning: In Rocket.Chat PR reviews, maintain strict scope boundaries—when a PR is focused on a specific endpoint (e.g., rooms.favorite), avoid reviewing or suggesting changes to other endpoints that were incidentally refactored (e.g., rooms.invite) unless explicitly requested by maintainers.
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38913
File: packages/ddp-client/src/legacy/types/SDKLegacy.ts:34-34
Timestamp: 2026-02-25T20:10:16.987Z
Learning: In the RocketChat/Rocket.Chat monorepo, packages/ddp-client and apps/meteor do not use TypeScript project references. Module augmentations in apps/meteor (e.g., declare module 'rocket.chat/rest-typings') are not visible when compiling packages/ddp-client in isolation, which is why legacy SDK methods that depend on OperationResult types for OpenAPI-migrated endpoints must remain commented out.
📚 Learning: 2026-02-24T19:09:09.561Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38974
File: apps/meteor/app/api/server/v1/im.ts:220-221
Timestamp: 2026-02-24T19:09:09.561Z
Learning: In RocketChat/Rocket.Chat OpenAPI migration PRs for apps/meteor/app/api/server/v1 endpoints, maintainers prefer to avoid any logic changes; style-only cleanups (like removing inline comments) may be deferred to follow-ups to keep scope tight.
Applied to files:
.changeset/migrate-chat-follow-unfollow-message.md
📚 Learning: 2026-02-25T20:10:16.987Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38913
File: packages/ddp-client/src/legacy/types/SDKLegacy.ts:34-34
Timestamp: 2026-02-25T20:10:16.987Z
Learning: In the RocketChat/Rocket.Chat monorepo, packages/ddp-client and apps/meteor do not use TypeScript project references. Module augmentations in apps/meteor (e.g., declare module 'rocket.chat/rest-typings') are not visible when compiling packages/ddp-client in isolation, which is why legacy SDK methods that depend on OperationResult types for OpenAPI-migrated endpoints must remain commented out.
Applied to files:
.changeset/migrate-chat-follow-unfollow-message.mdapps/meteor/app/api/server/v1/chat.ts
📚 Learning: 2026-02-24T19:05:56.710Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 0
File: :0-0
Timestamp: 2026-02-24T19:05:56.710Z
Learning: Rocket.Chat repo context: When a workspace manifest on develop already pins a dependency version (e.g., packages/web-ui-registration → "rocket.chat/ui-contexts": "27.0.1"), a lockfile change in a feature PR that upgrades only that dependency’s resolution is considered a manifest-driven sync and can be kept, preferably as a small "chore: sync yarn.lock with manifests" commit.
Applied to files:
.changeset/migrate-chat-follow-unfollow-message.mdapps/meteor/app/api/server/v1/chat.ts
📚 Learning: 2026-02-24T19:09:01.522Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38974
File: apps/meteor/app/api/server/v1/im.ts:220-221
Timestamp: 2026-02-24T19:09:01.522Z
Learning: In Rocket.Chat OpenAPI migration PRs for endpoints under apps/meteor/app/api/server/v1, avoid introducing logic changes. Only perform scope-tight changes that preserve behavior; style-only cleanups (e.g., removing inline comments) may be deferred to follow-ups to keep the migration PR focused.
Applied to files:
apps/meteor/app/api/server/v1/chat.ts
📚 Learning: 2026-01-17T01:51:47.764Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38219
File: packages/core-typings/src/cloud/Announcement.ts:5-6
Timestamp: 2026-01-17T01:51:47.764Z
Learning: In packages/core-typings/src/cloud/Announcement.ts, the AnnouncementSchema.createdBy field intentionally overrides IBannerSchema.createdBy (object with _id and optional username) with a string enum ['cloud', 'system'] to match existing runtime behavior. This is documented as technical debt with a FIXME comment at apps/meteor/app/cloud/server/functions/syncWorkspace/handleCommsSync.ts:53 and should not be flagged as an error until the runtime behavior is corrected.
Applied to files:
apps/meteor/app/api/server/v1/chat.ts
📚 Learning: 2025-09-19T15:15:04.642Z
Learnt from: rodrigok
Repo: RocketChat/Rocket.Chat PR: 36991
File: apps/meteor/server/services/federation/infrastructure/rocket-chat/adapters/Settings.ts:219-221
Timestamp: 2025-09-19T15:15:04.642Z
Learning: The Federation_Matrix_homeserver_domain setting in apps/meteor/server/services/federation/infrastructure/rocket-chat/adapters/Settings.ts is part of the old federation system and is being deprecated/removed, so configuration issues with this setting should not be flagged for improvement.
Applied to files:
apps/meteor/app/api/server/v1/chat.ts
📚 Learning: 2025-12-10T21:00:54.909Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:54.909Z
Learning: Rocket.Chat monorepo: Jest testMatch pattern '<rootDir>/src/**/*.spec.(ts|js|mjs)' is valid in this repo and used across multiple packages (e.g., packages/tools, ee/packages/omnichannel-services). Do not flag it as invalid in future reviews.
Applied to files:
apps/meteor/app/api/server/v1/chat.ts
📚 Learning: 2026-02-24T19:36:55.089Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/page-objects/fragments/home-content.ts:60-82
Timestamp: 2026-02-24T19:36:55.089Z
Learning: In RocketChat/Rocket.Chat e2e tests (apps/meteor/tests/e2e/page-objects/fragments/home-content.ts), thread message preview listitems do not have aria-roledescription="message", so lastThreadMessagePreview locator cannot be scoped to messageListItems (which filters for aria-roledescription="message"). It should remain scoped to page.getByRole('listitem') or mainMessageList.getByRole('listitem').
Applied to files:
apps/meteor/app/api/server/v1/chat.ts
📚 Learning: 2026-02-23T17:53:06.802Z
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 35995
File: apps/meteor/app/api/server/v1/rooms.ts:1107-1112
Timestamp: 2026-02-23T17:53:06.802Z
Learning: During PR reviews that touch endpoint files under apps/meteor/app/api/server/v1, enforce strict scope: if a PR targets a specific endpoint (e.g., rooms.favorite), do not propose changes to unrelated endpoints (e.g., rooms.invite) unless maintainers explicitly request them. Focus feedback on the touched endpoint's behavior, API surface, and related tests; avoid broad cross-endpoint changes in the same PR unless requested.
Applied to files:
apps/meteor/app/api/server/v1/chat.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.
Applied to files:
apps/meteor/app/api/server/v1/chat.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.
Applied to files:
apps/meteor/app/api/server/v1/chat.ts
🧬 Code graph analysis (1)
apps/meteor/app/api/server/v1/chat.ts (2)
apps/meteor/app/threads/server/methods/followMessage.ts (2)
followMessage(21-49)followMessage(52-61)apps/meteor/app/threads/server/methods/unfollowMessage.ts (2)
unfollowMessage(21-49)unfollowMessage(52-61)
🔇 Additional comments (3)
apps/meteor/app/api/server/v1/chat.ts (2)
60-76: LGTM!The local type and AJV schema for
ChatFollowMessageLocalare correctly defined with proper validation (requiredmidfield withminLength: 1), following the established pattern used by other local schemas in this file.
78-94: LGTM!The schema definition is correct. While
ChatFollowMessageLocalSchemaandChatUnfollowMessageLocalSchemaare identical and could be consolidated, keeping them separate aligns with maintaining a tight scope for this migration PR..changeset/migrate-chat-follow-unfollow-message.md (1)
1-6: LGTM!The changeset correctly identifies
minorversion bumps for both affected packages. The description accurately summarizes the migration to OpenAPI with AJV validation schemas.
ahmed-n-abdeltwab
left a comment
There was a problem hiding this comment.
The overall pattern looks good (LGTM), but you just need to complete the last step: testing these APIs locally.
To do so, run the server as usual but with these parameters: TEST_MODE=true yarn dev. Then, open a new terminal, navigate to the apps/meteor directory, and run the following commands:
# Test all Chat endpoints
cd apps/meteor
yarn testapi -f '[Chat]'
# Test specific endpoint
yarn testapi -f 'should create a direct message'
# Run all API tests
yarn testapiI recommend not running all API tests at once, as this can take a huge amount of time.
|
@ggazzo 👍 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #39225 +/- ##
===========================================
+ Coverage 70.72% 70.86% +0.14%
===========================================
Files 3195 3208 +13
Lines 113108 113426 +318
Branches 20479 20520 +41
===========================================
+ Hits 79991 80375 +384
+ Misses 31067 30991 -76
- Partials 2050 2060 +10
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
2f60a09 to
365d625
Compare
|
/jira ARCH-1464 |
Proposed changes (including videos or screenshots)
Migrate
chat.followMessageandchat.unfollowMessageendpoints to the new OpenAPI-compatible chained route definition syntax with AJV body and response validation.Changes
apps/meteor/app/api/server/v1/chat.tsChatFollowMessageLocalandChatUnfollowMessageLocalchat.followMessageandchat.unfollowMessagefromaddRoute()to chained.post()calls on thechatEndpointschain (afterchat.update)packages/rest-typings/src/v1/chat.tsChatFollowMessageandChatUnfollowMessagetypes, schemas, and validatorsChatEndpointsinterface.changeset/migrate-chat-follow-unfollow-message.mdminorbump for@rocket.chat/meteorand@rocket.chat/rest-typingsIssue(s)
Tracking: RocketChat/Rocket.Chat-Open-API#150
Swagger UI — chat.followMessage:

Swagger UI — chat.unfollowMessage:

Summary by CodeRabbit
Task: ARCH-2019