stream-chat-ruby 2.17.2 → 2.18.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/CHANGELOG.md +8 -0
- data/README.md +8 -1
- data/lib/stream-chat/channel.rb +15 -0
- data/lib/stream-chat/client.rb +34 -5
- data/lib/stream-chat/stream_rate_limits.rb +17 -0
- data/lib/stream-chat/stream_response.rb +28 -0
- data/lib/stream-chat/version.rb +1 -1
- data/stream-chat.gemspec +2 -2
- metadata +5 -8
- data/.github/CODEOWNERS +0 -1
- data/.github/workflows/ci.yml +0 -33
- data/.github/workflows/initiate_release.yml +0 -47
- data/.github/workflows/release.yml +0 -40
- data/scripts/get_changelog_diff.js +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af3ba47a48c7b729201b5db3401986f5d45007030b4caa86053399f5faf12aba
|
4
|
+
data.tar.gz: ba8243a507b81682a5f283f09e5075dd21a9c345c9043c8bf118ea423db1a1da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b004af8b95616a958803f632a434ae0ac1a6cd7504725faeceb76a2b27e75cdee45541ad876f598dc465ff02edee5662f4521437a9a74c5db3ef84c08dee6845
|
7
|
+
data.tar.gz: ca7d458fe80c3417f4058e7c876ea4984818e3c0b072f4bedd962f96a5b556d7835a36748f5da9e1ed968fe52e8711ca2c4011b463eec4108590d9b384ecb047
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
4
4
|
|
5
|
+
## [2.18.0](https://github.com/GetStream/stream-chat-ruby/compare/v2.17.2...v2.18.0) (2022-01-26)
|
6
|
+
|
7
|
+
|
8
|
+
### Features
|
9
|
+
|
10
|
+
* expose rate limits ([#72](https://github.com/GetStream/stream-chat-ruby/issues/72)) ([3f1ad5c](https://github.com/GetStream/stream-chat-ruby/commit/3f1ad5c8f43263424e934055d0ac283cdcce9376))
|
11
|
+
* full feature parity ([#71](https://github.com/GetStream/stream-chat-ruby/issues/71)) ([a25a1b6](https://github.com/GetStream/stream-chat-ruby/commit/a25a1b66f9eadd77d09b99d5c3cfba27bba52f17))
|
12
|
+
|
5
13
|
### [2.17.2](https://github.com/GetStream/stream-chat-ruby/compare/v2.17.1...v2.17.2) (2022-01-17)
|
6
14
|
|
7
15
|
### Features
|
data/README.md
CHANGED
@@ -213,7 +213,7 @@ See [an example rails application using the Ruby SDK](https://github.com/GetStre
|
|
213
213
|
First, make sure you can run the test suite. Tests are run via rspec
|
214
214
|
|
215
215
|
```bash
|
216
|
-
|
216
|
+
STREAM_KEY=my_api_key STREAM_SECRET=my_api_secret bundle exec rake spec
|
217
217
|
```
|
218
218
|
|
219
219
|
This repository follows a commit message convention in order to automatically generate the [CHANGELOG](./CHANGELOG.md). Make sure you follow the rules of [conventional commits](https://www.conventionalcommits.org/) when opening a pull request.
|
@@ -229,3 +229,10 @@ The job creates a pull request with the changelog. Check if it looks good.
|
|
229
229
|
- Merge the pull request.
|
230
230
|
|
231
231
|
Once the PR is merged, it automatically kicks off another job which will upload the Gem to RubyGems.org and creates a GitHub release.
|
232
|
+
|
233
|
+
## We are hiring!
|
234
|
+
|
235
|
+
We've recently closed a [$38 million Series B funding round](https://techcrunch.com/2021/03/04/stream-raises-38m-as-its-chat-and-activity-feed-apis-power-communications-for-1b-users/) and we keep actively growing.
|
236
|
+
Our APIs are used by more than a billion end-users, and you'll have a chance to make a huge impact on the product within a team of the strongest engineers all over the world.
|
237
|
+
|
238
|
+
Check out our current openings and apply via [Stream's website](https://getstream.io/team/#jobs).
|
data/lib/stream-chat/channel.rb
CHANGED
@@ -13,6 +13,7 @@ module StreamChat
|
|
13
13
|
def initialize(client, channel_type, channel_id = nil, custom_data = nil)
|
14
14
|
@channel_type = channel_type
|
15
15
|
@id = channel_id
|
16
|
+
@cid = "#{@channel_type}:#{@id}"
|
16
17
|
@client = client
|
17
18
|
@custom_data = custom_data
|
18
19
|
@custom_data = {} if @custom_data.nil?
|
@@ -24,6 +25,10 @@ module StreamChat
|
|
24
25
|
"channels/#{@channel_type}/#{@id}"
|
25
26
|
end
|
26
27
|
|
28
|
+
def get_messages(message_ids)
|
29
|
+
@client.get("#{url}/messages", params: { 'ids' => message_ids.join(',') })
|
30
|
+
end
|
31
|
+
|
27
32
|
def send_message(message, user_id)
|
28
33
|
payload = { message: add_user_id(message, user_id) }
|
29
34
|
@client.post("#{url}/message", data: payload)
|
@@ -99,6 +104,16 @@ module StreamChat
|
|
99
104
|
@client.post("#{url}/truncate", data: options)
|
100
105
|
end
|
101
106
|
|
107
|
+
def mute(user_id, expiration = nil)
|
108
|
+
data = { user_id: user_id, channel_cid: @cid }
|
109
|
+
data['expiration'] = expiration if expiration
|
110
|
+
@client.post('moderation/mute/channel', data: data)
|
111
|
+
end
|
112
|
+
|
113
|
+
def unmute(user_id)
|
114
|
+
@client.post('moderation/unmute/channel', data: { 'user_id' => user_id, 'channel_cid' => @cid })
|
115
|
+
end
|
116
|
+
|
102
117
|
def add_members(user_ids, **options)
|
103
118
|
payload = options.merge({ add_members: user_ids })
|
104
119
|
@client.post(url, data: payload)
|
data/lib/stream-chat/client.rb
CHANGED
@@ -8,6 +8,7 @@ require 'jwt'
|
|
8
8
|
require 'time'
|
9
9
|
require 'stream-chat/channel'
|
10
10
|
require 'stream-chat/errors'
|
11
|
+
require 'stream-chat/stream_response'
|
11
12
|
require 'stream-chat/version'
|
12
13
|
require 'stream-chat/util'
|
13
14
|
|
@@ -35,12 +36,12 @@ module StreamChat
|
|
35
36
|
# StreamChat::Client.new('my_key', 'my_secret', 3.0)
|
36
37
|
#
|
37
38
|
def initialize(api_key = '', api_secret = '', timeout = 6.0, **options)
|
38
|
-
@api_key = api_key
|
39
|
-
@api_secret = api_secret
|
40
|
-
@timeout = timeout
|
39
|
+
@api_key = api_key || ENV['STREAM_KEY']
|
40
|
+
@api_secret = api_secret || ENV['STREAM_SECRET']
|
41
|
+
@timeout = timeout || ENV['STREAM_CHAT_TIMEOUT']
|
41
42
|
@options = options
|
42
43
|
@auth_token = JWT.encode({ server: true }, @api_secret, 'HS256')
|
43
|
-
@base_url = options[:base_url] || BASE_URL
|
44
|
+
@base_url = options[:base_url] || ENV['STREAM_CHAT_URL'] || BASE_URL
|
44
45
|
@conn = Faraday.new(url: @base_url) do |faraday|
|
45
46
|
faraday.options[:open_timeout] = @timeout
|
46
47
|
faraday.options[:timeout] = @timeout
|
@@ -221,6 +222,14 @@ module StreamChat
|
|
221
222
|
delete("messages/#{message_id}")
|
222
223
|
end
|
223
224
|
|
225
|
+
def query_banned_users(filter_conditions, sort: nil, **options)
|
226
|
+
params = options.merge({
|
227
|
+
filter_conditions: filter_conditions,
|
228
|
+
sort: get_sort_fields(sort)
|
229
|
+
})
|
230
|
+
get('query_banned_users', params: { payload: params.to_json })
|
231
|
+
end
|
232
|
+
|
224
233
|
def query_users(filter_conditions, sort: nil, **options)
|
225
234
|
params = options.merge({
|
226
235
|
filter_conditions: filter_conditions,
|
@@ -303,6 +312,22 @@ module StreamChat
|
|
303
312
|
signature == x_signature
|
304
313
|
end
|
305
314
|
|
315
|
+
def send_user_event(user_id, event)
|
316
|
+
post("users/#{user_id}/event", data: event)
|
317
|
+
end
|
318
|
+
|
319
|
+
def translate_message(message_id, language)
|
320
|
+
post("messages/#{message_id}/translate", data: { language: language })
|
321
|
+
end
|
322
|
+
|
323
|
+
def run_message_action(message_id, data)
|
324
|
+
post("messages/#{message_id}/action", data: data)
|
325
|
+
end
|
326
|
+
|
327
|
+
def create_guest(user)
|
328
|
+
post('guests', data: user)
|
329
|
+
end
|
330
|
+
|
306
331
|
def list_blocklists
|
307
332
|
get('blocklists')
|
308
333
|
end
|
@@ -405,6 +430,10 @@ module StreamChat
|
|
405
430
|
parse_response(response)
|
406
431
|
end
|
407
432
|
|
433
|
+
def check_push(push_data)
|
434
|
+
post('check_push', data: push_data)
|
435
|
+
end
|
436
|
+
|
408
437
|
def check_sqs(sqs_key = nil, sqs_secret = nil, sqs_url = nil)
|
409
438
|
post('check_sqs', data: { sqs_key: sqs_key, sqs_secret: sqs_secret, sqs_url: sqs_url })
|
410
439
|
end
|
@@ -486,7 +515,7 @@ module StreamChat
|
|
486
515
|
end
|
487
516
|
raise StreamAPIException, response if response.status >= 399
|
488
517
|
|
489
|
-
parsed_result
|
518
|
+
StreamResponse.new(parsed_result, response)
|
490
519
|
end
|
491
520
|
|
492
521
|
def make_http_request(method, relative_url, params: nil, data: nil)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# lib/stream_rate_limits.rb
|
4
|
+
|
5
|
+
module StreamChat
|
6
|
+
class StreamRateLimits
|
7
|
+
attr_reader :limit
|
8
|
+
attr_reader :remaining
|
9
|
+
attr_reader :reset
|
10
|
+
|
11
|
+
def initialize(limit, remaining, reset)
|
12
|
+
@limit = limit.to_i
|
13
|
+
@remaining = remaining.to_i
|
14
|
+
@reset = Time.at(reset.to_i)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# lib/stream_response.rb
|
4
|
+
require 'stream-chat/stream_rate_limits'
|
5
|
+
|
6
|
+
module StreamChat
|
7
|
+
class StreamResponse < Hash
|
8
|
+
attr_reader :rate_limit
|
9
|
+
attr_reader :status_code
|
10
|
+
attr_reader :headers
|
11
|
+
|
12
|
+
def initialize(hash, response)
|
13
|
+
super(nil)
|
14
|
+
merge!(hash)
|
15
|
+
|
16
|
+
if response.headers.key?('X-Ratelimit-Limit')
|
17
|
+
@rate_limit = StreamRateLimits.new(
|
18
|
+
response.headers['X-Ratelimit-Limit'],
|
19
|
+
response.headers['X-Ratelimit-Remaining'],
|
20
|
+
response.headers['X-Ratelimit-Reset']
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
@status_code = response.status
|
25
|
+
@headers = response.headers
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/stream-chat/version.rb
CHANGED
data/stream-chat.gemspec
CHANGED
@@ -12,9 +12,9 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.summary = 'The low level client for serverside calls for Stream Chat.'
|
13
13
|
gem.email = 'support@getstream.io'
|
14
14
|
gem.homepage = 'http://github.com/GetStream/stream-chat-ruby'
|
15
|
-
gem.authors = ['
|
15
|
+
gem.authors = ['getstream.io']
|
16
16
|
gem.files = Dir.chdir(File.expand_path(__dir__)) do
|
17
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|
|
17
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|\.github|scripts)/}) }
|
18
18
|
end
|
19
19
|
gem.required_ruby_version = '>=2.5.0'
|
20
20
|
gem.metadata = {
|
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.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- getstream.io
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -100,10 +100,6 @@ executables: []
|
|
100
100
|
extensions: []
|
101
101
|
extra_rdoc_files: []
|
102
102
|
files:
|
103
|
-
- ".github/CODEOWNERS"
|
104
|
-
- ".github/workflows/ci.yml"
|
105
|
-
- ".github/workflows/initiate_release.yml"
|
106
|
-
- ".github/workflows/release.yml"
|
107
103
|
- ".gitignore"
|
108
104
|
- ".rubocop.yml"
|
109
105
|
- ".versionrc.js"
|
@@ -117,9 +113,10 @@ files:
|
|
117
113
|
- lib/stream-chat/channel.rb
|
118
114
|
- lib/stream-chat/client.rb
|
119
115
|
- lib/stream-chat/errors.rb
|
116
|
+
- lib/stream-chat/stream_rate_limits.rb
|
117
|
+
- lib/stream-chat/stream_response.rb
|
120
118
|
- lib/stream-chat/util.rb
|
121
119
|
- lib/stream-chat/version.rb
|
122
|
-
- scripts/get_changelog_diff.js
|
123
120
|
- stream-chat.gemspec
|
124
121
|
homepage: http://github.com/GetStream/stream-chat-ruby
|
125
122
|
licenses: []
|
data/.github/CODEOWNERS
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
* @ffenix113
|
data/.github/workflows/ci.yml
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
name: test
|
2
|
-
|
3
|
-
on: [pull_request]
|
4
|
-
|
5
|
-
jobs:
|
6
|
-
test:
|
7
|
-
runs-on: ubuntu-latest
|
8
|
-
strategy:
|
9
|
-
max-parallel: 1
|
10
|
-
matrix:
|
11
|
-
ruby: ['2.5', '2.6', '2.7', '3.0', '3.1']
|
12
|
-
name: 💎 Ruby ${{ matrix.ruby }}
|
13
|
-
steps:
|
14
|
-
- uses: actions/checkout@v2
|
15
|
-
with:
|
16
|
-
fetch-depth: 0 # gives the commit linter access to previous commits
|
17
|
-
|
18
|
-
- name: Commit message linter
|
19
|
-
if: ${{ matrix.ruby == '2.5' }}
|
20
|
-
uses: wagoid/commitlint-github-action@v4
|
21
|
-
|
22
|
-
- uses: ruby/setup-ruby@v1
|
23
|
-
with:
|
24
|
-
ruby-version: ${{ matrix.ruby }}
|
25
|
-
bundler-cache: true
|
26
|
-
|
27
|
-
- run: bundle exec rake rubocop
|
28
|
-
|
29
|
-
- run: bundle exec rake test
|
30
|
-
env:
|
31
|
-
STREAM_CHAT_API_KEY: ${{ secrets.STREAM_CHAT_API_KEY }}
|
32
|
-
STREAM_CHAT_API_SECRET: ${{ secrets.STREAM_CHAT_API_SECRET }}
|
33
|
-
STREAM_CHAT_API_HOST: ${{ secrets.STREAM_CHAT_API_HOST }}
|
@@ -1,47 +0,0 @@
|
|
1
|
-
name: Create release PR
|
2
|
-
|
3
|
-
on:
|
4
|
-
workflow_dispatch:
|
5
|
-
inputs:
|
6
|
-
version:
|
7
|
-
description: "The new version number with 'v' prefix. Example: v1.40.1"
|
8
|
-
required: true
|
9
|
-
|
10
|
-
jobs:
|
11
|
-
init_release:
|
12
|
-
name: 🚀 Create release PR
|
13
|
-
runs-on: ubuntu-latest
|
14
|
-
steps:
|
15
|
-
- uses: actions/checkout@v2
|
16
|
-
with:
|
17
|
-
fetch-depth: 0 # gives the changelog generator access to all previous commits
|
18
|
-
|
19
|
-
- name: Update CHANGELOG.md, version.rb and push release branch
|
20
|
-
env:
|
21
|
-
VERSION: ${{ github.event.inputs.version }}
|
22
|
-
run: |
|
23
|
-
npx --yes standard-version@9.3.2 --release-as "$VERSION" --skip.tag --skip.commit --tag-prefix=v
|
24
|
-
git config --global user.name 'github-actions'
|
25
|
-
git config --global user.email 'release@getstream.io'
|
26
|
-
git checkout -q -b "release-$VERSION"
|
27
|
-
git commit -am "chore(release): $VERSION"
|
28
|
-
git push -q -u origin "release-$VERSION"
|
29
|
-
|
30
|
-
- name: Get changelog diff
|
31
|
-
uses: actions/github-script@v5
|
32
|
-
with:
|
33
|
-
script: |
|
34
|
-
const get_change_log_diff = require('./scripts/get_changelog_diff.js')
|
35
|
-
core.exportVariable('CHANGELOG', get_change_log_diff())
|
36
|
-
|
37
|
-
- name: Open pull request
|
38
|
-
env:
|
39
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
40
|
-
run: |
|
41
|
-
gh pr create \
|
42
|
-
-t "Release ${{ github.event.inputs.version }}" \
|
43
|
-
-b "# :rocket: ${{ github.event.inputs.version }}
|
44
|
-
Make sure to use squash & merge when merging!
|
45
|
-
Once this is merged, another job will kick off automatically and publish the package.
|
46
|
-
# :memo: Changelog
|
47
|
-
${{ env.CHANGELOG }}"
|
@@ -1,40 +0,0 @@
|
|
1
|
-
name: Release
|
2
|
-
|
3
|
-
on:
|
4
|
-
pull_request:
|
5
|
-
types: [closed]
|
6
|
-
branches:
|
7
|
-
- master
|
8
|
-
|
9
|
-
jobs:
|
10
|
-
Release:
|
11
|
-
name: 🚀 Release
|
12
|
-
if: github.event.pull_request.merged && startsWith(github.head_ref, 'release-')
|
13
|
-
runs-on: ubuntu-latest
|
14
|
-
steps:
|
15
|
-
- uses: actions/checkout@v2
|
16
|
-
with:
|
17
|
-
fetch-depth: 0
|
18
|
-
|
19
|
-
- uses: actions/github-script@v5
|
20
|
-
with:
|
21
|
-
script: |
|
22
|
-
const get_change_log_diff = require('./scripts/get_changelog_diff.js')
|
23
|
-
core.exportVariable('CHANGELOG', get_change_log_diff())
|
24
|
-
|
25
|
-
// Getting the release version from the PR source branch
|
26
|
-
// Source branch looks like this: release-1.0.0
|
27
|
-
const version = context.payload.pull_request.head.ref.split('-')[1]
|
28
|
-
core.exportVariable('VERSION', version)
|
29
|
-
|
30
|
-
- name: Publish gem
|
31
|
-
uses: dawidd6/action-publish-gem@v1
|
32
|
-
with:
|
33
|
-
api_key: ${{secrets.RUBYGEMS_API_KEY}}
|
34
|
-
|
35
|
-
- name: Create release on GitHub
|
36
|
-
uses: ncipollo/release-action@v1
|
37
|
-
with:
|
38
|
-
body: ${{ env.CHANGELOG }}
|
39
|
-
tag: ${{ env.VERSION }}
|
40
|
-
token: ${{ secrets.GITHUB_TOKEN }}
|
@@ -1,26 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
Here we're trying to parse the latest changes from CHANGELOG.md file.
|
3
|
-
The changelog looks like this:
|
4
|
-
|
5
|
-
## 0.0.3
|
6
|
-
- Something #3
|
7
|
-
## 0.0.2
|
8
|
-
- Something #2
|
9
|
-
## 0.0.1
|
10
|
-
- Something #1
|
11
|
-
|
12
|
-
In this case we're trying to extract "- Something #3" since that's the latest change.
|
13
|
-
*/
|
14
|
-
module.exports = () => {
|
15
|
-
const fs = require('fs')
|
16
|
-
|
17
|
-
changelog = fs.readFileSync('CHANGELOG.md', 'utf8')
|
18
|
-
releases = changelog.match(/## [?[0-9](.+)/g)
|
19
|
-
|
20
|
-
current_release = changelog.indexOf(releases[0])
|
21
|
-
previous_release = changelog.indexOf(releases[1])
|
22
|
-
|
23
|
-
latest_changes = changelog.substr(current_release, previous_release - current_release)
|
24
|
-
|
25
|
-
return latest_changes
|
26
|
-
}
|