Skip to content

Commit

Permalink
Add ability to set_attr channel/group custom_fields (#40)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
reist and nmagedman authored Nov 11, 2022
1 parent 3fcc8ff commit f818507
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/rocket_chat/messages/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,17 @@ 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
# * [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 join_code purpose read_only topic type]
%i[announcement custom_fields default description join_code purpose read_only topic type]
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/rocket_chat/messages/group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/rocket_chat/messages/room.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit f818507

Please sign in to comment.