rocketchat-ruby icon indicating copy to clipboard operation
rocketchat-ruby copied to clipboard

feat: Channel and Group #kick APIs

Open lucasthomazoni opened this issue 3 years ago • 5 comments

Added:

@abrom Since both API's do not allow user#username and room#name, I'm sending it as nil on user_params and room_params respectively.

lucasthomazoni avatar Oct 07 '22 19:10 lucasthomazoni

Not sure I follow what you mean about the APIs not allowing user#username and room#name. They both support these params. See

https://github.com/RocketChat/Rocket.Chat/blob/404cfffe3fcee219579efce47ee0cab114162c69/apps/meteor/app/api/server/v1/channels.ts#L200-L220

and

https://github.com/RocketChat/Rocket.Chat/blob/404cfffe3fcee219579efce47ee0cab114162c69/apps/meteor/app/api/server/v1/groups.js#L532-L551

Specifically from the getUserFromParams helper method: https://github.com/RocketChat/Rocket.Chat/blob/f74ba4e587ec294b4482ba578dcb2708f0322b4e/apps/meteor/app/api/server/helpers/getUserFromParams.ts#L7-L27

And the findChannelByIdOrName method: https://github.com/RocketChat/Rocket.Chat/blob/404cfffe3fcee219579efce47ee0cab114162c69/apps/meteor/app/api/server/v1/channels.ts#L30-L62 and findPrivateGroupByIdOrName method: https://github.com/RocketChat/Rocket.Chat/blob/404cfffe3fcee219579efce47ee0cab114162c69/apps/meteor/app/api/server/v1/groups.js#L22-L68

abrom avatar Oct 09 '22 14:10 abrom

The kick APIs are also already supported by the gem. See https://github.com/abrom/rocketchat-ruby/blob/main/lib/rocket_chat/messages/room.rb#L200-L207

abrom avatar Oct 09 '22 14:10 abrom

Still happy to accept a PR improving the docs and specs, although another spec or two to test the username/room name options would be nice (and removing the channel/group kick methods).

abrom avatar Oct 09 '22 14:10 abrom

@abrom Sorry I was looking at https://developer.rocket.chat/ docs instead of the actual code on GitHub and there is no mention of the user#username param.

I will undo the changes made and improve specs as well, just one unrelated question: Why are custom_fields not marked as settable attributes on channel and group APIs? Can I add it?

Thanks!

lucasthomazoni avatar Oct 11 '22 15:10 lucasthomazoni

No problems! Yeah the rocketchat docs are a little misleading on that front. I had to go hunting through the code base to find the real story 😉

Regarding custom fields, are you referring to https://developer.rocket.chat/reference/api/rest-api/endpoints/core-endpoints/channels-endpoints/setcustomfields ? (and similar for groups of course)

If so, it looks like that also supports finding the channel by ID or name (same as kick and others). See https://github.com/RocketChat/Rocket.Chat/blob/404cfffe3fcee219579efce47ee0cab114162c69/apps/meteor/app/api/server/v1/channels.js#L692-L712

But yes, absolutely. PR's welcome!

abrom avatar Oct 12 '22 00:10 abrom