-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[NEW] REST API endpoint channels.setDefault
#10941
[NEW] REST API endpoint channels.setDefault
#10941
Conversation
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.
I know we're almost never providing localization keys for errors, but I really think we should start doing it for every new API
Localization will only start working after this PR is merged: #10818
const findResult = findChannelByIdOrName({ params: this.requestParams() }); | ||
|
||
if (findResult.default === this.bodyParams.default) { | ||
return RocketChat.API.v1.failure('The channel default setting is the same as what it would be changed to.'); |
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.
Missing localization key here
return RocketChat.API.v1.failure('The channel default setting is the same as what it would be changed to.', 'error-channels-setdefault-is-same');
RocketChat.API.v1.addRoute('channels.setDefault', { authRequired: true }, { | ||
post() { | ||
if (typeof this.bodyParams.default === 'undefined') { | ||
return RocketChat.API.v1.failure('The bodyParam "default" is required'); |
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.
Missing localization key here
return RocketChat.API.v1.failure('The bodyParam "default" is required', 'error-channels-setdefault-missing-default-param');
@cardoso The localization keys for this are located in the same file as all others, right? |
@cardoso That should do it~ |
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.
Thanks @vynmera 👍
channels.setDefault
@vynmera Will this work when calling channels.create? Currently it takes: Will it now take {"default": true} ? |
Closes #10939.
This PR adds a simple new REST API route
channels.setDefault
to set a channel as default. It behaves the same aschannels.setReadOnly
:POST /api/v1/channels.setDefault (requires auth)
{ "roomId": "YOUR_ROOM_ID", "default": true }
A docs PR is on the way.