@@ -43,29 +43,34 @@ def url
4343 "channels/#{ @channel_type } /#{ @id } "
4444 end
4545
46+ # Gets multiple messages from the channel.
4647 sig { params ( message_ids : T ::Array [ String ] ) . returns ( StreamChat ::StreamResponse ) }
4748 def get_messages ( message_ids )
4849 @client . get ( "#{ url } /messages" , params : { 'ids' => message_ids . join ( ',' ) } )
4950 end
5051
52+ # Sends a message to this channel.
5153 sig { params ( message : StringKeyHash , user_id : String ) . returns ( StreamChat ::StreamResponse ) }
5254 def send_message ( message , user_id )
5355 payload = { message : add_user_id ( message , user_id ) }
5456 @client . post ( "#{ url } /message" , data : payload )
5557 end
5658
59+ # Sends an event on this channel.
5760 sig { params ( event : StringKeyHash , user_id : String ) . returns ( StreamChat ::StreamResponse ) }
5861 def send_event ( event , user_id )
5962 payload = { 'event' => add_user_id ( event , user_id ) }
6063 @client . post ( "#{ url } /event" , data : payload )
6164 end
6265
66+ # Sends a new reaction to a given message.
6367 sig { params ( message_id : String , reaction : StringKeyHash , user_id : String ) . returns ( StreamChat ::StreamResponse ) }
6468 def send_reaction ( message_id , reaction , user_id )
6569 payload = { reaction : add_user_id ( reaction , user_id ) }
6670 @client . post ( "messages/#{ message_id } /reaction" , data : payload )
6771 end
6872
73+ # Delete a reaction from a message.
6974 sig { params ( message_id : String , reaction_type : String , user_id : String ) . returns ( StreamChat ::StreamResponse ) }
7075 def delete_reaction ( message_id , reaction_type , user_id )
7176 @client . delete (
@@ -74,12 +79,14 @@ def delete_reaction(message_id, reaction_type, user_id)
7479 )
7580 end
7681
82+ # Creates a channel with the given creator user.
7783 sig { params ( user_id : String ) . returns ( StreamChat ::StreamResponse ) }
7884 def create ( user_id )
7985 @custom_data [ 'created_by' ] = { id : user_id }
8086 query ( watch : false , state : false , presence : false )
8187 end
8288
89+ # Creates or returns a channel.
8390 sig { params ( options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
8491 def query ( **options )
8592 payload = { state : true , data : @custom_data } . merge ( options )
@@ -91,6 +98,12 @@ def query(**options)
9198 state
9299 end
93100
101+ # Queries members of a channel.
102+ #
103+ # The queryMembers endpoint allows you to list and paginate members from a channel. The
104+ # endpoint supports filtering on numerous criteria to efficiently return members information.
105+ # This endpoint is useful for channels that have large lists of members and
106+ # you want to search members or if you want to display the full list of members for a channel.
94107 sig { params ( filter_conditions : StringKeyHash , sort : T . nilable ( T ::Hash [ String , Integer ] ) , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
95108 def query_members ( filter_conditions = { } , sort : nil , **options )
96109 params = { } . merge ( options ) . merge ( {
@@ -110,12 +123,14 @@ def query_members(filter_conditions = {}, sort: nil, **options)
110123 @client . get ( 'members' , params : { payload : params . to_json } )
111124 end
112125
126+ # Updates a channel.
113127 sig { params ( channel_data : T . nilable ( StringKeyHash ) , update_message : T . nilable ( StringKeyHash ) , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
114128 def update ( channel_data , update_message = nil , **options )
115129 payload = { data : channel_data , message : update_message } . merge ( options )
116130 @client . post ( url , data : payload )
117131 end
118132
133+ # Updates a channel partially.
119134 sig { params ( set : T . nilable ( StringKeyHash ) , unset : T . nilable ( T ::Array [ String ] ) ) . returns ( StreamChat ::StreamResponse ) }
120135 def update_partial ( set = nil , unset = nil )
121136 raise StreamChannelException , 'set or unset is needed' if set . nil? && unset . nil?
@@ -124,123 +139,161 @@ def update_partial(set = nil, unset = nil)
124139 @client . patch ( url , data : payload )
125140 end
126141
142+ # Deletes a channel.
127143 sig { returns ( StreamChat ::StreamResponse ) }
128144 def delete
129145 @client . delete ( url )
130146 end
131147
148+ # Removes all messages from the channel.
132149 sig { params ( options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
133150 def truncate ( **options )
134151 @client . post ( "#{ url } /truncate" , data : options )
135152 end
136153
154+ # Mutes a channel.
155+ #
156+ # Messages added to a muted channel will not trigger push notifications, nor change the
157+ # unread count for the users that muted it. By default, mutes stay in place indefinitely
158+ # until the user removes it; however, you can optionally set an expiration time. The list
159+ # of muted channels and their expiration time is returned when the user connects.
137160 sig { params ( user_id : String , expiration : T . nilable ( Integer ) ) . returns ( StreamChat ::StreamResponse ) }
138161 def mute ( user_id , expiration = nil )
139162 data = { user_id : user_id , channel_cid : @cid }
140163 data [ 'expiration' ] = expiration if expiration
141164 @client . post ( 'moderation/mute/channel' , data : data )
142165 end
143166
167+ # Unmutes a channel.
144168 sig { params ( user_id : String ) . returns ( StreamChat ::StreamResponse ) }
145169 def unmute ( user_id )
146170 @client . post ( 'moderation/unmute/channel' , data : { 'user_id' => user_id , 'channel_cid' => @cid } )
147171 end
148172
173+ # Adds members to the channel.
149174 sig { params ( user_ids : T ::Array [ String ] , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
150175 def add_members ( user_ids , **options )
151176 payload = options . merge ( { add_members : user_ids } )
152177 update ( nil , nil , **payload )
153178 end
154179
180+ # Invites users to the channel.
155181 sig { params ( user_ids : T ::Array [ String ] , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
156182 def invite_members ( user_ids , **options )
157183 payload = options . merge ( { invites : user_ids } )
158184 update ( nil , nil , **payload )
159185 end
160186
187+ # Accepts an invitation to the channel.
161188 sig { params ( user_id : String , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
162189 def accept_invite ( user_id , **options )
163190 payload = options . merge ( { user_id : user_id , accept_invite : true } )
164191 update ( nil , nil , **payload )
165192 end
166193
194+ # Rejects an invitation to the channel.
167195 sig { params ( user_id : String , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
168196 def reject_invite ( user_id , **options )
169197 payload = options . merge ( { user_id : user_id , reject_invite : true } )
170198 update ( nil , nil , **payload )
171199 end
172200
201+ # Adds moderators to the channel.
173202 sig { params ( user_ids : T ::Array [ String ] ) . returns ( StreamChat ::StreamResponse ) }
174203 def add_moderators ( user_ids )
175204 update ( nil , nil , add_moderators : user_ids )
176205 end
177206
207+ # Removes members from the channel.
178208 sig { params ( user_ids : T ::Array [ String ] ) . returns ( StreamChat ::StreamResponse ) }
179209 def remove_members ( user_ids )
180210 update ( nil , nil , remove_members : user_ids )
181211 end
182212
213+ # Assigns roles to members in the channel.
183214 sig { params ( members : T ::Array [ StringKeyHash ] , message : T . nilable ( StringKeyHash ) ) . returns ( StreamChat ::StreamResponse ) }
184215 def assign_roles ( members , message = nil )
185216 update ( nil , message , assign_roles : members )
186217 end
187218
219+ # Demotes moderators in the channel.
188220 sig { params ( user_ids : T ::Array [ String ] ) . returns ( StreamChat ::StreamResponse ) }
189221 def demote_moderators ( user_ids )
190222 update ( nil , nil , demote_moderators : user_ids )
191223 end
192224
225+ # Sends the mark read event for this user, only works if the `read_events` setting is enabled.
193226 sig { params ( user_id : String , options : StringKeyHash ) . returns ( StreamChat ::StreamResponse ) }
194227 def mark_read ( user_id , **options )
195228 payload = add_user_id ( options , user_id )
196229 @client . post ( "#{ url } /read" , data : payload )
197230 end
198231
232+ # List the message replies for a parent message.
199233 sig { params ( parent_id : String , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
200234 def get_replies ( parent_id , **options )
201235 @client . get ( "messages/#{ parent_id } /replies" , params : options )
202236 end
203237
238+ # List the reactions, supports pagination.
204239 sig { params ( message_id : String , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
205240 def get_reactions ( message_id , **options )
206241 @client . get ( "messages/#{ message_id } /reactions" , params : options )
207242 end
208243
244+ # Bans a user from this channel.
209245 sig { params ( user_id : String , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
210246 def ban_user ( user_id , **options )
211247 @client . ban_user ( user_id , type : @channel_type , id : @id , **options )
212248 end
213249
250+ # Removes the ban for a user on this channel.
214251 sig { params ( user_id : String ) . returns ( StreamChat ::StreamResponse ) }
215252 def unban_user ( user_id )
216253 @client . unban_user ( user_id , type : @channel_type , id : @id )
217254 end
218255
256+ # Removes a channel from query channel requests for that user until a new message is added.
257+ # Use `show` to cancel this operation.
219258 sig { params ( user_id : String ) . returns ( StreamChat ::StreamResponse ) }
220259 def hide ( user_id )
221260 @client . post ( "#{ url } /hide" , data : { user_id : user_id } )
222261 end
223262
263+ # Shows a previously hidden channel.
264+ # Use `hide` to hide a channel.
224265 sig { params ( user_id : String ) . returns ( StreamChat ::StreamResponse ) }
225266 def show ( user_id )
226267 @client . post ( "#{ url } /show" , data : { user_id : user_id } )
227268 end
228269
270+ # Uploads a file.
271+ #
272+ # This functionality defaults to using the Stream CDN. If you would like, you can
273+ # easily change the logic to upload to your own CDN of choice.
229274 sig { params ( url : String , user : StringKeyHash , content_type : T . nilable ( String ) ) . returns ( StreamChat ::StreamResponse ) }
230275 def send_file ( url , user , content_type = nil )
231276 @client . send_file ( "#{ self . url } /file" , url , user , content_type )
232277 end
233278
279+ # Uploads an image.
280+ #
281+ # Stream supported image types are: image/bmp, image/gif, image/jpeg, image/png, image/webp,
282+ # image/heic, image/heic-sequence, image/heif, image/heif-sequence, image/svg+xml.
283+ # You can set a more restrictive list for your application if needed.
284+ # The maximum file size is 100MB.
234285 sig { params ( url : String , user : StringKeyHash , content_type : T . nilable ( String ) ) . returns ( StreamChat ::StreamResponse ) }
235286 def send_image ( url , user , content_type = nil )
236287 @client . send_file ( "#{ self . url } /image" , url , user , content_type )
237288 end
238289
290+ # Deletes a file by file url.
239291 sig { params ( url : String ) . returns ( StreamChat ::StreamResponse ) }
240292 def delete_file ( url )
241293 @client . delete ( "#{ self . url } /file" , params : { url : url } )
242294 end
243295
296+ # Deletes an image by image url.
244297 sig { params ( url : String ) . returns ( StreamChat ::StreamResponse ) }
245298 def delete_image ( url )
246299 @client . delete ( "#{ self . url } /image" , params : { url : url } )
0 commit comments