From f818507e3cc1913fe100c679b4745cb4d8adf75e Mon Sep 17 00:00:00 2001 From: Boris Peterbarg Date: Fri, 11 Nov 2022 02:16:42 +0200 Subject: [PATCH] Add ability to set_attr channel/group custom_fields (#40) * Add ability to set_attr channel/group custom_fields, announcement and default * Support RC API endpoint groups.create param extraData The extraData param allows setting arbitrary attributes on the RC Room. Added to the API in RC v3.12.0 by Rocket.Chat PR 20617, commit 2ad2d0bd7ed Co-authored-by: Noach Magedman --- lib/rocket_chat/messages/channel.rb | 5 ++++- lib/rocket_chat/messages/group.rb | 4 +++- lib/rocket_chat/messages/room.rb | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/rocket_chat/messages/channel.rb b/lib/rocket_chat/messages/channel.rb index 85fd5c2..3e12865 100644 --- a/lib/rocket_chat/messages/channel.rb +++ b/lib/rocket_chat/messages/channel.rb @@ -61,6 +61,9 @@ def online(room_id: nil, name: nil) end # Keys for set_attr: + # * [String] announcement Announcement for the channel + # * [Hash] custom_fields Custom fields for the channel + # * [Boolean] default Sets whether the channel is a default channel or not # * [String] description A room's description # * [String] join_code Code to join a channel # * [String] purpose Alias for description @@ -68,7 +71,7 @@ def online(room_id: nil, name: nil) # * [String] topic A room's topic # * [Strong] type c (channel) or p (private group) def self.settable_attributes - %i[description join_code purpose read_only topic type] + %i[announcement custom_fields default description join_code purpose read_only topic type] end end end diff --git a/lib/rocket_chat/messages/group.rb b/lib/rocket_chat/messages/group.rb index 6d5089a..49ca9b4 100644 --- a/lib/rocket_chat/messages/group.rb +++ b/lib/rocket_chat/messages/group.rb @@ -92,13 +92,15 @@ def online(room_id: nil, name: nil) end # Keys for set_attr: + # * [String] announcement Announcement for the channel + # * [Hash] custom_fields Custom fields for the channel # * [String] description A room's description # * [String] purpose Alias for description # * [Boolean] read_only Read-only status # * [String] topic A room's topic # * [Strong] type c (channel) or p (private group) def self.settable_attributes - %i[description purpose read_only topic type] + %i[announcement custom_fields description purpose read_only topic type] end end end diff --git a/lib/rocket_chat/messages/room.rb b/lib/rocket_chat/messages/room.rb index db2e59d..ce97f9a 100644 --- a/lib/rocket_chat/messages/room.rb +++ b/lib/rocket_chat/messages/room.rb @@ -309,7 +309,7 @@ def members(room_id: nil, name: nil, offset: nil, count: nil, sort: nil) attr_reader :session def room_option_hash(options) - args = [options, :members, :read_only, :custom_fields] + args = [options, :members, :read_only, :custom_fields, :extra_data] options = Util.slice_hash(*args) return {} if options.empty?