abrom / rocketchat-ruby

Ruby wrapper for RocketChat v1 REST API
MIT License
33 stars 24 forks source link

feat: Channel and Group #kick APIs #39

Open lucasthomazoni opened 1 year ago

lucasthomazoni commented 1 year ago

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.

abrom commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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).

lucasthomazoni commented 1 year ago

@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!

abrom commented 1 year ago

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!