stream-chat-ruby 2.8.0 → 2.11.1

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: 6bd69ddcd8703b0afb1c93208ed7c42112f3daaa6b61e2d80ab86606be615151
4
- data.tar.gz: acd7af4d4b43ed330b6bd7f95a73b4aff60593d52cf9133032e9e1b4adc66736
3
+ metadata.gz: 94aa7ad5ea3a88c5bf5e20cf49d5d73379df7a2b6944565e7dd853fe026f6b6c
4
+ data.tar.gz: 84a37542aa8790e4f328aff6f5c748eef76df32d0f23404ff5e487453e10681d
5
5
  SHA512:
6
- metadata.gz: 765c5deea378177673be188e11eefb4da985597459922b6043df2c6701f8637312f2c9c77848ab2b07f77747840ca586032a8eda442ded7b043616419e2f39d0
7
- data.tar.gz: fc9300507e09e346b7bdaacf0dd0754f5ecf3c054140ed1409082eb009dec5efba880675ef1c464ce3450f8d5a15ff5cec2ba6223db63dce376417b1c5119379
6
+ metadata.gz: 7daa874596aabbe29e2cfa48d530c396e686ba949477f9212eb21d080f28f5ba1e6d8a28f1524121a315a3c5f15d6d64da9ef3ff96c2209d4fa57e5386433127
7
+ data.tar.gz: 35f6745c799556c623541922c8bb8863b4b93469eb57d69662b3c3525c46cdeae3fb3fef6731f5cf633996fdb1ed5c8d902b7a2bf20d43e4fd81e820d114a1c1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## August 23rd, 2021 - 2.11.1
2
+
3
+ - Use edge as base url
4
+
5
+ ## June 25th, 2021 - 2.11.0
6
+
7
+ - Add support for improved search
8
+
9
+ ## June 4th, 2021 - 2.10.0
10
+
11
+ - Add custom command CRUD support
12
+
13
+ ## May 31st, 2021 - 2.9.0
14
+
15
+ - Add support for app and user level token revoke
16
+
1
17
  ## May 21st, 2021 - 2.8.0
2
18
 
3
19
  - Add query message flags support
@@ -4,6 +4,7 @@
4
4
  require 'open-uri'
5
5
  require 'faraday'
6
6
  require 'jwt'
7
+ require 'time'
7
8
  require 'stream-chat/channel'
8
9
  require 'stream-chat/errors'
9
10
  require 'stream-chat/version'
@@ -13,7 +14,7 @@ module StreamChat
13
14
  DEFAULT_BLOCKLIST = 'profanity_en_2020_v1'
14
15
 
15
16
  class Client
16
- BASE_URL = 'https://chat-us-east-1.stream-io-api.com'
17
+ BASE_URL = 'https://chat.stream-io-api.com'
17
18
 
18
19
  attr_reader :api_key
19
20
  attr_reader :api_secret
@@ -45,9 +46,10 @@ module StreamChat
45
46
  end
46
47
  end
47
48
 
48
- def create_token(user_id, exp = nil)
49
+ def create_token(user_id, exp = nil, iat = nil)
49
50
  payload = { user_id: user_id }
50
51
  payload['exp'] = exp unless exp.nil?
52
+ payload['iat'] = iat unless iat.nil?
51
53
  JWT.encode(payload, @api_secret, 'HS256')
52
54
  end
53
55
 
@@ -90,13 +92,21 @@ module StreamChat
90
92
  get("messages/#{id}")
91
93
  end
92
94
 
93
- def search(filter_conditions, query, **options)
94
- params = options.merge({
95
- filter_conditions: filter_conditions,
96
- query: query
97
- })
95
+ def search(filter_conditions, query, sort: nil, **options)
96
+ offset = options[:offset]
97
+ next_value = options[:next]
98
+ raise ArgumentError, 'cannot use offset with next or sort parameters' if offset&.positive? && (next_value || (!sort.nil? && !sort.empty?))
98
99
 
99
- get('search', params: { payload: params.to_json })
100
+ to_merge = {
101
+ filter_conditions: filter_conditions,
102
+ sort: get_sort_fields(sort)
103
+ }
104
+ if query.is_a? String
105
+ to_merge[:query] = query
106
+ else
107
+ to_merge[:message_filter_conditions] = query
108
+ end
109
+ get('search', params: { payload: options.merge(to_merge).to_json })
100
110
  end
101
111
 
102
112
  def update_users(users)
@@ -283,6 +293,30 @@ module StreamChat
283
293
  get("export_channels/#{task_id}")
284
294
  end
285
295
 
296
+ def revoke_tokens(before)
297
+ before = before.rfc3339 if before.instance_of?(DateTime)
298
+ update_app_settings({ 'revoke_tokens_issued_before' => before })
299
+ end
300
+
301
+ def revoke_user_token(user_id, before)
302
+ revoke_users_token([user_id], before)
303
+ end
304
+
305
+ def revoke_users_token(user_ids, before)
306
+ before = before.rfc3339 if before.instance_of?(DateTime)
307
+
308
+ updates = []
309
+ user_ids.each do |user_id|
310
+ updates.push({
311
+ 'id' => user_id,
312
+ 'set' => {
313
+ 'revoke_tokens_issued_before' => before
314
+ }
315
+ })
316
+ end
317
+ update_users_partial(updates)
318
+ end
319
+
286
320
  def put(relative_url, params: nil, data: nil)
287
321
  make_http_request(:put, relative_url, params: params, data: data)
288
322
  end
@@ -326,6 +360,26 @@ module StreamChat
326
360
  post('check_sqs', data: { sqs_key: sqs_key, sqs_secret: sqs_secret, sqs_url: sqs_url })
327
361
  end
328
362
 
363
+ def create_command(command)
364
+ post('commands', data: command)
365
+ end
366
+
367
+ def get_command(name)
368
+ get("commands/#{name}")
369
+ end
370
+
371
+ def update_command(name, command)
372
+ put("commands/#{name}", data: command)
373
+ end
374
+
375
+ def delete_command(name)
376
+ delete("commands/#{name}")
377
+ end
378
+
379
+ def list_commands
380
+ get('commands')
381
+ end
382
+
329
383
  private
330
384
 
331
385
  def get_default_params
@@ -338,8 +392,8 @@ module StreamChat
338
392
 
339
393
  def get_default_headers
340
394
  {
341
- "Content-Type": 'application/json',
342
- "X-Stream-Client": get_user_agent
395
+ 'Content-Type': 'application/json',
396
+ 'X-Stream-Client': get_user_agent
343
397
  }
344
398
  end
345
399
 
@@ -3,5 +3,5 @@
3
3
  # lib/version.rb
4
4
 
5
5
  module StreamChat
6
- VERSION = '2.8.0'
6
+ VERSION = '2.11.1'
7
7
  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.8.0
4
+ version: 2.11.1
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-05-21 00:00:00.000000000 Z
11
+ date: 2021-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday