Skip to content
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

Merged
merged 18 commits into from
Jun 20, 2018

Conversation

vynmera
Copy link
Contributor

@vynmera vynmera commented May 29, 2018

Closes #10939.

This PR adds a simple new REST API route channels.setDefault to set a channel as default. It behaves the same as channels.setReadOnly:

POST /api/v1/channels.setDefault (requires auth)
{ "roomId": "YOUR_ROOM_ID", "default": true }

A docs PR is on the way.

Copy link
Contributor

@cardoso cardoso left a 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.');
Copy link
Contributor

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');
Copy link
Contributor

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');

@vynmera
Copy link
Contributor Author

vynmera commented May 30, 2018

@cardoso The localization keys for this are located in the same file as all others, right?
Looking at failure(), this code should already compile pre-10818, so I'll make the changes already when I have the time if that's OK

@vynmera
Copy link
Contributor Author

vynmera commented May 30, 2018

@cardoso That should do it~

Copy link
Contributor

@cardoso cardoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @vynmera 👍

@rodrigok rodrigok changed the title [NEW] REST API: channels.setDefault [NEW] REST API endpoint channels.setDefault Jun 20, 2018
@rodrigok rodrigok merged commit 5f9ec71 into RocketChat:develop Jun 20, 2018
@ear-dev
Copy link
Contributor

ear-dev commented Jun 21, 2018

@vynmera Will this work when calling channels.create? Currently it takes:
{"name": "<>", "readOnly": "<> }

Will it now take {"default": true} ?

@rodrigok rodrigok mentioned this pull request Jun 28, 2018
@vynmera vynmera deleted the rest-set-default-channels branch July 3, 2018 18:47
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.

6 participants