Skip to content

chore: migrate rooms.muteUser and rooms.unmuteUser endpoints to the new pattern#39414

Closed
mdawoud27 wants to merge 4 commits intoRocketChat:developfrom
mdawoud27:chore/migrate-rooms-muteUser-unmuteUser-to-ajv
Closed

chore: migrate rooms.muteUser and rooms.unmuteUser endpoints to the new pattern#39414
mdawoud27 wants to merge 4 commits intoRocketChat:developfrom
mdawoud27:chore/migrate-rooms-muteUser-unmuteUser-to-ajv

Conversation

@mdawoud27
Copy link
Copy Markdown
Contributor

@mdawoud27 mdawoud27 commented Mar 6, 2026

Proposed changes (including videos or screenshots)

Migrates the rooms.muteUser and rooms.unmuteUser endpoints from the legacy API.v1.addRoute pattern to the new OpenAPI-compliant format using AJV schema validation, added explicit response schemas for 200, 400, and 401 status codes, business logic unchanged

Testing

  • Run the server locally with TEST_MODE=true yarn dev

  • Then run the test commands and confirm all tests pass

    muteUser unmuteUser

Part of the ongoing REST API migration effort: RocketChat/Rocket.Chat-Open-API#150

Summary by CodeRabbit

  • Bug Fixes

    • Mute/unmute room actions return a standardized success payload ({ success: true }) and provide consistent 400/401 error responses with improved request validation.
  • Refactor

    • Mute/unmute endpoints migrated into the consolidated room endpoints collection and updated to use schema-based validation, simplifying and unifying the public API surface and routing.

@mdawoud27 mdawoud27 requested a review from a team as a code owner March 6, 2026 14:48
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Mar 6, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 6, 2026

🦋 Changeset detected

Latest commit: 5077ef8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 41 packages
Name Type
@rocket.chat/meteor Minor
@rocket.chat/rest-typings Minor
@rocket.chat/api-client Patch
@rocket.chat/core-services Patch
@rocket.chat/ddp-client Patch
@rocket.chat/http-router Patch
@rocket.chat/models Patch
@rocket.chat/ui-contexts Major
@rocket.chat/web-ui-registration Major
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/abac Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/livechat Patch
@rocket.chat/mock-providers Patch
@rocket.chat/cron Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/server-fetch Patch
@rocket.chat/ui-client Major
@rocket.chat/media-calls Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/fuselage-ui-kit Major
@rocket.chat/gazzodown Major
@rocket.chat/ui-avatar Major
@rocket.chat/ui-video-conf Major
@rocket.chat/ui-voip Major
@rocket.chat/core-typings Minor
@rocket.chat/apps Patch
@rocket.chat/model-typings Patch
@rocket.chat/license Patch
@rocket.chat/pdf-worker Patch

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 6, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Moved mute/unmute room endpoints into the roomEndpoints collection in apps/meteor/app/api/server/v1/rooms.ts, adding request schemas, types, and validators; corresponding standalone endpoint typings and types were removed from packages/rest-typings/src/v1/rooms.ts.

Changes

Cohort / File(s) Summary
API: roomEndpoints (server)
apps/meteor/app/api/server/v1/rooms.ts
Embedded POST endpoints rooms.muteUser and rooms.unmuteUser added to roomEndpoints; new RoomsMuteUnmuteUser type, RoomsMuteUnmuteUserSchema, and isRoomsMuteUnmuteUserProps validator added; action logic moved into endpoint handlers and roomEndpoints export surface updated.
REST typings removed/updated
packages/rest-typings/src/v1/rooms.ts
Removed exported RoomsMuteUnmuteUser type, its schema/validator, and the standalone '/v1/rooms.muteUser' and '/v1/rooms.unmuteUser' endpoint signatures from RoomsEndpoints typings.
Changeset
.changeset/migrate-rooms-mute-unmute-endpoints.md
Added changeset documenting the migration to OpenAPI/AJV validation and bumped relevant package versions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: migrating two specific endpoints to a new pattern, which is the primary objective of the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.

Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Copy link
Copy Markdown
Contributor

@ahmed-n-abdeltwab ahmed-n-abdeltwab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where are the remaining steps?

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/meteor/app/api/server/v1/rooms.ts`:
- Around line 1202-1258: The REST typings declare the POST handlers for
rooms.muteUser and rooms.unmuteUser as returning void, but the endpoints
actually respond with { success: true }; update the REST type signatures (the
POST: (...) => void entries) for rooms.muteUser and rooms.unmuteUser to return {
success: true } instead, and if there are corresponding ValidateFunction
generics (e.g., ValidateFunction<void>) change them to ValidateFunction<{
success: true }> so the TypeScript types match the ajv/OpenAPI response shape.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2c573842-cc55-40a1-b1c5-3f130adfc833

📥 Commits

Reviewing files that changed from the base of the PR and between 79c712b and 38c458b.

📒 Files selected for processing (1)
  • apps/meteor/app/api/server/v1/rooms.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/rooms.ts
🧠 Learnings (5)
📓 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.
📚 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/rooms.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/rooms.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/rooms.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/rooms.ts
🔇 Additional comments (1)
apps/meteor/app/api/server/v1/rooms.ts (1)

1198-1200: Return success from rooms.leave.

This keeps the handler consistent with the declared 200 response in the chained roomEndpoints definition.

Comment thread apps/meteor/app/api/server/v1/rooms.ts
@mdawoud27 mdawoud27 force-pushed the chore/migrate-rooms-muteUser-unmuteUser-to-ajv branch from 38c458b to 957b56b Compare March 6, 2026 15:07
@mdawoud27 mdawoud27 requested a review from a team as a code owner March 6, 2026 15:07
@mdawoud27
Copy link
Copy Markdown
Contributor Author

@ahmed-n-abdeltwab Do you mean swagger tests and changeset file or something else?

@ahmed-n-abdeltwab
Copy link
Copy Markdown
Contributor

@ahmed-n-abdeltwab Do you mean swagger tests and changeset file or something else?

we are getting to this later but first you need to clean the APIs from the rest-typings props, take a look at this example #36916

@mdawoud27 mdawoud27 force-pushed the chore/migrate-rooms-muteUser-unmuteUser-to-ajv branch from 957b56b to a77cc9e Compare March 6, 2026 15:37
@mdawoud27 mdawoud27 force-pushed the chore/migrate-rooms-muteUser-unmuteUser-to-ajv branch from a77cc9e to 03b6340 Compare March 6, 2026 16:45
@mdawoud27
Copy link
Copy Markdown
Contributor Author

@ahmed-n-abdeltwab take a look

Copy link
Copy Markdown
Contributor

@ahmed-n-abdeltwab ahmed-n-abdeltwab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but last thing you need to create a changeset file

@mdawoud27
Copy link
Copy Markdown
Contributor Author

@ahmed-n-abdeltwab done 🫡

Comment thread apps/meteor/app/api/server/v1/rooms.ts Outdated
@mdawoud27 mdawoud27 force-pushed the chore/migrate-rooms-muteUser-unmuteUser-to-ajv branch from b280553 to a221f30 Compare March 7, 2026 12:59
Comment thread apps/meteor/app/api/server/v1/rooms.ts Outdated
Comment on lines 1299 to 1302
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should for simplicity be replaced with type RoomEndpoints = ExtractRoutesFromAPI;. The endpoints migrated to the new pattern should be chained together. For a reference, take a look at the example in #39094

@mdawoud27
Copy link
Copy Markdown
Contributor Author

@ahmed-n-abdeltwab, Yeah, I noticed that too and it confused me a bit at first 😅
But I didn’t want to change it without confirming with you or mentor first.

Also following the rule of “if it works, don’t touch it” 😄

@ahmed-n-abdeltwab
Copy link
Copy Markdown
Contributor

@ahmed-n-abdeltwab, Yeah, I noticed that too and it confused me a bit at first 😅 But I didn’t want to change it without confirming with you or mentor first.

Also following the rule of “if it works, don’t touch it” 😄

no problem, im here for you to guide you

@mdawoud27
Copy link
Copy Markdown
Contributor Author

Thanks! I really appreciate this.

I noticed there are some failed tests, such as /rooms.delete and /rooms.membersOrderedByRole. Should I try to fix them in this PR, or open a separate PR to address the failing tests?

@ahmed-n-abdeltwab
Copy link
Copy Markdown
Contributor

Thanks! I really appreciate this.

I noticed there are some failed tests, such as /rooms.delete and /rooms.membersOrderedByRole. Should I try to fix them in this PR, or open a separate PR to address the failing tests?

Try debugging it. If the problem is with the PR APIs, then we need to address or fix it. If not, it's recommended to make the PR as concise and clean as possible. Also, so I don't forget, you should test the PR APIs locally and make sure they are green. And run eslint fix inside the Meteor folder for these files.

@mdawoud27
Copy link
Copy Markdown
Contributor Author

Now all tests pass 🙌

Screenshot From 2026-03-07 22-23-42

@mdawoud27 mdawoud27 force-pushed the chore/migrate-rooms-muteUser-unmuteUser-to-ajv branch 2 times, most recently from 1aca1e0 to a952772 Compare March 7, 2026 20:40
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you touch this file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you touch this file?

because there were failing tests especially in /rooms.delete and rooms.membersOrderedByRole

should I have avoided doing that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you touch this file?

because there were failing tests especially in /rooms.delete and rooms.membersOrderedByRole

should I have avoided doing that?

@ahmed-n-abdeltwab friendly ping

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I have avoided doing that?
yes, you should avoid editing the test file or any file unrelated to the migration

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you should avoid editing the test file or any file unrelated to the migration

Thanks for the clarification @ahmed-n-abdeltwab.
I've reverted the changes to the test file

@mdawoud27 mdawoud27 force-pushed the chore/migrate-rooms-muteUser-unmuteUser-to-ajv branch from a952772 to 9860f8a Compare March 12, 2026 11:21
@mdawoud27
Copy link
Copy Markdown
Contributor Author

@ggazzo could you please review this PR

@ggazzo
Copy link
Copy Markdown
Member

ggazzo commented Apr 17, 2026

Hey @mdawoud27, thank you for your contribution! 🙏

These endpoints have already been migrated as part of #39553, which consolidated all OpenAPI migrations to make it easier to test and validate everything as a single unit. That PR has been merged into develop, so this work is already covered. Closing this one — thanks again!

@ggazzo ggazzo closed this Apr 17, 2026
@mdawoud27 mdawoud27 deleted the chore/migrate-rooms-muteUser-unmuteUser-to-ajv branch April 17, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants