stream-chat-ruby 2.11.1 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -0
- data/.github/workflows/ci.yml +4 -5
- data/CHANGELOG.md +32 -0
- data/lib/stream-chat/channel.rb +2 -2
- data/lib/stream-chat/client.rb +50 -1
- data/lib/stream-chat/errors.rb +11 -1
- data/lib/stream-chat/version.rb +1 -1
- data/stream-chat.gemspec +1 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d913a2d883a67d7e06afd1e57febfb5565cbcd23d69249e101f72163084f7b96
|
4
|
+
data.tar.gz: af4374cd74b9789c5751f6569e9317e46289207daa6a72eea0e53a20ad3ee43f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c7ed7f7f94d009b4e3a091942f6b59cfa14087d02ba4b2659e18755dbb62a8bbe471e0497ce46a113598fd1e36aa2c7a3749f4ca3505f6f18e28a8d2ca3e663
|
7
|
+
data.tar.gz: 4c0dbed5b2230c4ce9fb3b8630f6d8fa72dd58097b35b12d78a6b355635cd7d9b0b63e38e1b011b57d7ce647fb271b0b225977e02c35718d549fc9d9c9ad7da3
|
data/.github/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @ffenix113
|
data/.github/workflows/ci.yml
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
name:
|
1
|
+
name: test
|
2
2
|
|
3
3
|
on: [pull_request]
|
4
4
|
|
5
5
|
jobs:
|
6
|
-
|
6
|
+
test:
|
7
7
|
runs-on: ubuntu-latest
|
8
8
|
strategy:
|
9
9
|
max-parallel: 1
|
@@ -12,15 +12,14 @@ jobs:
|
|
12
12
|
name: Ruby ${{ matrix.ruby }}
|
13
13
|
steps:
|
14
14
|
- uses: actions/checkout@v2
|
15
|
-
- uses:
|
15
|
+
- uses: ruby/setup-ruby@v1
|
16
16
|
with:
|
17
17
|
ruby-version: ${{ matrix.ruby }}
|
18
|
+
bundler-cache: true
|
18
19
|
|
19
20
|
- env:
|
20
21
|
STREAM_CHAT_API_KEY: ${{ secrets.STREAM_CHAT_API_KEY }}
|
21
22
|
STREAM_CHAT_API_SECRET: ${{ secrets.STREAM_CHAT_API_SECRET }}
|
22
23
|
run: |
|
23
|
-
gem install bundler
|
24
|
-
bundle install --jobs 4 --retry 3
|
25
24
|
bundle exec rake rubocop
|
26
25
|
bundle exec rake test
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,35 @@
|
|
1
|
+
## November 17th, 2021 - 2.13.0
|
2
|
+
|
3
|
+
- Add support for shadow banning user
|
4
|
+
- shadow_ban
|
5
|
+
- remove_shadow_ban
|
6
|
+
- Add support for pinning messages
|
7
|
+
- pin_message
|
8
|
+
- unpin_message
|
9
|
+
- Add support for partial updating messages
|
10
|
+
- update_message_partial
|
11
|
+
- Add support for updating channel ownership for Deleted Users
|
12
|
+
|
13
|
+
## November 1st, 2021 - 2.12.0
|
14
|
+
|
15
|
+
- Add support for async endpoints
|
16
|
+
- get_task
|
17
|
+
- delete_channels
|
18
|
+
- delete_users
|
19
|
+
|
20
|
+
## October 22nd, 2021 - 2.11.3
|
21
|
+
|
22
|
+
- Don't log the entire response when creating exception
|
23
|
+
- Access error details through StreamAPIException class attr_readers
|
24
|
+
|
25
|
+
## October 5th, 2021 - 2.11.2
|
26
|
+
|
27
|
+
- Add Codeowners file
|
28
|
+
- Fix StreamChannelException raises
|
29
|
+
- Fix rubocop linting error
|
30
|
+
- Fix channel export test
|
31
|
+
- Update Github action
|
32
|
+
|
1
33
|
## August 23rd, 2021 - 2.11.1
|
2
34
|
|
3
35
|
- Use edge as base url
|
data/lib/stream-chat/channel.rb
CHANGED
@@ -19,7 +19,7 @@ module StreamChat
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def url
|
22
|
-
raise StreamChannelException 'channel does not have an id' if @id.nil?
|
22
|
+
raise StreamChannelException, 'channel does not have an id' if @id.nil?
|
23
23
|
|
24
24
|
"channels/#{@channel_type}/#{@id}"
|
25
25
|
end
|
@@ -85,7 +85,7 @@ module StreamChat
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def update_partial(set = nil, unset = nil)
|
88
|
-
raise StreamChannelException 'set or unset is needed' if set.nil? && unset.nil?
|
88
|
+
raise StreamChannelException, 'set or unset is needed' if set.nil? && unset.nil?
|
89
89
|
|
90
90
|
payload = { set: set, unset: unset }
|
91
91
|
@client.patch(url, data: payload)
|
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
|
@@ -293,6 +330,18 @@ module StreamChat
|
|
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 })
|
@@ -413,7 +462,7 @@ module StreamChat
|
|
413
462
|
headers['Authorization'] = @auth_token
|
414
463
|
headers['stream-auth-type'] = 'jwt'
|
415
464
|
url = [@base_url, relative_url].join('/')
|
416
|
-
params =
|
465
|
+
params = {} if params.nil?
|
417
466
|
params = (get_default_params.merge(params).sort_by { |k, _v| k.to_s }).to_h
|
418
467
|
url = "#{url}?#{URI.encode_www_form(params)}"
|
419
468
|
|
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.13.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-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -86,6 +86,7 @@ executables: []
|
|
86
86
|
extensions: []
|
87
87
|
extra_rdoc_files: []
|
88
88
|
files:
|
89
|
+
- ".github/CODEOWNERS"
|
89
90
|
- ".github/workflows/ci.yml"
|
90
91
|
- ".gitignore"
|
91
92
|
- ".rubocop.yml"
|
@@ -104,7 +105,8 @@ files:
|
|
104
105
|
- stream-chat.gemspec
|
105
106
|
homepage: http://github.com/GetStream/stream-chat-ruby
|
106
107
|
licenses: []
|
107
|
-
metadata:
|
108
|
+
metadata:
|
109
|
+
rubygems_mfa_required: 'true'
|
108
110
|
post_install_message:
|
109
111
|
rdoc_options: []
|
110
112
|
require_paths:
|
@@ -120,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
122
|
- !ruby/object:Gem::Version
|
121
123
|
version: '0'
|
122
124
|
requirements: []
|
123
|
-
rubygems_version: 3.
|
125
|
+
rubygems_version: 3.0.3
|
124
126
|
signing_key:
|
125
127
|
specification_version: 4
|
126
128
|
summary: The low level client for serverside calls for Stream Chat.
|