-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[FIX] channels.convertToTeam endpoint doesn't work when only the channelName param is provided
#26858
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
Merged
Merged
[FIX] channels.convertToTeam endpoint doesn't work when only the channelName param is provided
#26858
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
811a951
Support channelId and channelName params in channels.convertToTeam en…
matheusbsilva137 1d13bd4
Add tests
matheusbsilva137 09f0b1b
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat i…
matheusbsilva137 105444f
Fix tests
matheusbsilva137 f8997ad
Merge branch 'develop' into fix/channels-convert-to-team-types
matheusbsilva137 0bf369b
Fix findChannelByIdOrName params type
matheusbsilva137 fb24acf
Merge branch 'develop' into fix/channels-convert-to-team-types
matheusbsilva137 2133c0f
Merge branch 'develop' into fix/channels-convert-to-team-types
matheusbsilva137 d7df939
Do not allow channel's name and id both to be sent as parameters
matheusbsilva137 0f1ddd6
Merge branch 'fix/channels-convert-to-team-types' of https://github.c…
matheusbsilva137 35605b4
Fix typing issue in findChannelByIdOrName call
matheusbsilva137 1879101
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat i…
matheusbsilva137 1e14d94
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat i…
matheusbsilva137 a52871d
Fix team name already taken test
matheusbsilva137 36210b0
Remove unnecessary permission updates
matheusbsilva137 971f37c
Improve request nesting
matheusbsilva137 80fa434
Fix tests order
matheusbsilva137 aaebe90
Use async/await in new tests
matheusbsilva137 7400c8b
yarn.lock from develop
sampaiodiego ad9a658
Merge branch 'develop' into fix/channels-convert-to-team-types
sampaiodiego File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we have to do it like this?
In this particular context,
roomId in paramsis the same asparams.roomId ?(the purpose of it) - so no matter what you do in the calling function, the called still has to check for both values any way.This conditional and destructuring just seems useless at that point. And IMO is bad. We should keep the code simple. And inspire others (people who are gonna read your code) to do so too.
on the called, you can simply change the param type from the union to a simple all-partial and chain the truthness checks instead of membership checks as it was before
roomId ? .. : roomName ? ... : undefinedit's late for me, hopefully i was able to explain myself.
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.
Hey Debdut, I'll first explain what was the issue on the way we were calling this function (that is, with
params: { roomId: channelId, roomName: channelName }): this would cause one of the fields in theparamsobject to beundefined. So checking'roomId' in paramsinfindChannelByIdOrNamewould always returntrue(since this field is in the object, even though its value isundefined).Still, I see we could change the params type to
params: { roomId?: string; roomName?: string }and check forparams.roomIdinstead of'roomId' in params(is that what you mean?). If we do so, I think we should also bring back the error check we had before (so as to throw an error when both params are undefined).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.
Already done by the route function. So, you can safely ignore that part.
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.
Rocket.Chat/apps/meteor/app/api/server/v1/channels.ts
Lines 464 to 466 in aaebe90