stream-chat-ruby 2.11.2 → 2.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2fe612ee0891b1f564057942d1f9ff74de3b1cf423dc3985e24ab45c87ef8687
4
- data.tar.gz: 8ea59fb71fcae04419b9a55d7466e3da2da8eee70d7fc1fccedd60037f5d7672
3
+ metadata.gz: a49d0bd536f4b372aa7fffeda3ba7797c0ad33ddc21f1ba4b7edf1b4bcba339a
4
+ data.tar.gz: 8092970fb6b1111d822ab962a19acf7b92f62538ecee854510fd56078e9375ad
5
5
  SHA512:
6
- metadata.gz: 164fb93106e15822aa2bb1a7561b2f5e24bcb94b09782851dfefbf0a05584b15d3a07a4190403c26a31e251f6b9b9d2ebd6c2853312a253a7dcad6ddd3f430cc
7
- data.tar.gz: 1e2a0b04c1eac20184c68d24dd10554acb064b61f2d732341184747131721e8f3dd74a6455e7acf958313af1be076c33bdc414f382e4b8d7932c1acb45a06ac8
6
+ metadata.gz: e806fef59018bfeeb59ac62ecb8153ea9cb80df56dd0c8b429f5d45311e9773ac45cc99e62d66b84b950cc96285e5ca9c8e6ac215afb6dc3eeb673cf999dae0d
7
+ data.tar.gz: 781642d54dbe9eccfa5340c432fb6d682e2cd1787cf09737ff41fbd5e0add670494b8a1ce9a575f9c0a9b2bdb3ac5de15526d1df4005d588d5e76421b4e547db
data/CHANGELOG.md CHANGED
@@ -1,3 +1,33 @@
1
+ ## November 24th, 2021 - 2.14.0
2
+
3
+ - Add new flags for export channels
4
+ - clear_deleted_message_text (default: false)
5
+ - include_truncated_messages (default: false)
6
+
7
+ ## November 17th, 2021 - 2.13.0
8
+
9
+ - Add support for shadow banning user
10
+ - shadow_ban
11
+ - remove_shadow_ban
12
+ - Add support for pinning messages
13
+ - pin_message
14
+ - unpin_message
15
+ - Add support for partial updating messages
16
+ - update_message_partial
17
+ - Add support for updating channel ownership for Deleted Users
18
+
19
+ ## November 1st, 2021 - 2.12.0
20
+
21
+ - Add support for async endpoints
22
+ - get_task
23
+ - delete_channels
24
+ - delete_users
25
+
26
+ ## October 22nd, 2021 - 2.11.3
27
+
28
+ - Don't log the entire response when creating exception
29
+ - Access error details through StreamAPIException class attr_readers
30
+
1
31
  ## October 5th, 2021 - 2.11.2
2
32
 
3
33
  - Add Codeowners file
@@ -12,6 +12,8 @@ require 'stream-chat/util'
12
12
 
13
13
  module StreamChat
14
14
  DEFAULT_BLOCKLIST = 'profanity_en_2020_v1'
15
+ SOFT_DELETE = 'soft'
16
+ HARD_DELETE = 'hard'
15
17
 
16
18
  class Client
17
19
  BASE_URL = 'https://chat.stream-io-api.com'
@@ -158,6 +160,16 @@ module StreamChat
158
160
  delete('moderation/ban', params: params)
159
161
  end
160
162
 
163
+ def shadow_ban(target_id, **options)
164
+ payload = { target_user_id: target_id, shadow: true }.merge(options)
165
+ post('moderation/ban', data: payload)
166
+ end
167
+
168
+ def remove_shadow_ban(target_id, **options)
169
+ params = { target_user_id: target_id, shadow: true }.merge(options)
170
+ delete('moderation/ban', params: params)
171
+ end
172
+
161
173
  def mute_user(target_id, user_id)
162
174
  payload = { target_id: target_id, user_id: user_id }
163
175
  post('moderation/mute', data: payload)
@@ -173,12 +185,37 @@ module StreamChat
173
185
  post('channels/read', data: payload)
174
186
  end
175
187
 
188
+ def pin_message(message_id, user_id, expiration: nil)
189
+ updates = {
190
+ set: {
191
+ pinned: true,
192
+ pin_expires: expiration
193
+ }
194
+ }
195
+ update_message_partial(message_id, updates, user_id: user_id)
196
+ end
197
+
198
+ def unpin_message(message_id, user_id)
199
+ updates = {
200
+ set: {
201
+ pinned: false
202
+ }
203
+ }
204
+ update_message_partial(message_id, updates, user_id: user_id)
205
+ end
206
+
176
207
  def update_message(message)
177
208
  raise ArgumentError 'message must have an id' unless message.key? 'id'
178
209
 
179
210
  post("messages/#{message['id']}", data: { message: message })
180
211
  end
181
212
 
213
+ def update_message_partial(message_id, updates, user_id: nil, **options)
214
+ params = updates.merge(options)
215
+ params['user'] = { id: user_id } if user_id
216
+ put("messages/#{message_id}", data: params)
217
+ end
218
+
182
219
  def delete_message(message_id)
183
220
  delete("messages/#{message_id}")
184
221
  end
@@ -285,14 +322,26 @@ module StreamChat
285
322
  delete("blocklists/#{name}")
286
323
  end
287
324
 
288
- def export_channels(*channels)
289
- post('export_channels', data: { channels: channels })
325
+ def export_channels(*channels, **options)
326
+ post('export_channels', data: { channels: channels, **options })
290
327
  end
291
328
 
292
329
  def get_export_channel_status(task_id)
293
330
  get("export_channels/#{task_id}")
294
331
  end
295
332
 
333
+ def get_task(task_id)
334
+ get("tasks/#{task_id}")
335
+ end
336
+
337
+ def delete_users(user_ids, user: SOFT_DELETE, messages: nil, conversations: nil)
338
+ post('users/delete', data: { user_ids: user_ids, user: user, messages: messages, conversations: conversations })
339
+ end
340
+
341
+ def delete_channels(cids, hard_delete: false)
342
+ post('channels/delete', data: { cids: cids, hard_delete: hard_delete })
343
+ end
344
+
296
345
  def revoke_tokens(before)
297
346
  before = before.rfc3339 if before.instance_of?(DateTime)
298
347
  update_app_settings({ 'revoke_tokens_issued_before' => before })
@@ -4,10 +4,12 @@
4
4
 
5
5
  module StreamChat
6
6
  class StreamAPIException < StandardError
7
+ attr_reader :error_code
8
+ attr_reader :error_message
9
+
7
10
  def initialize(response)
8
11
  super()
9
12
  @response = response
10
- p response
11
13
  begin
12
14
  parsed_response = JSON.parse(response.body)
13
15
  @json_response = true
@@ -25,6 +27,14 @@ module StreamChat
25
27
  "StreamChat error HTTP code: #{@response.status}"
26
28
  end
27
29
  end
30
+
31
+ def json_response?
32
+ @json_response
33
+ end
34
+
35
+ def to_s
36
+ message
37
+ end
28
38
  end
29
39
 
30
40
  class StreamChannelException < StandardError; end
@@ -3,5 +3,5 @@
3
3
  # lib/version.rb
4
4
 
5
5
  module StreamChat
6
- VERSION = '2.11.2'
6
+ VERSION = '2.14.0'
7
7
  end
data/stream-chat.gemspec CHANGED
@@ -23,4 +23,5 @@ Gem::Specification.new do |gem|
23
23
  gem.add_development_dependency 'rake'
24
24
  gem.add_development_dependency 'rspec'
25
25
  gem.add_development_dependency 'simplecov'
26
+ gem.metadata['rubygems_mfa_required'] = 'true'
26
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stream-chat-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.2
4
+ version: 2.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mircea Cosbuc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-05 00:00:00.000000000 Z
11
+ date: 2021-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -105,7 +105,8 @@ files:
105
105
  - stream-chat.gemspec
106
106
  homepage: http://github.com/GetStream/stream-chat-ruby
107
107
  licenses: []
108
- metadata: {}
108
+ metadata:
109
+ rubygems_mfa_required: 'true'
109
110
  post_install_message:
110
111
  rdoc_options: []
111
112
  require_paths:
@@ -121,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
122
  - !ruby/object:Gem::Version
122
123
  version: '0'
123
124
  requirements: []
124
- rubygems_version: 3.0.3
125
+ rubygems_version: 3.1.2
125
126
  signing_key:
126
127
  specification_version: 4
127
128
  summary: The low level client for serverside calls for Stream Chat.