Skip to content

chore: Add OpenAPI support to chat.delete and chat.react endpoints#39220

Closed
sezallagwal wants to merge 6 commits intoRocketChat:developfrom
sezallagwal:chore/openapi-chat-delete-react
Closed

chore: Add OpenAPI support to chat.delete and chat.react endpoints#39220
sezallagwal wants to merge 6 commits intoRocketChat:developfrom
sezallagwal:chore/openapi-chat-delete-react

Conversation

@sezallagwal
Copy link
Copy Markdown
Contributor

@sezallagwal sezallagwal commented Mar 1, 2026

Proposed Changes

This PR integrates OpenAPI support into the Rocket.Chat API, migrating chat.delete and chat.react endpoints to the new OpenAPI pattern. The update includes improved API documentation, enhanced type safety, and response validation using AJV.

Key Changes:

  • Implemented the new pattern and added AJV-based JSON schema validation for the APIs
  • Used the ExtractRoutesFromAPI utility from the TypeScript definitions to dynamically derive routes from the endpoint specifications
  • Enabled Swagger UI integration for these APIs
  • Applied route method chaining for the endpoints
  • This does not introduce any breaking changes to the endpoint logic

Tracked in: RocketChat/Rocket.Chat-Open-API#150


Testing

  • Verified that the API response schemas are correctly documented in Swagger UI
  • Confirmed that sending an empty request body returns a 400 validation error
  • All tests passed without any breaking changes

Endpoints

  • Delete a chat message
    POST /api/v1/chat.delete

  • Send a reaction
    POST /api/v1/chat.react


Steps to Test or Reproduce

  1. Run the server locally with:
    yarn dsv
  2. Navigate to:
    http://localhost:3000/api-docs/
    
  3. Authorize using X-Auth-Token and X-User-Id
  4. Find POST /api/v1/chat.delete and execute with:
    { "msgId": "<id>", "roomId": "<rid>" }
  5. Find POST /api/v1/chat.react and execute with:
    { "emoji": ":thumbsup:", "messageId": "<id>" }
  6. Execute with an empty body:
    {}
    This should return a 400 validation error.

Swagger UI — chat.delete:
image

Swagger UI — chat.react:
image

Summary by CodeRabbit

  • New Features

    • Added public chat endpoints: ignore user and search messages.
  • Refactor

    • Moved message delete and react handling to local/internal route variants with consolidated validation and responses.
  • Notes

    • Public delete/react endpoints were removed from the public API; other chat behaviors remain unchanged.

@sezallagwal sezallagwal requested review from a team as code owners March 1, 2026 13:37
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot bot commented Mar 1, 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 1, 2026

🦋 Changeset detected

Latest commit: 9faecc6

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 1, 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

Moves global chat.delete and chat.react registrations into local API.v1.chat chained endpoints with AJV request/response validation; removes those public REST typings and adds chat.ignoreUser and chat.search endpoints in rest-typings; adds a changeset recording the migration and dependency minor bumps.

Changes

Cohort / File(s) Summary
Changeset
\.changeset/migrate-chat-delete-react.md
Adds changeset describing migration to chained route syntax and AJV validation; records minor dependency bumps for @rocket.chat/meteor and @rocket.chat/rest-typings.
API implementation
apps/meteor/app/api/server/v1/chat.ts
Removes global chat.delete/chat.react route registrations; adds local API.v1.chat.delete and API.v1.chat.react chained endpoints, new local request types (ChatDeleteLocal, ChatReactLocal), AJV schemas/validators (ChatDeleteLocalSchema, ChatReactLocalSchema, isChatDeleteLocalProps, isChatReactLocalProps), and per-endpoint response schemas. Core permission and business logic retained but routing and validation reorganized.
Public typings
packages/rest-typings/src/v1/chat.ts
Removes public /v1/chat.delete and /v1/chat.react endpoint types/schemas and their validators; adjusts ChatEndpoints accordingly and retains/clarifies chat.ignoreUser and chat.search GET endpoints and types.

Sequence Diagram(s)

sequenceDiagram
  rect rgba(240,240,255,0.5)
    participant Client
    participant API as API.v1.chat
    participant Validator
    participant Auth as PermissionCheck
    participant DB as MessagesDB
  end

  Client->>API: POST /v1/chat.delete { msgId, roomId, ... }
  API->>Validator: validate request (AJV)
  Validator-->>API: validated params
  API->>Auth: check permissions (user, room)
  Auth-->>API: allowed / denied
  API->>DB: fetch message by msgId
  DB-->>API: message
  API->>DB: perform delete operation
  DB-->>API: result
  API-->>Client: 200 { _id, ts, message: {...} } or 4xx
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 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 accurately summarizes the main change: adding OpenAPI support to the chat.delete and chat.react endpoints. The change scope aligns with the changeset modifications across all affected files.
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.


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.

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.

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/rest-typings/src/v1/chat.ts">

<violation number="1" location="packages/rest-typings/src/v1/chat.ts:1005">
P2: `/v1/chat.delete` was removed from `ChatEndpoints`, but the endpoint is still used in app code and `Endpoints` still depends on `ChatEndpoints`, so type coverage for this REST route is dropped.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@sezallagwal
Copy link
Copy Markdown
Contributor Author

Fixed in the latest commit — retained /v1/chat.delete in ChatEndpoints for client-side type coverage. @cubic-dev-ai

@ahmed-n-abdeltwab
Copy link
Copy Markdown
Contributor

Thanks for providing the screenshots! also Once you solve these issues, this PR will be ready

@sezallagwal
Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai re-run

@cubic-dev-ai
Copy link
Copy Markdown
Contributor

cubic-dev-ai bot commented Mar 1, 2026

@cubic-dev-ai re-run

@sezallagwal I have started the AI code review. It will take a few minutes to complete.

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 3 files

@sezallagwal
Copy link
Copy Markdown
Contributor Author

I have resolved the issues. Please have a look @ahmed-n-abdeltwab

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.

please take a look at these issues

@sezallagwal
Copy link
Copy Markdown
Contributor Author

Thanks for the detailed review, @ahmed-n-abdeltwab! I missed the individual thread comments before, but they’re all fixed in the latest commit.

@sezallagwal sezallagwal force-pushed the chore/openapi-chat-delete-react branch from 9547f23 to 692dbfd Compare March 3, 2026 13:44
@sezallagwal sezallagwal force-pushed the chore/openapi-chat-delete-react branch from 692dbfd to cc3eb9d Compare March 3, 2026 13:52
@sezallagwal
Copy link
Copy Markdown
Contributor Author

@ahmed-n-abdeltwab I’ve resolved the merge conflicts and verified everything locally using yarn testapi -f '[Chat]'.
Could you please review it when you get a chance?

image

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.

could you take a look at these

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

@ahmed-n-abdeltwab
Copy link
Copy Markdown
Contributor

@ggazzo 👍

@ggazzo
Copy link
Copy Markdown
Member

ggazzo commented Mar 23, 2026

Hey, thanks for the contribution! 🙏

I'm closing this PR because the endpoint(s) covered here have already been migrated as part of a larger batch migration I'm working on (see #39820). I decided to go with a mass migration approach because reviewing individual PRs for each endpoint was taking too much of my time.

That said, you're more than welcome to help by reviewing and testing the changes in #39820 to make sure everything is working correctly. Your input would be really valuable!

Thanks again for your effort! 🚀

@ggazzo ggazzo closed this Mar 23, 2026
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