fix: convert mailer endpoint to new pattern#35712
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 |
|
|
Hi! This PR updates the mailer endpoint to the new pattern. Kindly review when possible. Thanks a lot! |
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
…/Rocket.Chat into rishitha-mailer-fix
cardoso
left a comment
There was a problem hiding this comment.
@rishitha4303 please keep your changes confined to apps/meteor/app/api/server/v1/mailer.ts.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #35712 +/- ##
========================================
Coverage 61.16% 61.16%
========================================
Files 3003 3003
Lines 71350 71350
Branches 16333 16333
========================================
Hits 43638 43638
- Misses 24745 24746 +1
+ Partials 2967 2966 -1
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
@kody updated the response schema as suggested. Can you re-check? |
|
@rishitha4303 please format the |
|
|
||
| import Ajv from 'ajv'; | ||
| import { API } from '../api'; | ||
| import { sendMail } from '../../../mail-messages/server/functions/sendMail'; | ||
| import { Mailer } from '../../../mail-messages/server/lib/Mailer'; | ||
| import { API } from '../api'; |
There was a problem hiding this comment.
The import order of API here is an unneeded change. Please install the eslint vscode extension and fix the lint issues: https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
There was a problem hiding this comment.
I installed the ESLint VSCode extension and checked the mailer.ts file. After running it, linting issues were found.
but it seems there are some other linting issues preventing to next step, they might be in other files. I'm currently checking the rest
This PR updates the /mailer endpoint to use the modern API.v1.post() structure instead of the deprecated API.v1.addRoute().
Changes include:
2.Added ajv response validation schema
4.Ensured permissions and parameter validation remain intact
Tested:
Verified functionality locally after changes
Confirmed schema validation works as expected
Endpoint returns expected response format ({ success: true })
💬 GSoC Context:
This change contributes to my GSoC proposal by helping modernize Rocket.Chat’s API routes for maintainability and consistency.
This pull request refactors the
/mailerand/mailer.unsubscribeAPI endpoints in theapps/meteor/app/api/server/v1/mailer.tsfile to adopt the newerAPI.v1.postmethod, replacing the olderAPI.v1.addRoute. It also introduces explicit response validation usingajvfor both endpoints and includes temporary debugging logs. Additionally, a newtsconfig-esm.jsonfile is added to thepackages/fuselage-ui-kitdirectory.