-
Notifications
You must be signed in to change notification settings - Fork 13.3k
chore: migrate rooms.hide and rooms.open to OpenAPI-compliant pattern #39072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
7144ed7
7a9f808
eefea4e
4b3767f
5fc1d43
00bcd97
c260039
651dd01
5f70334
16a23c5
9fa1c10
96c0f83
e05c7cb
7591ff7
a025ef0
7aa1adc
4277e92
4150fad
eb263ba
f4a4021
cb7d370
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| '@rocket.chat/meteor': minor | ||
| '@rocket.chat/rest-typings': minor | ||
| --- | ||
|
|
||
| Migrated `rooms.hide` and `rooms.open` endpoints to new OpenAPI-compliant pattern with AJV validation and response schemas. | ||
|
|
||
| Tracking PR: https://github.com/RocketChat/Rocket.Chat-Open-API/pull/150 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4215,6 +4215,7 @@ describe('[Rooms]', () => { | |
| it('should return 401 if user is not logged in', async () => { | ||
| await request | ||
| .post(api('rooms.hide')) | ||
| .send({ roomId: roomA._id }) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test was sending a request with no body and no credentials, which caused AJV validation to run first and return 400 (missing roomId) before the auth middleware could return 401. Adding .send({ roomId: roomA._id }) ensures the request body is valid so that authentication is the only failing condition, making the test correctly assert the 401 behavior.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
make sense |
||
| .expect('Content-Type', 'application/json') | ||
| .expect(401) | ||
| .expect((res) => { | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you forget to remove RoomsOpenProps and RoomsHideProps from rest-typings and move them into the corresponding API file apps/meteor/app/api/server/v1/rooms.ts
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just seeing this now, I've immediately done this and pushed |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in projection option:
projectionsshould beprojection.MongoDB/Mongoose uses
projection(singular) as the option name. This typo will cause the projection to be ignored, returning the full user document instead of just{ _id: 1 }.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isnt this outoff the scoop for this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Length of output: 59
🏁 Script executed:
Length of output: 408
🏁 Script executed:
Length of output: 354
@ahmed-n-abdeltwabYou're absolutely right—this is out of scope for this migration PR.I checked the original implementation on the
developbranch, and theprojectionstypo already existed in the old code. Since this PR is focused on migrating to the OpenAPI pattern while preserving existing behavior, fixing the typo would constitute a logic change (the current code returns the full user document, fixing it would return only_id).Per the migration guidelines, this PR should maintain behavioral parity with the original implementation, even if that includes pre-existing bugs. The typo should be addressed in a separate bug-fix PR.
My apologies for flagging this during a migration-focused review. Would you like me to open a follow-up issue to track fixing this typo across the codebase?
🧠 Learnings used