stream-chat-ruby 2.13.0 → 2.17.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d913a2d883a67d7e06afd1e57febfb5565cbcd23d69249e101f72163084f7b96
4
- data.tar.gz: af4374cd74b9789c5751f6569e9317e46289207daa6a72eea0e53a20ad3ee43f
3
+ metadata.gz: b89ec4be90e50aefec0c944f7dcd33ea5cca18b709f431467f20e44a303b7bfe
4
+ data.tar.gz: a94ca94e1c4144f9bdc699d694a55f88ab1a1f46306941ffa912573af45a2bb7
5
5
  SHA512:
6
- metadata.gz: 5c7ed7f7f94d009b4e3a091942f6b59cfa14087d02ba4b2659e18755dbb62a8bbe471e0497ce46a113598fd1e36aa2c7a3749f4ca3505f6f18e28a8d2ca3e663
7
- data.tar.gz: 4c0dbed5b2230c4ce9fb3b8630f6d8fa72dd58097b35b12d78a6b355635cd7d9b0b63e38e1b011b57d7ce647fb271b0b225977e02c35718d549fc9d9c9ad7da3
6
+ metadata.gz: b9a030a478585db63eaccc77cfe5375610afe83c2a4858f6e5f3965ad0802f08a2eba9a949f66bc3bf7e89dd8b8211098d782e9096b83b1ed946a3a113704d72
7
+ data.tar.gz: b7d4e530a4a5599fce27c56d18b2689980a5aae0153290aa0065bf9e2efde674555693c3ebfb19a27eeba28f238b80814b5679afb8fb81dd1c0062a0ec0d46bd
@@ -8,18 +8,26 @@ jobs:
8
8
  strategy:
9
9
  max-parallel: 1
10
10
  matrix:
11
- ruby: ['2.5', '2.6', '2.7', '3.0']
12
- name: Ruby ${{ matrix.ruby }}
11
+ ruby: ['2.5', '2.6', '2.7', '3.0', '3.1']
12
+ name: 💎 Ruby ${{ matrix.ruby }}
13
13
  steps:
14
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
+
15
22
  - uses: ruby/setup-ruby@v1
16
23
  with:
17
24
  ruby-version: ${{ matrix.ruby }}
18
25
  bundler-cache: true
19
26
 
20
- - env:
27
+ - run: bundle exec rake rubocop
28
+
29
+ - run: bundle exec rake test
30
+ env:
21
31
  STREAM_CHAT_API_KEY: ${{ secrets.STREAM_CHAT_API_KEY }}
22
32
  STREAM_CHAT_API_SECRET: ${{ secrets.STREAM_CHAT_API_SECRET }}
23
- run: |
24
- bundle exec rake rubocop
25
- bundle exec rake test
33
+ STREAM_CHAT_API_HOST: ${{ secrets.STREAM_CHAT_API_HOST }}
@@ -0,0 +1,47 @@
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 }}"
@@ -0,0 +1,40 @@
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 }}
data/.gitignore CHANGED
@@ -9,6 +9,7 @@
9
9
  /test/tmp/
10
10
  /test/version_tmp/
11
11
  /tmp/
12
+ .vscode
12
13
 
13
14
  # Used by dotenv library to load environment variables.
14
15
  # .env
@@ -43,7 +44,7 @@ build-iPhoneSimulator/
43
44
  # for a library or gem, you might want to ignore these files since the code is
44
45
  # intended to run in multiple environments; otherwise, check them in:
45
46
  Gemfile.lock
46
- # .ruby-version
47
+ .ruby-version
47
48
  # .ruby-gemset
48
49
 
49
50
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
data/.rubocop.yml CHANGED
@@ -21,9 +21,6 @@ Metrics/MethodLength:
21
21
  Naming/AccessorMethodName:
22
22
  Enabled: false
23
23
 
24
- Security/Open:
25
- Enabled: false
26
-
27
24
  Style/AccessorGrouping:
28
25
  Enabled: false
29
26
  Style/Documentation:
@@ -32,3 +29,6 @@ Style/DoubleCopDisableDirective:
32
29
  Enabled: false
33
30
  Style/FrozenStringLiteralComment:
34
31
  Enabled: false
32
+
33
+ Gemspec/RequireMFA:
34
+ Enabled: false
data/.versionrc.js ADDED
@@ -0,0 +1,16 @@
1
+ const versionFileUpdater = {
2
+ VERSION_REGEX: /VERSION = '(.+)'/,
3
+
4
+ readVersion: function (contents) {
5
+ const version = this.VERSION_REGEX.exec(contents)[1];
6
+ return version;
7
+ },
8
+
9
+ writeVersion: function (contents, version) {
10
+ return contents.replace(this.VERSION_REGEX.exec(contents)[0], `VERSION = '${version}'`);
11
+ }
12
+ }
13
+
14
+ module.exports = {
15
+ bumpFiles: [{ filename: './lib/stream-chat/version.rb', updater: versionFileUpdater }],
16
+ }
data/CHANGELOG.md CHANGED
@@ -1,3 +1,32 @@
1
+ # Changelog
2
+
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
+
5
+ ## [2.17.0](https://github.com/GetStream/stream-chat-ruby/compare/v2.16.0...v2.17.0) (2022-01-14)
6
+
7
+
8
+ ### Features
9
+
10
+ * add options to add members ([#63](https://github.com/GetStream/stream-chat-ruby/issues/63)) ([89c9fa9](https://github.com/GetStream/stream-chat-ruby/commit/89c9fa98e19565c4b5353077523a1d407e1f10c9))
11
+
12
+ ## [2.16.0](https://github.com/GetStream/stream-chat-ruby/compare/v2.15.0...v2.16.0) (2021-12-01)
13
+
14
+ - Add permissions v2 APIs by @ffenix113 in #62
15
+
16
+ ## [2.15.0](https://github.com/GetStream/stream-chat-ruby/compare/v2.14.0...v2.15.0) (2021-11-25)
17
+
18
+ - Add configuration support for channel truncate
19
+ - truncated_at: to truncate channel up to given time
20
+ - message: a system message to be added via truncation
21
+ - skip_push: don't send a push notification for system message
22
+ - hard_delete: true if truncation should delete messages instead of hiding
23
+
24
+ ## November 24th, 2021 - 2.14.0
25
+
26
+ - Add new flags for export channels
27
+ - clear_deleted_message_text (default: false)
28
+ - include_truncated_messages (default: false)
29
+
1
30
  ## November 17th, 2021 - 2.13.0
2
31
 
3
32
  - Add support for shadow banning user
data/Gemfile CHANGED
@@ -13,6 +13,7 @@ end
13
13
 
14
14
  group :test do
15
15
  gem 'faraday'
16
+ gem 'faraday-multipart'
16
17
  gem 'rack'
17
18
  gem 'simplecov'
18
19
  end
data/README.md CHANGED
@@ -14,7 +14,7 @@ Android SDK libraries (https://getstream.io/chat/).
14
14
 
15
15
  stream-chat-ruby supports:
16
16
 
17
- - Ruby (3.0, 2.7, 2.6, 2.5)
17
+ - Ruby (2.5, 2.6, 2.7, 3.0, 3.1)
18
18
 
19
19
  #### Install
20
20
 
@@ -216,12 +216,16 @@ First, make sure you can run the test suite. Tests are run via rspec
216
216
  STREAM_CHAT_API_KEY=my_api_key STREAM_CHAT_API_SECRET=my_api_secret bundle exec rake spec
217
217
  ```
218
218
 
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.
220
+
219
221
  ### Releasing a new version
220
222
 
221
223
  In order to release new version you need to be a maintainer of the library.
222
224
 
223
- - Update CHANGELOG
224
- - Update the version in `lib/stream-chat/version.rb`
225
- - Commit and push to GitHub
226
- - Build the gem with `bundle exec rake build`
227
- - Publish the gem with `bundle exec rake release`
225
+ - Kick off a job called `initiate_release` ([link](https://github.com/GetStream/stream-chat-ruby/actions/workflows/initiate_release.yml)).
226
+
227
+ The job creates a pull request with the changelog. Check if it looks good.
228
+
229
+ - Merge the pull request.
230
+
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.
@@ -95,12 +95,13 @@ module StreamChat
95
95
  @client.delete(url)
96
96
  end
97
97
 
98
- def truncate
99
- @client.post("#{url}/truncate")
98
+ def truncate(**options)
99
+ @client.post("#{url}/truncate", data: options)
100
100
  end
101
101
 
102
- def add_members(user_ids)
103
- @client.post(url, data: { add_members: user_ids })
102
+ def add_members(user_ids, **options)
103
+ payload = options.merge({ add_members: user_ids })
104
+ @client.post(url, data: payload)
104
105
  end
105
106
 
106
107
  def invite_members(user_ids)
@@ -115,6 +116,10 @@ module StreamChat
115
116
  @client.post(url, data: { remove_members: user_ids })
116
117
  end
117
118
 
119
+ def assign_roles(members, message = nil)
120
+ @client.post(url, data: { assign_roles: members, message: message })
121
+ end
122
+
118
123
  def demote_moderators(user_ids)
119
124
  @client.post(url, data: { demote_moderators: user_ids })
120
125
  end
@@ -3,6 +3,7 @@
3
3
  # lib/client.rb
4
4
  require 'open-uri'
5
5
  require 'faraday'
6
+ require 'faraday/multipart'
6
7
  require 'jwt'
7
8
  require 'time'
8
9
  require 'stream-chat/channel'
@@ -322,8 +323,8 @@ module StreamChat
322
323
  delete("blocklists/#{name}")
323
324
  end
324
325
 
325
- def export_channels(*channels)
326
- post('export_channels', data: { channels: channels })
326
+ def export_channels(*channels, **options)
327
+ post('export_channels', data: { channels: channels, **options })
327
328
  end
328
329
 
329
330
  def get_export_channel_status(task_id)
@@ -389,10 +390,9 @@ module StreamChat
389
390
  def send_file(relative_url, file_url, user, content_type = 'application/octet-stream')
390
391
  url = [@base_url, relative_url].join('/')
391
392
 
392
- file = open(file_url)
393
393
  body = { user: user.to_json }
394
394
 
395
- body[:file] = Faraday::UploadIO.new(file, content_type)
395
+ body[:file] = Faraday::UploadIO.new(file_url, content_type)
396
396
 
397
397
  response = @conn.post url do |req|
398
398
  req.headers['X-Stream-Client'] = get_user_agent
@@ -429,6 +429,38 @@ module StreamChat
429
429
  get('commands')
430
430
  end
431
431
 
432
+ def list_permissions
433
+ get('permissions')
434
+ end
435
+
436
+ def get_permission(id)
437
+ get("permissions/#{id}")
438
+ end
439
+
440
+ def create_permission(permission)
441
+ post('permissions', data: permission)
442
+ end
443
+
444
+ def update_permission(id, permission)
445
+ put("permissions/#{id}", data: permission)
446
+ end
447
+
448
+ def delete_permission(id)
449
+ delete("permissions/#{id}")
450
+ end
451
+
452
+ def create_role(name)
453
+ post('roles', data: { name: name })
454
+ end
455
+
456
+ def delete_role(name)
457
+ delete("roles/#{name}")
458
+ end
459
+
460
+ def list_roles
461
+ get('roles')
462
+ end
463
+
432
464
  private
433
465
 
434
466
  def get_default_params
@@ -3,5 +3,5 @@
3
3
  # lib/version.rb
4
4
 
5
5
  module StreamChat
6
- VERSION = '2.13.0'
6
+ VERSION = '2.17.0'
7
7
  end
@@ -0,0 +1,26 @@
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
+ }
data/stream-chat.gemspec CHANGED
@@ -23,5 +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
+ gem.metadata['rubygems_mfa_required'] = 'false'
27
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.13.0
4
+ version: 2.17.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-17 00:00:00.000000000 Z
11
+ date: 2022-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -88,8 +88,11 @@ extra_rdoc_files: []
88
88
  files:
89
89
  - ".github/CODEOWNERS"
90
90
  - ".github/workflows/ci.yml"
91
+ - ".github/workflows/initiate_release.yml"
92
+ - ".github/workflows/release.yml"
91
93
  - ".gitignore"
92
94
  - ".rubocop.yml"
95
+ - ".versionrc.js"
93
96
  - CHANGELOG.md
94
97
  - Gemfile
95
98
  - LICENSE
@@ -102,11 +105,12 @@ files:
102
105
  - lib/stream-chat/errors.rb
103
106
  - lib/stream-chat/util.rb
104
107
  - lib/stream-chat/version.rb
108
+ - scripts/get_changelog_diff.js
105
109
  - stream-chat.gemspec
106
110
  homepage: http://github.com/GetStream/stream-chat-ruby
107
111
  licenses: []
108
112
  metadata:
109
- rubygems_mfa_required: 'true'
113
+ rubygems_mfa_required: 'false'
110
114
  post_install_message:
111
115
  rdoc_options: []
112
116
  require_paths:
@@ -122,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
126
  - !ruby/object:Gem::Version
123
127
  version: '0'
124
128
  requirements: []
125
- rubygems_version: 3.0.3
129
+ rubygems_version: 3.1.2
126
130
  signing_key:
127
131
  specification_version: 4
128
132
  summary: The low level client for serverside calls for Stream Chat.