Thanks to visit codestin.com
Credit goes to github.com

Skip to content

chore: migrate mailer and mailer.unsubscribe to OpenAPI#39267

Open
amitb0ra wants to merge 2 commits intoRocketChat:developfrom
amitb0ra:feat/migrate-mailer-openapi
Open

chore: migrate mailer and mailer.unsubscribe to OpenAPI#39267
amitb0ra wants to merge 2 commits intoRocketChat:developfrom
amitb0ra:feat/migrate-mailer-openapi

Conversation

@amitb0ra
Copy link

@amitb0ra amitb0ra commented Mar 3, 2026

Proposed changes (including videos or screenshots)

Migrate mailer and mailer.unsubscribe endpoints to the new OpenAPI-compatible chained route definition syntax with AJV body and response validation.

Changes

apps/meteor/app/api/server/v1/mailer.ts

  • Defined local types and AJV schemas for MailerLocal and MailerUnsubscribeLocal
  • Migrated both endpoints from addRoute() to chained .post() calls
  • Added response validation schemas (200, 400, 401)
  • Added ExtractRoutesFromAPI and declare module augmentation
  • Preserved permissionsRequired: ['send-mail'] for mailer endpoint
  • Preserved rateLimiterOptions for mailer.unsubscribe endpoint

packages/rest-typings/src/v1/mailer.ts — Deleted (all endpoints migrated)
packages/rest-typings/src/v1/mailer/MailerParamsPOST.ts — Deleted (all endpoints migrated)
packages/rest-typings/src/v1/mailer/MailerUnsubscribeParamsPOST.ts — Deleted (all endpoints migrated)

packages/rest-typings/src/index.ts

  • Removed MailerEndpoints import and entry from Endpoints interface
  • Removed re-exports for deleted files

.changeset/migrate-mailer-unsubscribe.md

  • Added changeset with minor bump for @rocket.chat/meteor and @rocket.chat/rest-typings

Issue(s)

Tracking: RocketChat/Rocket.Chat-Open-API#150

Screenshots

mailer
image

mailer.unsubscribe
image

image

Summary by CodeRabbit

  • Refactor
    • Updated mailer and unsubscribe API endpoints with improved request validation and OpenAPI 3.0.3 documentation schemas. Enhanced error response handling for better API reliability.

amitb0ra added 2 commits March 1, 2026 05:32
…ation

- Migrated mailer and mailer.unsubscribe POST endpoints from addRoute to chainable .post() pattern
- Added inline AJV response schemas (200/400/401/403) for OpenAPI 3.0.3 doc generation
- Moved type definitions and validators from rest-typings into handler file
- Removed packages/rest-typings/src/v1/mailer.ts and mailer/ directory
- Updated packages/rest-typings/src/index.ts to remove old imports and re-exports
- Uses ExtractRoutesFromAPI + module augmentation for type extraction
@amitb0ra amitb0ra requested review from a team as code owners March 3, 2026 01:51
@dionisio-bot
Copy link
Contributor

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

changeset-bot bot commented Mar 3, 2026

🦋 Changeset detected

Latest commit: 9473b97

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 Patch
@rocket.chat/rest-typings Patch
@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 Patch
@rocket.chat/web-ui-registration Patch
@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 Patch
@rocket.chat/media-calls Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/core-typings Patch
@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
Contributor

coderabbitai bot commented Mar 3, 2026

Walkthrough

This pull request migrates mailer API endpoints from a deprecated addRoute pattern to a chainable .post() pattern with inline AJV response schemas for OpenAPI 3.0.3 documentation. Validators and type definitions are relocated from the shared rest-typings package into the meteor app's implementation, while the rest-typings package removes related exports.

Changes

Cohort / File(s) Summary
Changeset metadata
.changeset/migrate-mailer-openapi.md
Documents the migration of mailer endpoints from deprecated pattern to chainable .post() with inline AJV response schemas and patch version updates.
Mailer endpoint implementation
apps/meteor/app/api/server/v1/mailer.ts
Introduces AJV-based validators (isMailerProps, isMailerUnsubscribeProps), replaces addRoute calls with chainable .post() endpoints, adds comprehensive response schemas (200, 400, 401, 403 status codes), and exports new endpoint type via module declaration merging.
Rest-typings cleanup
packages/rest-typings/src/index.ts, packages/rest-typings/src/v1/mailer.ts, packages/rest-typings/src/v1/mailer/MailerParamsPOST.ts, packages/rest-typings/src/v1/mailer/MailerUnsubscribeParamsPOST.ts
Removes mailer-related type exports and validators from the public API surface, eliminating MailerEndpoints, MailerProps, MailerUnsubscribeProps, and associated validators.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

type: chore

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore: migrate mailer and mailer.unsubscribe to OpenAPI' clearly and specifically summarizes the main change: migrating two mailer-related endpoints to use OpenAPI-compatible patterns.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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
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 6 files

Copy link
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

🧹 Nitpick comments (1)
apps/meteor/app/api/server/v1/mailer.ts (1)

109-109: Avoid inline lint-disable comments in implementation code.

Prefer a config-level override (or shared declaration-file convention) for this augmentation pattern instead of inline suppression comments.

As per coding guidelines: "Avoid code comments in the implementation".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/app/api/server/v1/mailer.ts` at line 109, Remove the inline
eslint-disable comment in apps/meteor/app/api/server/v1/mailer.ts and instead
handle the augmentation exception at configuration or declaration-file level:
either add a targeted override in the shared ESLint config (.eslintrc) to allow
`@typescript-eslint/naming-convention` and `@typescript-eslint/no-empty-interface`
for declaration/augmentation files, or move the augmentation into a shared .d.ts
declaration file (e.g., types/global.d.ts) where you can document and scope the
exception without inline suppression; update references to the augmentation so
the file no longer contains the inline "eslint-disable-next-line" comment.
🤖 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/mailer.ts`:
- Around line 27-28: The OpenAPI change added nullable: true to the request
schema fields dryrun and query which expands the contract to accept explicit
nulls; revert those schema entries in the mailer.ts request/body definition so
dryrun and query remain optional but not nullable (remove the nullable: true key
for the dryrun and query properties in the schema object), ensuring validation
semantics for dryrun and query are preserved.

---

Nitpick comments:
In `@apps/meteor/app/api/server/v1/mailer.ts`:
- Line 109: Remove the inline eslint-disable comment in
apps/meteor/app/api/server/v1/mailer.ts and instead handle the augmentation
exception at configuration or declaration-file level: either add a targeted
override in the shared ESLint config (.eslintrc) to allow
`@typescript-eslint/naming-convention` and `@typescript-eslint/no-empty-interface`
for declaration/augmentation files, or move the augmentation into a shared .d.ts
declaration file (e.g., types/global.d.ts) where you can document and scope the
exception without inline suppression; update references to the augmentation so
the file no longer contains the inline "eslint-disable-next-line" comment.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2c23512 and 9473b97.

📒 Files selected for processing (6)
  • .changeset/migrate-mailer-openapi.md
  • apps/meteor/app/api/server/v1/mailer.ts
  • packages/rest-typings/src/index.ts
  • packages/rest-typings/src/v1/mailer.ts
  • packages/rest-typings/src/v1/mailer/MailerParamsPOST.ts
  • packages/rest-typings/src/v1/mailer/MailerUnsubscribeParamsPOST.ts
💤 Files with no reviewable changes (4)
  • packages/rest-typings/src/index.ts
  • packages/rest-typings/src/v1/mailer.ts
  • packages/rest-typings/src/v1/mailer/MailerUnsubscribeParamsPOST.ts
  • packages/rest-typings/src/v1/mailer/MailerParamsPOST.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/mailer.ts
🧠 Learnings (8)
📓 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.
📚 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-mailer-openapi.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-mailer-openapi.md
  • apps/meteor/app/api/server/v1/mailer.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-mailer-openapi.md
📚 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/mailer.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/mailer.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/mailer.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/mailer.ts
🧬 Code graph analysis (1)
apps/meteor/app/api/server/v1/mailer.ts (3)
apps/meteor/app/mail-messages/server/functions/sendMail.ts (1)
  • sendMail (13-101)
apps/meteor/app/api/server/ApiClass.ts (1)
  • ExtractRoutesFromAPI (74-78)
packages/rest-typings/src/index.ts (1)
  • Endpoints (47-91)
🔇 Additional comments (3)
apps/meteor/app/api/server/v1/mailer.ts (2)

49-104: Route migration preserves the important guards and behavior.

Auth requirements, send-mail permission, rate limiting, and handler flow are retained while adding explicit response schemas.


106-111: Module augmentation is safe for isolated package compilation.

Verification confirms no active legacy SDK typing depends on the migrated mailer endpoints. The module augmentation in apps/meteor will not cause typing issues when packages/ddp-client compiles in isolation, as no legacy SDK methods reference these endpoints.

.changeset/migrate-mailer-openapi.md (1)

2-3: The review comment is based on an incorrect premise.

Mailer types were never exported from @rocket.chat/rest-typings. The changeset describes a refactoring of endpoint implementation within apps/meteor (migrating from addRoute to the chainable .post() pattern), not a removal of public types from rest-typings. Since the rest-typings public API surface is unchanged, the patch level is appropriate.

Likely an incorrect or invalid review comment.

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.

1 participant