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 +4 -4
- data/CHANGELOG.md +30 -0
- data/lib/stream-chat/client.rb +51 -2
- data/lib/stream-chat/errors.rb +11 -1
- data/lib/stream-chat/version.rb +1 -1
- data/stream-chat.gemspec +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a49d0bd536f4b372aa7fffeda3ba7797c0ad33ddc21f1ba4b7edf1b4bcba339a
|
4
|
+
data.tar.gz: 8092970fb6b1111d822ab962a19acf7b92f62538ecee854510fd56078e9375ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/stream-chat/client.rb
CHANGED
@@ -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 })
|
data/lib/stream-chat/errors.rb
CHANGED
@@ -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
|
data/lib/stream-chat/version.rb
CHANGED
data/stream-chat.gemspec
CHANGED
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.
|
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-
|
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.
|
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.
|