99module StreamChat
1010 class Channel
1111 extend T ::Sig
12- T ::Configuration . default_checked_level = :never
1312 # For now we disable runtime type checks.
1413 # We will enable it with a major bump in the future,
1514 # but for now, let's just run a static type check.
1615
17- sig { returns ( T . nilable ( String ) ) }
16+ T :: Sig :: WithoutRuntime . sig { returns ( T . nilable ( String ) ) }
1817 attr_reader :id
1918
20- sig { returns ( String ) }
19+ T :: Sig :: WithoutRuntime . sig { returns ( String ) }
2120 attr_reader :channel_type
2221
23- sig { returns ( StringKeyHash ) }
22+ T :: Sig :: WithoutRuntime . sig { returns ( StringKeyHash ) }
2423 attr_reader :custom_data
2524
26- sig { returns ( T ::Array [ StringKeyHash ] ) }
25+ T :: Sig :: WithoutRuntime . sig { returns ( T ::Array [ StringKeyHash ] ) }
2726 attr_reader :members
2827
29- sig { params ( client : StreamChat ::Client , channel_type : String , channel_id : T . nilable ( String ) , custom_data : T . nilable ( StringKeyHash ) ) . void }
28+ T :: Sig :: WithoutRuntime . sig { params ( client : StreamChat ::Client , channel_type : String , channel_id : T . nilable ( String ) , custom_data : T . nilable ( StringKeyHash ) ) . void }
3029 def initialize ( client , channel_type , channel_id = nil , custom_data = nil )
3130 @channel_type = channel_type
3231 @id = channel_id
@@ -36,42 +35,42 @@ def initialize(client, channel_type, channel_id = nil, custom_data = nil)
3635 @members = T . let ( [ ] , T ::Array [ StringKeyHash ] )
3736 end
3837
39- sig { returns ( String ) }
38+ T :: Sig :: WithoutRuntime . sig { returns ( String ) }
4039 def url
4140 raise StreamChannelException , 'channel does not have an id' if @id . nil?
4241
4342 "channels/#{ @channel_type } /#{ @id } "
4443 end
4544
4645 # Gets multiple messages from the channel.
47- sig { params ( message_ids : T ::Array [ String ] ) . returns ( StreamChat ::StreamResponse ) }
46+ T :: Sig :: WithoutRuntime . sig { params ( message_ids : T ::Array [ String ] ) . returns ( StreamChat ::StreamResponse ) }
4847 def get_messages ( message_ids )
4948 @client . get ( "#{ url } /messages" , params : { 'ids' => message_ids . join ( ',' ) } )
5049 end
5150
5251 # Sends a message to this channel.
53- sig { params ( message : StringKeyHash , user_id : String ) . returns ( StreamChat ::StreamResponse ) }
52+ T :: Sig :: WithoutRuntime . sig { params ( message : StringKeyHash , user_id : String ) . returns ( StreamChat ::StreamResponse ) }
5453 def send_message ( message , user_id )
5554 payload = { message : add_user_id ( message , user_id ) }
5655 @client . post ( "#{ url } /message" , data : payload )
5756 end
5857
5958 # Sends an event on this channel.
60- sig { params ( event : StringKeyHash , user_id : String ) . returns ( StreamChat ::StreamResponse ) }
59+ T :: Sig :: WithoutRuntime . sig { params ( event : StringKeyHash , user_id : String ) . returns ( StreamChat ::StreamResponse ) }
6160 def send_event ( event , user_id )
6261 payload = { 'event' => add_user_id ( event , user_id ) }
6362 @client . post ( "#{ url } /event" , data : payload )
6463 end
6564
6665 # Sends a new reaction to a given message.
67- sig { params ( message_id : String , reaction : StringKeyHash , user_id : String ) . returns ( StreamChat ::StreamResponse ) }
66+ T :: Sig :: WithoutRuntime . sig { params ( message_id : String , reaction : StringKeyHash , user_id : String ) . returns ( StreamChat ::StreamResponse ) }
6867 def send_reaction ( message_id , reaction , user_id )
6968 payload = { reaction : add_user_id ( reaction , user_id ) }
7069 @client . post ( "messages/#{ message_id } /reaction" , data : payload )
7170 end
7271
7372 # Delete a reaction from a message.
74- sig { params ( message_id : String , reaction_type : String , user_id : String ) . returns ( StreamChat ::StreamResponse ) }
73+ T :: Sig :: WithoutRuntime . sig { params ( message_id : String , reaction_type : String , user_id : String ) . returns ( StreamChat ::StreamResponse ) }
7574 def delete_reaction ( message_id , reaction_type , user_id )
7675 @client . delete (
7776 "messages/#{ message_id } /reaction/#{ reaction_type } " ,
@@ -80,14 +79,14 @@ def delete_reaction(message_id, reaction_type, user_id)
8079 end
8180
8281 # Creates a channel with the given creator user.
83- sig { params ( user_id : String ) . returns ( StreamChat ::StreamResponse ) }
82+ T :: Sig :: WithoutRuntime . sig { params ( user_id : String ) . returns ( StreamChat ::StreamResponse ) }
8483 def create ( user_id )
8584 @custom_data [ 'created_by' ] = { id : user_id }
8685 query ( watch : false , state : false , presence : false )
8786 end
8887
8988 # Creates or returns a channel.
90- sig { params ( options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
89+ T :: Sig :: WithoutRuntime . sig { params ( options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
9190 def query ( **options )
9291 payload = { state : true , data : @custom_data } . merge ( options )
9392 url = "channels/#{ @channel_type } "
@@ -104,7 +103,7 @@ def query(**options)
104103 # endpoint supports filtering on numerous criteria to efficiently return members information.
105104 # This endpoint is useful for channels that have large lists of members and
106105 # you want to search members or if you want to display the full list of members for a channel.
107- sig { params ( filter_conditions : StringKeyHash , sort : T . nilable ( T ::Hash [ String , Integer ] ) , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
106+ T :: Sig :: WithoutRuntime . sig { params ( filter_conditions : StringKeyHash , sort : T . nilable ( T ::Hash [ String , Integer ] ) , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
108107 def query_members ( filter_conditions = { } , sort : nil , **options )
109108 params = { } . merge ( options ) . merge ( {
110109 id : @id ,
@@ -124,14 +123,14 @@ def query_members(filter_conditions = {}, sort: nil, **options)
124123 end
125124
126125 # Updates a channel.
127- sig { params ( channel_data : T . nilable ( StringKeyHash ) , update_message : T . nilable ( StringKeyHash ) , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
126+ T :: Sig :: WithoutRuntime . sig { params ( channel_data : T . nilable ( StringKeyHash ) , update_message : T . nilable ( StringKeyHash ) , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
128127 def update ( channel_data , update_message = nil , **options )
129128 payload = { data : channel_data , message : update_message } . merge ( options )
130129 @client . post ( url , data : payload )
131130 end
132131
133132 # Updates a channel partially.
134- sig { params ( set : T . nilable ( StringKeyHash ) , unset : T . nilable ( T ::Array [ String ] ) ) . returns ( StreamChat ::StreamResponse ) }
133+ T :: Sig :: WithoutRuntime . sig { params ( set : T . nilable ( StringKeyHash ) , unset : T . nilable ( T ::Array [ String ] ) ) . returns ( StreamChat ::StreamResponse ) }
135134 def update_partial ( set = nil , unset = nil )
136135 raise StreamChannelException , 'set or unset is needed' if set . nil? && unset . nil?
137136
@@ -140,13 +139,13 @@ def update_partial(set = nil, unset = nil)
140139 end
141140
142141 # Deletes a channel.
143- sig { returns ( StreamChat ::StreamResponse ) }
142+ T :: Sig :: WithoutRuntime . sig { returns ( StreamChat ::StreamResponse ) }
144143 def delete
145144 @client . delete ( url )
146145 end
147146
148147 # Removes all messages from the channel.
149- sig { params ( options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
148+ T :: Sig :: WithoutRuntime . sig { params ( options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
150149 def truncate ( **options )
151150 @client . post ( "#{ url } /truncate" , data : options )
152151 end
@@ -157,112 +156,112 @@ def truncate(**options)
157156 # unread count for the users that muted it. By default, mutes stay in place indefinitely
158157 # until the user removes it; however, you can optionally set an expiration time. The list
159158 # of muted channels and their expiration time is returned when the user connects.
160- sig { params ( user_id : String , expiration : T . nilable ( Integer ) ) . returns ( StreamChat ::StreamResponse ) }
159+ T :: Sig :: WithoutRuntime . sig { params ( user_id : String , expiration : T . nilable ( Integer ) ) . returns ( StreamChat ::StreamResponse ) }
161160 def mute ( user_id , expiration = nil )
162161 data = { user_id : user_id , channel_cid : @cid }
163162 data [ 'expiration' ] = expiration if expiration
164163 @client . post ( 'moderation/mute/channel' , data : data )
165164 end
166165
167166 # Unmutes a channel.
168- sig { params ( user_id : String ) . returns ( StreamChat ::StreamResponse ) }
167+ T :: Sig :: WithoutRuntime . sig { params ( user_id : String ) . returns ( StreamChat ::StreamResponse ) }
169168 def unmute ( user_id )
170169 @client . post ( 'moderation/unmute/channel' , data : { 'user_id' => user_id , 'channel_cid' => @cid } )
171170 end
172171
173172 # Adds members to the channel.
174- sig { params ( user_ids : T ::Array [ String ] , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
173+ T :: Sig :: WithoutRuntime . sig { params ( user_ids : T ::Array [ String ] , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
175174 def add_members ( user_ids , **options )
176175 payload = options . merge ( { add_members : user_ids } )
177176 update ( nil , nil , **payload )
178177 end
179178
180179 # Invites users to the channel.
181- sig { params ( user_ids : T ::Array [ String ] , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
180+ T :: Sig :: WithoutRuntime . sig { params ( user_ids : T ::Array [ String ] , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
182181 def invite_members ( user_ids , **options )
183182 payload = options . merge ( { invites : user_ids } )
184183 update ( nil , nil , **payload )
185184 end
186185
187186 # Accepts an invitation to the channel.
188- sig { params ( user_id : String , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
187+ T :: Sig :: WithoutRuntime . sig { params ( user_id : String , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
189188 def accept_invite ( user_id , **options )
190189 payload = options . merge ( { user_id : user_id , accept_invite : true } )
191190 update ( nil , nil , **payload )
192191 end
193192
194193 # Rejects an invitation to the channel.
195- sig { params ( user_id : String , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
194+ T :: Sig :: WithoutRuntime . sig { params ( user_id : String , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
196195 def reject_invite ( user_id , **options )
197196 payload = options . merge ( { user_id : user_id , reject_invite : true } )
198197 update ( nil , nil , **payload )
199198 end
200199
201200 # Adds moderators to the channel.
202- sig { params ( user_ids : T ::Array [ String ] ) . returns ( StreamChat ::StreamResponse ) }
201+ T :: Sig :: WithoutRuntime . sig { params ( user_ids : T ::Array [ String ] ) . returns ( StreamChat ::StreamResponse ) }
203202 def add_moderators ( user_ids )
204203 update ( nil , nil , add_moderators : user_ids )
205204 end
206205
207206 # Removes members from the channel.
208- sig { params ( user_ids : T ::Array [ String ] ) . returns ( StreamChat ::StreamResponse ) }
207+ T :: Sig :: WithoutRuntime . sig { params ( user_ids : T ::Array [ String ] ) . returns ( StreamChat ::StreamResponse ) }
209208 def remove_members ( user_ids )
210209 update ( nil , nil , remove_members : user_ids )
211210 end
212211
213212 # Assigns roles to members in the channel.
214- sig { params ( members : T ::Array [ StringKeyHash ] , message : T . nilable ( StringKeyHash ) ) . returns ( StreamChat ::StreamResponse ) }
213+ T :: Sig :: WithoutRuntime . sig { params ( members : T ::Array [ StringKeyHash ] , message : T . nilable ( StringKeyHash ) ) . returns ( StreamChat ::StreamResponse ) }
215214 def assign_roles ( members , message = nil )
216215 update ( nil , message , assign_roles : members )
217216 end
218217
219218 # Demotes moderators in the channel.
220- sig { params ( user_ids : T ::Array [ String ] ) . returns ( StreamChat ::StreamResponse ) }
219+ T :: Sig :: WithoutRuntime . sig { params ( user_ids : T ::Array [ String ] ) . returns ( StreamChat ::StreamResponse ) }
221220 def demote_moderators ( user_ids )
222221 update ( nil , nil , demote_moderators : user_ids )
223222 end
224223
225224 # Sends the mark read event for this user, only works if the `read_events` setting is enabled.
226- sig { params ( user_id : String , options : StringKeyHash ) . returns ( StreamChat ::StreamResponse ) }
225+ T :: Sig :: WithoutRuntime . sig { params ( user_id : String , options : StringKeyHash ) . returns ( StreamChat ::StreamResponse ) }
227226 def mark_read ( user_id , **options )
228227 payload = add_user_id ( options , user_id )
229228 @client . post ( "#{ url } /read" , data : payload )
230229 end
231230
232231 # List the message replies for a parent message.
233- sig { params ( parent_id : String , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
232+ T :: Sig :: WithoutRuntime . sig { params ( parent_id : String , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
234233 def get_replies ( parent_id , **options )
235234 @client . get ( "messages/#{ parent_id } /replies" , params : options )
236235 end
237236
238237 # List the reactions, supports pagination.
239- sig { params ( message_id : String , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
238+ T :: Sig :: WithoutRuntime . sig { params ( message_id : String , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
240239 def get_reactions ( message_id , **options )
241240 @client . get ( "messages/#{ message_id } /reactions" , params : options )
242241 end
243242
244243 # Bans a user from this channel.
245- sig { params ( user_id : String , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
244+ T :: Sig :: WithoutRuntime . sig { params ( user_id : String , options : T . untyped ) . returns ( StreamChat ::StreamResponse ) }
246245 def ban_user ( user_id , **options )
247246 @client . ban_user ( user_id , type : @channel_type , id : @id , **options )
248247 end
249248
250249 # Removes the ban for a user on this channel.
251- sig { params ( user_id : String ) . returns ( StreamChat ::StreamResponse ) }
250+ T :: Sig :: WithoutRuntime . sig { params ( user_id : String ) . returns ( StreamChat ::StreamResponse ) }
252251 def unban_user ( user_id )
253252 @client . unban_user ( user_id , type : @channel_type , id : @id )
254253 end
255254
256255 # Removes a channel from query channel requests for that user until a new message is added.
257256 # Use `show` to cancel this operation.
258- sig { params ( user_id : String ) . returns ( StreamChat ::StreamResponse ) }
257+ T :: Sig :: WithoutRuntime . sig { params ( user_id : String ) . returns ( StreamChat ::StreamResponse ) }
259258 def hide ( user_id )
260259 @client . post ( "#{ url } /hide" , data : { user_id : user_id } )
261260 end
262261
263262 # Shows a previously hidden channel.
264263 # Use `hide` to hide a channel.
265- sig { params ( user_id : String ) . returns ( StreamChat ::StreamResponse ) }
264+ T :: Sig :: WithoutRuntime . sig { params ( user_id : String ) . returns ( StreamChat ::StreamResponse ) }
266265 def show ( user_id )
267266 @client . post ( "#{ url } /show" , data : { user_id : user_id } )
268267 end
@@ -271,7 +270,7 @@ def show(user_id)
271270 #
272271 # This functionality defaults to using the Stream CDN. If you would like, you can
273272 # easily change the logic to upload to your own CDN of choice.
274- sig { params ( url : String , user : StringKeyHash , content_type : T . nilable ( String ) ) . returns ( StreamChat ::StreamResponse ) }
273+ T :: Sig :: WithoutRuntime . sig { params ( url : String , user : StringKeyHash , content_type : T . nilable ( String ) ) . returns ( StreamChat ::StreamResponse ) }
275274 def send_file ( url , user , content_type = nil )
276275 @client . send_file ( "#{ self . url } /file" , url , user , content_type )
277276 end
@@ -282,26 +281,26 @@ def send_file(url, user, content_type = nil)
282281 # image/heic, image/heic-sequence, image/heif, image/heif-sequence, image/svg+xml.
283282 # You can set a more restrictive list for your application if needed.
284283 # The maximum file size is 100MB.
285- sig { params ( url : String , user : StringKeyHash , content_type : T . nilable ( String ) ) . returns ( StreamChat ::StreamResponse ) }
284+ T :: Sig :: WithoutRuntime . sig { params ( url : String , user : StringKeyHash , content_type : T . nilable ( String ) ) . returns ( StreamChat ::StreamResponse ) }
286285 def send_image ( url , user , content_type = nil )
287286 @client . send_file ( "#{ self . url } /image" , url , user , content_type )
288287 end
289288
290289 # Deletes a file by file url.
291- sig { params ( url : String ) . returns ( StreamChat ::StreamResponse ) }
290+ T :: Sig :: WithoutRuntime . sig { params ( url : String ) . returns ( StreamChat ::StreamResponse ) }
292291 def delete_file ( url )
293292 @client . delete ( "#{ self . url } /file" , params : { url : url } )
294293 end
295294
296295 # Deletes an image by image url.
297- sig { params ( url : String ) . returns ( StreamChat ::StreamResponse ) }
296+ T :: Sig :: WithoutRuntime . sig { params ( url : String ) . returns ( StreamChat ::StreamResponse ) }
298297 def delete_image ( url )
299298 @client . delete ( "#{ self . url } /image" , params : { url : url } )
300299 end
301300
302301 private
303302
304- sig { params ( payload : StringKeyHash , user_id : String ) . returns ( StringKeyHash ) }
303+ T :: Sig :: WithoutRuntime . sig { params ( payload : StringKeyHash , user_id : String ) . returns ( StringKeyHash ) }
305304 def add_user_id ( payload , user_id )
306305 payload . merge ( { user : { id : user_id } } )
307306 end
0 commit comments