slack-ruby-client 3.3.0 → 3.4.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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/danger-comment.yml +11 -2
  3. data/.github/workflows/danger.yml +10 -2
  4. data/.github/workflows/lint.yml +21 -8
  5. data/.github/workflows/release.yml +27 -0
  6. data/.gitignore +1 -0
  7. data/.rubocop.yml +93 -1
  8. data/.spellcheck.txt +256 -0
  9. data/AGENTS.md +1 -1
  10. data/CHANGELOG.md +17 -0
  11. data/CONTRIBUTING.md +53 -62
  12. data/Gemfile +20 -4
  13. data/LICENSE.md +1 -1
  14. data/README.md +94 -104
  15. data/RELEASING.md +20 -58
  16. data/Rakefile +22 -0
  17. data/SECURITY.md +1 -1
  18. data/UPGRADING.md +39 -43
  19. data/benchmarks/events.rb +26 -0
  20. data/benchmarks/formatting.rb +17 -0
  21. data/benchmarks/support.rb +67 -0
  22. data/benchmarks/web_client.rb +28 -0
  23. data/bin/commands/admin_analytics_members.rb +39 -0
  24. data/bin/commands/admin_analytics_messages.rb +2 -2
  25. data/bin/commands/admin_analytics_slackbot.rb +33 -0
  26. data/bin/commands/admin_apps_permissions.rb +1 -1
  27. data/bin/commands/admin_conversations.rb +11 -1
  28. data/bin/commands/admin_slackbot_skills.rb +56 -0
  29. data/bin/commands/admin_users.rb +11 -2
  30. data/bin/commands/admin_users_access.rb +31 -0
  31. data/bin/commands/agents_conversations.rb +122 -0
  32. data/bin/commands/apps_managed_permissions.rb +2 -2
  33. data/bin/commands/chat.rb +1 -1
  34. data/bin/commands/pins.rb +1 -1
  35. data/bin/commands/slackLists_download.rb +1 -0
  36. data/bin/commands/slackLists_items.rb +1 -1
  37. data/bin/commands/slackbot_skills.rb +71 -0
  38. data/bin/commands/slackbot_skills_library.rb +29 -0
  39. data/bin/commands/team.rb +1 -0
  40. data/bin/commands/team_externalTeams.rb +1 -1
  41. data/examples/files_upload_v2/README.md +4 -3
  42. data/examples/oauth_v2/README.md +5 -4
  43. data/lib/slack/messages/formatting.rb +29 -20
  44. data/lib/slack/version.rb +1 -1
  45. data/lib/slack/web/api/endpoints/admin_analytics_members.rb +66 -0
  46. data/lib/slack/web/api/endpoints/admin_analytics_messages.rb +1 -1
  47. data/lib/slack/web/api/endpoints/admin_analytics_slackbot.rb +54 -0
  48. data/lib/slack/web/api/endpoints/admin_apps_permissions.rb +1 -1
  49. data/lib/slack/web/api/endpoints/admin_conversations.rb +16 -1
  50. data/lib/slack/web/api/endpoints/admin_slackbot_skills.rb +84 -0
  51. data/lib/slack/web/api/endpoints/admin_users.rb +13 -1
  52. data/lib/slack/web/api/endpoints/admin_users_access.rb +40 -0
  53. data/lib/slack/web/api/endpoints/agents_conversations.rb +186 -0
  54. data/lib/slack/web/api/endpoints/apps_managed_permissions.rb +1 -1
  55. data/lib/slack/web/api/endpoints/chat.rb +1 -1
  56. data/lib/slack/web/api/endpoints/pins.rb +1 -1
  57. data/lib/slack/web/api/endpoints/slackLists_download.rb +2 -0
  58. data/lib/slack/web/api/endpoints/slackLists_items.rb +1 -1
  59. data/lib/slack/web/api/endpoints/slackbot_skills.rb +107 -0
  60. data/lib/slack/web/api/endpoints/slackbot_skills_library.rb +36 -0
  61. data/lib/slack/web/api/endpoints/team.rb +2 -0
  62. data/lib/slack/web/api/endpoints/team_externalTeams.rb +1 -1
  63. data/lib/slack/web/api/endpoints.rb +14 -0
  64. data/lib/slack/web/api/errors.rb +258 -2
  65. data/lib/slack/web/api/mixins/ids.id.rb +2 -1
  66. data/script/release.rb +33 -0
  67. data/slack-ruby-client.gemspec +1 -2
  68. metadata +24 -3
data/UPGRADING.md CHANGED
@@ -1,27 +1,26 @@
1
- Upgrading Slack-Ruby-Client
2
- ===========================
1
+ # Upgrading Slack-Ruby-Client
3
2
 
4
- ### Upgrading to >= 3.3.0
3
+ ## Upgrading to 3.3.0 or Later
5
4
 
6
- #### Command-Line Client Dependency
5
+ ### Command-Line Client Dependency
7
6
 
8
7
  [#602](https://github.com/slack-ruby/slack-ruby-client/pull/602) removes [gli](https://github.com/davetron5000/gli) from slack-ruby-client's runtime dependencies. Only the `slack` command-line client uses it. If you use the command-line client, add `gem 'gli'` to your Gemfile or run `gem install gli`. Without it, `slack` exits with a message saying so. The library itself is unaffected.
9
8
 
10
- #### Exception Messages
9
+ ### Exception Messages
11
10
 
12
11
  [#603](https://github.com/slack-ruby/slack-ruby-client/pull/603) standardizes handwritten exception messages to start with lowercase letters and omit trailing periods. Some messages also quote argument names and values with backticks. For example, `TooManyRequestsError` now reports `retry after 3600 seconds` instead of `Retry after 3600 seconds`, and file-upload validation reports ``required argument :`filename` missing in file (`0`)`` instead of `Required argument :filename missing in file (0)`.
13
12
 
14
13
  Update tests, regular expressions, or application logic that match these messages exactly. Exception classes and rescue behavior are unchanged; upstream Slack error codes (such as `invalid_auth`) and dynamically supplied messages are preserved. Prefer matching exception classes and structured error attributes rather than human-readable message text.
15
14
 
16
- ### Upgrading to >= 3.2.0
15
+ ## Upgrading to 3.2.0 or Later
17
16
 
18
17
  [#583](https://github.com/slack-ruby/slack-ruby-client/pull/583) modifies the error types raised when a nonexistent #channel-name or @user-handle is looked up. These will now raise `ChannelNotFound` and `UserNotFound` respectively, whereas they previously raised a `SlackError`. If your code relies on these types without accounting for inheritance, it will need to be migrated. Notably, `rescue SlackError` will continue to work as normal, since both error classes inherit from it.
19
18
 
20
- ### Upgrading to >= 3.0.0
19
+ ## Upgrading to 3.0.0 or Later
21
20
 
22
21
  Support for the [RTM API](https://docs.slack.dev/tools/java-slack-sdk/guides/rtm/) has been removed in [#573](https://github.com/slack-ruby/slack-ruby-client/pull/573). By now you should have [migrated your app to granular permissions](https://code.dblock.org/2020/11/30/migrating-classic-slack-ruby-bots-to-granular-permissions.html), and you should lock your slack-ruby-client to 2.x for those bots. Next, to remove RTM components we found it more effective to just [write a new version of a bot](https://code.dblock.org/2024/06/30/writing-a-channel-slack-bot.html) and avoid a complex migration.
23
22
 
24
- ### Upgrading to >= 2.0.0
23
+ ## Upgrading to 2.0.0 or Later
25
24
 
26
25
  [#416](https://github.com/slack-ruby/slack-ruby-client/pull/416) Removes default values for Faraday's SSL settings `ca_file` and `ca_path`.
27
26
 
@@ -40,24 +39,21 @@ or
40
39
  client = Slack::Web::Client.new(ca_file: OpenSSL::X509::DEFAULT_CERT_FILE, ca_path: OpenSSL::X509::DEFAULT_CERT_DIR)
41
40
  ```
42
41
 
43
- #### RealTime Stores
42
+ ### RealTime Stores
44
43
 
45
- Slack has deprecated the `rtm.start` method and [replaced its response](https://api.slack.com/changelog/2021-10-rtm-start-to-stop) with that of `rtm.connect`, so it has been removed from the library along with the `start_method` configuration ([#419](https://github.com/slack-ruby/slack-ruby-client/pull/419)) and `Slack::RealTime::Stores::Starter` is now the default store.
46
- If your app still relies on the old `rtm.start` behavior, you can achieve a similar result with `Slack::RealTime::Stores::Store`, which initializes itself using Web API methods (see [README](README.md#slackrealtimestoresstore)).
44
+ Slack has deprecated the `rtm.start` method and [replaced its response](https://api.slack.com/changelog/2021-10-rtm-start-to-stop) with that of `rtm.connect`, so it has been removed from the library along with the `start_method` configuration ([#419](https://github.com/slack-ruby/slack-ruby-client/pull/419)) and `Slack::RealTime::Stores::Starter` is now the default store. If your app still relies on the old `rtm.start` behavior, you can achieve a similar result with `Slack::RealTime::Stores::Store`, which initializes itself using Web API methods (see [README](README.md#slackrealtimestoresstore)).
47
45
 
48
- The names of the Store caches `channels` and `groups` have been changed to `public_channels` and `private_channels` to reflect their true meaning.
49
- This is consistent with the [Slack Web API](https://api.slack.com/methods/conversations.list#arg_types), although [event types for private channels](https://api.slack.com/events?query=group) still use the term `group`.
50
- In both cases, private channels consist of both [conversation types](https://api.slack.com/types/conversation) (`id: 'C...'', is_channel: true, is_group: false, is_private: true`) and [group types](https://api.slack.com/types/group) (`id: 'G...', is_channel: false, is_group: true, is_private: true`) depending whether the object was created before or after March 2021.
46
+ The names of the Store caches `channels` and `groups` have been changed to `public_channels` and `private_channels` to reflect their true meaning. This is consistent with the [Slack Web API](https://api.slack.com/methods/conversations.list#arg_types), although [event types for private channels](https://api.slack.com/events?query=group) still use the term `group`. In both cases, private channels consist of both [conversation types](https://api.slack.com/types/conversation) (`id: 'C...'', is_channel: true, is_group: false, is_private: true`) and [group types](https://api.slack.com/types/group) (`id: 'G...', is_channel: false, is_group: true, is_private: true`) depending whether the object was created before or after March 2021.
51
47
 
52
- ### Upgrading to >= 1.0.0
48
+ ## Upgrading to 1.0.0 or Later
53
49
 
54
- #### Deprecated Methods
50
+ ### Deprecated Methods
55
51
 
56
52
  Slack has deprecated all `channel` and `group` methods, which have been removed from the library.
57
53
 
58
54
  See [this announcement from Slack](https://api.slack.com/changelog/2020-01-deprecating-antecedents-to-the-conversations-api) for details.
59
55
 
60
- #### Error Handling
56
+ ### Error Handling
61
57
 
62
58
  As of 1.0.0 `Slack::Web::Api::Errors::ServerError` and its subclasses (introduced in 0.16.0) no longer extend `Slack::Web::Api::Errors::InternalError` or its parent `Slack::Web::Api::Errors::SlackError`. If you are rescuing `SlackError` or `InternalError` with the intention of including `ServerError` and its subclasses you should adjust your code to explicitly rescue `Slack::Web::Api::Errors::ServerError`.
63
59
 
@@ -91,45 +87,45 @@ error.message
91
87
  # => 'timeout_error'
92
88
  ```
93
89
 
94
- ### Upgrading to >= 0.16.0
90
+ ## Upgrading to 0.16.0 or Later
95
91
 
96
- #### Removed Celluloid and Faye-Websocket Concurrency Support
92
+ ### Removed Celluloid and Faye WebSocket Concurrency Support
97
93
 
98
94
  Concurrency support for `celluloid-io` and `faye-websocket` has been removed. If you are running a RealTime bot on Celluloid or Faye, you must upgrade to `async-websocket`. Please note that RealTime bots are deprecated by Slack, and we generally recommend you [migrate your classic, RealTime bot, to granular permissions](https://code.dblock.org/2020/11/30/migrating-classic-slack-ruby-bots-to-granular-permissions.html).
99
95
 
100
96
  See [#338](https://github.com/slack-ruby/slack-ruby-client/issues/338) for more information.
101
97
 
102
- #### Error Handling
98
+ ### Error Handling
103
99
 
104
100
  As of 0.16.0 `Faraday::Error` exceptions sans `Faraday::ClientError` are wrapped into `Slack::Web::Api::Errors::ServerError`, so if you're rescuing `Faraday::Error` — you should adjust your code to use `Slack::Web::Api::Errors::ServerError` and use `exception.cause` if underlying `Faraday::Error` is needed.
105
101
 
106
102
  See [README#other-errors](README.md#other-errors) and [#350](https://github.com/slack-ruby/slack-ruby-client/pull/350) for more information.
107
103
 
108
- ### Upgrading to >= 0.15.0
104
+ ## Upgrading to 0.15.0 or Later
109
105
 
110
106
  As of 0.15.0, `activesupport` is no longer required. Add `gem 'activesupport'` to your Gemfile if you required ActiveSupport via this library.
111
107
 
112
108
  See [#325](https://github.com/slack-ruby/slack-ruby-client/pull/325) for more information.
113
109
 
114
- ### Upgrading to >= 0.14.0
110
+ ## Upgrading to 0.14.0 or Later
115
111
 
116
112
  If you are using async-websocket, lock down its version to 0.8.0 as newer versions are currently incompatible.
117
113
 
118
- ```
114
+ ```ruby
119
115
  gem 'async-websocket', '~> 0.8.0'
120
116
  ```
121
117
 
122
118
  See [#282](https://github.com/slack-ruby/slack-ruby-client/issues/282) for more information.
123
119
 
124
- ### Upgrading to >= 0.13.0
120
+ ## Upgrading to 0.13.0 or Later
125
121
 
126
- #### Recommended Async Library
122
+ ### Recommended Async Library
127
123
 
128
124
  The RealTime client now supports [async-websocket](https://github.com/socketry/async-websocket), which is actively maintained and is now the recommended library.
129
125
 
130
126
  See [#219](https://github.com/slack-ruby/slack-ruby-client/pull/219) for implementation details.
131
127
 
132
- #### Async Library Threading and Reactor Changes
128
+ ### Async Library Threading and Reactor Changes
133
129
 
134
130
  The RealTime celluloid-io implementation now uses a `Thread` per client. Previous versions used an `Actor`.
135
131
 
@@ -137,9 +133,9 @@ The faye-websocket implementation with EventMachine will attempt to shutdown Eve
137
133
 
138
134
  See [#224](https://github.com/slack-ruby/slack-ruby-client/pull/224) for more information.
139
135
 
140
- ### Upgrading to >= 0.9.0
136
+ ## Upgrading to 0.9.0 or Later
141
137
 
142
- #### Changes in How the RTM Client Connects
138
+ ### Changes in How the RTM Client Connects
143
139
 
144
140
  The RealTime client now automatically chooses either [rtm.start](https://api.slack.com/methods/rtm.start) or [rtm.connect](https://api.slack.com/methods/rtm.connect) to open a connection. The `rtm.connect` method is a newer, preferred method, which serves connection purposes and returns some basic team info. The `rtm.start` method additionally returns a lot of data about the team, its channels, and members, and is required to use the full `Slack::RealTime::Stores::Store` storage class.
145
141
 
@@ -153,7 +149,7 @@ end
153
149
 
154
150
  See [#145](https://github.com/slack-ruby/slack-ruby-client/pull/145) for more information.
155
151
 
156
- ### Upgrading to >= 0.8.0
152
+ ## Upgrading to 0.8.0 or Later
157
153
 
158
154
  The default timeout for `rtm.start` has been increased from 60 to 180 seconds via `Slack::RealTime::Client.config.start_options[:request][:timeout]`. If you're explicitly setting `start_options` in your application, preserve the value by merging settings instead of replacing the entire `start_options` value.
159
155
 
@@ -175,9 +171,9 @@ end
175
171
 
176
172
  See [#136](https://github.com/slack-ruby/slack-ruby-client/pull/136) for more information.
177
173
 
178
- ### Upgrading to >= 0.6.0
174
+ ## Upgrading to 0.6.0 or Later
179
175
 
180
- #### Changes to API Response Data
176
+ ### Changes to API Response Data
181
177
 
182
178
  API responses in both Web and RealTime clients are now instances of [Slack::Messages::Message](lib/slack/messages/message.rb), which provides method access to properties.
183
179
 
@@ -195,39 +191,39 @@ puts "Welcome #{client.self.name} to the #{client.team.name} team."
195
191
 
196
192
  See [#56](https://github.com/slack-ruby/slack-ruby-client/issues/56) for more information.
197
193
 
198
- #### Changes to RealTime Local Store
194
+ ### Changes to RealTime Local Store
199
195
 
200
196
  Upon a successful `rtm.start` the RealTime client keeps a local cache of objects, including `self` or `users`. It will now also track changes to these objects. The following changes have been made to the data structures.
201
197
 
202
- ##### client.self
198
+ #### Self
203
199
 
204
200
  The `client.self` object is now a `Slack::RealTime::Models::User`, which is a child of `Hashie::Mash`, so no code changes should be required.
205
201
 
206
- ##### client.team
202
+ #### Team
207
203
 
208
204
  The `client.team` object is now a `Slack::RealTime::Models::Team`, which is a child of `Hashie::Mash`, so no code changes should be required.
209
205
 
210
- ##### client .users, .channels, .groups, .ims
206
+ #### Users, Channels, Groups, and IMs
211
207
 
212
- The `client.users`, `.channels`, `.groups` and `.ims` collections have been changed from `Array` to `Hash`, with object ID as key. Replace any code iterating over the array, eg. `client.users.values.each` or `client.channels.each_pair { |id, channel| ... }`.
208
+ The `client.users`, `.channels`, `.groups` and `.ims` collections have been changed from `Array` to `Hash`, with object ID as key. Replace any code iterating over the array, e.g. `client.users.values.each` or `client.channels.each_pair { |id, channel| ... }`.
213
209
 
214
210
  See [#55](https://github.com/slack-ruby/slack-ruby-client/issues/55) for more information.
215
211
 
216
- ### Upgrading to >= 0.5.0
212
+ ## Upgrading to 0.5.0 or Later
217
213
 
218
- #### Changes to Real Time Concurrency
214
+ ### Changes to Real Time Concurrency
219
215
 
220
- Since 0.5.0 `Slack::RealTime::Client` supports [Celluloid](https://github.com/celluloid/celluloid) and no longer defaults to [Faye::WebSocket](https://github.com/faye/faye-websocket-ruby) with [Eventmachine](https://github.com/eventmachine/eventmachine). It will auto-detect one or the other depending on the gems in your Gemfile, which means you may need to add one or the other to your Gemfile.
216
+ Since 0.5.0 `Slack::RealTime::Client` supports [Celluloid](https://github.com/celluloid/celluloid) and no longer defaults to [Faye::WebSocket](https://github.com/faye/faye-websocket-ruby) with [EventMachine](https://github.com/eventmachine/eventmachine). It will auto-detect one or the other depending on the gems in your Gemfile, which means you may need to add one or the other to your Gemfile.
221
217
 
222
- ##### Faye::WebSocket with Eventmachine
218
+ #### Faye::WebSocket with EventMachine
223
219
 
224
- ```
220
+ ```ruby
225
221
  gem 'faye-websocket'
226
222
  ```
227
223
 
228
- ##### Celluloid
224
+ #### Celluloid
229
225
 
230
- ```
226
+ ```ruby
231
227
  gem 'celluloid-io'
232
228
  ```
233
229
 
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'support'
4
+ require 'rack'
5
+ require 'stringio'
6
+
7
+ secret = 'benchmark-signing-secret'
8
+ body = JSON.dump(token: 'x', team_id: 'T1', event: { type: 'message', text: 'hello' * 50 })
9
+
10
+ def signed_env(secret, body)
11
+ timestamp = Time.now.to_i.to_s
12
+ hex = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('SHA256'), secret, "v0:#{timestamp}:#{body}")
13
+ Rack::MockRequest.env_for(
14
+ '/events', method: 'POST', input: body,
15
+ 'HTTP_X_SLACK_REQUEST_TIMESTAMP' => timestamp, 'HTTP_X_SLACK_SIGNATURE' => "v0=#{hex}"
16
+ )
17
+ end
18
+
19
+ env = signed_env(secret, body)
20
+
21
+ SlackBenchmarks.run('Slack::Events::Request') do |x|
22
+ x.report('verify!') do
23
+ env['rack.input'].rewind
24
+ Slack::Events::Request.new(Rack::Request.new(env), signing_secret: secret).verify!
25
+ end
26
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'support'
4
+
5
+ message = 'Hey <@U024BE7LH|bob>, did you see <#C1234|general>? “Quoted” ‘text’ &amp; ' \
6
+ '<https://example.com|a link> &gt; file.txt <!everyone>'
7
+ plain = 'A message without any special formatting, which is the most common case for unescape.' * 3
8
+ markdown = "**Bold**, *italic*, ***both***, ~~struck~~, and a [link](https://example.com).\n" * 5
9
+ escape = 'Hello & <world>, 1 < 2 && 3 > 2.' * 5
10
+
11
+ SlackBenchmarks.run('Slack::Messages::Formatting') do |x|
12
+ x.report('unescape (formatted)') { Slack::Messages::Formatting.unescape(message) }
13
+ x.report('unescape (plain)') { Slack::Messages::Formatting.unescape(plain) }
14
+ x.report('escape') { Slack::Messages::Formatting.escape(escape) }
15
+ x.report('markdown (formatted)') { Slack::Messages::Formatting.markdown(markdown) }
16
+ x.report('markdown (plain)') { Slack::Messages::Formatting.markdown(plain) }
17
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Shared setup for the benchmarks in this directory. Run one with
4
+ # `bundle exec ruby benchmarks/<name>.rb`, or all of them with `bundle exec rake benchmark`.
5
+ # Set BENCHMARK_TIME and BENCHMARK_WARMUP (seconds) to trade accuracy for speed.
6
+
7
+ require 'benchmark/ips'
8
+ require 'benchmark/memory'
9
+ require 'json'
10
+
11
+ require_relative '../lib/slack-ruby-client'
12
+
13
+ module SlackBenchmarks
14
+ # A Faraday adapter that answers every request in process from canned JSON,
15
+ # so benchmarks measure the client stack (middleware, JSON, Hashie::Mash, helpers) without network noise.
16
+ class Adapter < Faraday::Adapter
17
+ class << self
18
+ attr_accessor :responder
19
+ end
20
+
21
+ def call(env)
22
+ super
23
+ body = self.class.responder.call(env)
24
+ save_response(env, 200, body, { 'Content-Type' => 'application/json; charset=utf-8' })
25
+ @app.call(env)
26
+ end
27
+ end
28
+
29
+ module_function
30
+
31
+ def run(title, &block)
32
+ puts "== #{title} (Ruby #{RUBY_VERSION}, slack-ruby-client #{Slack::VERSION})"
33
+ time = Float(ENV.fetch('BENCHMARK_TIME', 2))
34
+ warmup = Float(ENV.fetch('BENCHMARK_WARMUP', 1))
35
+ Benchmark.ips do |x|
36
+ x.config(time: time, warmup: warmup)
37
+ yield x
38
+ end
39
+ Benchmark.memory(&block)
40
+ end
41
+
42
+ def client(&responder)
43
+ Adapter.responder = responder
44
+ Slack::Web::Client.new(token: 'benchmark-token', adapter: Adapter, logger: ::Logger.new(nil))
45
+ end
46
+
47
+ def members(count, prefix: 'U')
48
+ Array.new(count) do |i|
49
+ {
50
+ id: "#{prefix}#{i.to_s.rjust(8, '0')}",
51
+ name: "user#{i}",
52
+ real_name: "User #{i}",
53
+ profile: { email: "user#{i}@example.com", display_name: "user#{i}", image: "https://example.com/#{i}.png" }
54
+ }
55
+ end
56
+ end
57
+
58
+ # Pages through `items` like a cursor-paginated Slack method, honoring `limit` and `cursor`.
59
+ def paginate(env, key, items)
60
+ params = env.method == :get ? Faraday::Utils.parse_query(env.url.query.to_s) : Faraday::Utils.parse_query(env.request_body.to_s)
61
+ limit = Integer(params['limit'] || 100)
62
+ offset = Integer(params['cursor'].to_s.empty? ? 0 : params['cursor'])
63
+ page = items[offset, limit] || []
64
+ next_cursor = offset + limit < items.size ? (offset + limit).to_s : ''
65
+ JSON.dump(ok: true, key => page, response_metadata: { next_cursor: next_cursor })
66
+ end
67
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'support'
4
+
5
+ members = SlackBenchmarks.members(1_000)
6
+ channels = Array.new(1_000) { |i| { id: format('C%08d', i), name: "channel-#{i}", is_channel: true } }
7
+ auth = JSON.dump(ok: true, url: 'https://example.slack.com/', team: 'Example', user: 'bot', team_id: 'T1', user_id: 'U1')
8
+ posted = JSON.dump(ok: true, channel: 'C1', ts: '1.000', message: { text: 'hello', type: 'message' })
9
+
10
+ client = SlackBenchmarks.client do |env|
11
+ case env.url.path
12
+ when '/api/auth.test' then auth
13
+ when '/api/chat.postMessage' then posted
14
+ when '/api/users.list' then SlackBenchmarks.paginate(env, :members, members)
15
+ when '/api/conversations.list' then SlackBenchmarks.paginate(env, :channels, channels)
16
+ else raise "unexpected request to #{env.url.path}"
17
+ end
18
+ end
19
+
20
+ blocks = Array.new(10) { |i| { type: 'section', text: { type: 'mrkdwn', text: "Block #{i}" } } }
21
+
22
+ SlackBenchmarks.run('Slack::Web::Client') do |x|
23
+ x.report('auth_test') { client.auth_test }
24
+ x.report('chat_postMessage with blocks') { client.chat_postMessage(channel: 'C1', text: 'hello', blocks: blocks) }
25
+ x.report('users_list, 10 pages of 100') { client.users_list(limit: 100) { |_page| nil } }
26
+ x.report('users_id, last of 1000') { client.users_id(user: '@user999') }
27
+ x.report('conversations_id, last of 1000') { client.conversations_id(channel: '#channel-999') }
28
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ module Slack
5
+ module Cli
6
+ class App
7
+ desc 'AdminAnalyticsMembers methods.'
8
+ command 'admin_analytics_members' do |g|
9
+ g.desc 'Retrieves activity metrics for each member of an organization or workspace for one day. Returns the same metrics as the member analytics dashboard, sorted by user ID.'
10
+ g.long_desc %( Retrieves activity metrics for each member of an organization or workspace for one day. Returns the same metrics as the member analytics dashboard, sorted by user ID. )
11
+ g.command 'activity' do |c|
12
+ c.flag 'date', desc: "The day to report on, as YYYY-MM-DD in UTC. Each metric counts that day's activity. Defaults to the most recent day with data. The response's available_date_range gives the earliest and latest days you can request."
13
+ c.flag 'team_id', desc: 'Workspace ID to scope the results to. With an organization-level token, omit it for organization-wide results. A workspace-level token may only pass its own workspace.'
14
+ c.flag 'member_types', desc: 'Comma-separated list of member types to include. Omit to include every member type.'
15
+ c.flag 'user_ids', desc: 'Comma-separated list of user IDs to return. Use admin.analytics.members.metadata, which supports searching by name and email, to find them; this method never returns names or email addresses. Up to 500 IDs. Deactivated members may be included. Omit to return every member.'
16
+ c.flag 'cursor', desc: "Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request's response_metadata. Default value fetches the first 'page' of the collection."
17
+ c.flag 'limit', desc: 'Maximum number of members to return. Max allowed is 500.'
18
+ c.action do |_global_options, options, _args|
19
+ puts JSON.dump(@client.admin_analytics_members_activity(options))
20
+ end
21
+ end
22
+
23
+ g.desc 'Retrieves profile metadata for each member of an organization or workspace. Returns the same profile fields as the member analytics dashboard, sorted by user ID, as the companion of admin.analytics.members.activity.'
24
+ g.long_desc %( Retrieves profile metadata for each member of an organization or workspace. Returns the same profile fields as the member analytics dashboard, sorted by user ID, as the companion of admin.analytics.members.activity. )
25
+ g.command 'metadata' do |c|
26
+ c.flag 'include_deactivated_since', desc: 'Also return members deactivated on or after this day, as YYYY-MM-DD in UTC. Without it, only active members are returned.'
27
+ c.flag 'team_id', desc: 'Workspace ID to scope the results to. With an organization-level token, omit it for organization-wide results. A workspace-level token may only pass its own workspace.'
28
+ c.flag 'member_types', desc: 'Comma-separated list of member types to include. Omit to include every member type.'
29
+ c.flag 'query', desc: 'Space-delimited search terms matched against member names, and against email addresses when the organization shows them. When the organization hides email addresses, or hides guest email addresses, the search does not match on email at all, so a hidden address cannot be recovered by searching for it. Only matching members are returned.'
30
+ c.flag 'cursor', desc: "Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request's response_metadata. Default value fetches the first 'page' of the collection."
31
+ c.flag 'limit', desc: 'Maximum number of members to return. Max allowed is 500.'
32
+ c.action do |_global_options, options, _args|
33
+ puts JSON.dump(@client.admin_analytics_members_metadata(options))
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -6,8 +6,8 @@ module Slack
6
6
  class App
7
7
  desc 'AdminAnalyticsMessages methods.'
8
8
  command 'admin_analytics_messages' do |g|
9
- g.desc 'Retrieves activity metrics for messages from a given channel.'
10
- g.long_desc %( Retrieves activity metrics for messages from a given channel. )
9
+ g.desc 'Retrieves activity metrics for messages from a given channel, created between oldest_ts and latest_ts'
10
+ g.long_desc %( Retrieves activity metrics for messages from a given channel, created between oldest_ts and latest_ts )
11
11
  g.command 'activity' do |c|
12
12
  c.flag 'channel', desc: 'Channel ID for channel of the message activity to query.'
13
13
  c.flag 'oldest_ts', desc: 'Oldest timestamp to include in the results. Defaults to 7 days before current time. If not passed while still passing the latest_ts parameter, defaults to 7 days before latest_ts.'
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ module Slack
5
+ module Cli
6
+ class App
7
+ desc 'AdminAnalyticsSlackbot methods.'
8
+ command 'admin_analytics_slackbot' do |g|
9
+ g.desc 'Retrieve per-user Slackbot skill usage for an Enterprise organization on a single date, returned as paginated JSON.'
10
+ g.long_desc %( Retrieve per-user Slackbot skill usage for an Enterprise organization on a single date, returned as paginated JSON. )
11
+ g.command 'skills' do |c|
12
+ c.flag 'date', desc: "The date to retrieve the analytics data for, expressed as YYYY-MM-DD in UTC. If not provided, defaults to the latest date with available data. The response's available_date_range gives the earliest and latest dates you can request."
13
+ c.flag 'cursor', desc: "Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request's response_metadata. Default value fetches the first 'page' of the collection."
14
+ c.flag 'limit', desc: 'Maximum number of skill entries to return per page, counted across all rows. Defaults to 500. Max allowed is 1000.'
15
+ c.action do |_global_options, options, _args|
16
+ puts JSON.dump(@client.admin_analytics_slackbot_skills(options))
17
+ end
18
+ end
19
+
20
+ g.desc 'Retrieve per-user Slackbot tool usage for an Enterprise organization on a single date, returned as paginated JSON.'
21
+ g.long_desc %( Retrieve per-user Slackbot tool usage for an Enterprise organization on a single date, returned as paginated JSON. )
22
+ g.command 'tools' do |c|
23
+ c.flag 'date', desc: "The date to retrieve the analytics data for, expressed as YYYY-MM-DD in UTC. If not provided, defaults to the latest date with available data. The response's available_date_range gives the earliest and latest dates you can request."
24
+ c.flag 'cursor', desc: "Paginate through collections of data by setting the cursor parameter to a next_cursor attribute returned by a previous request's response_metadata. Default value fetches the first 'page' of the collection."
25
+ c.flag 'limit', desc: 'Maximum number of tool entries to return per page, counted across all rows. Defaults to 500. Max allowed is 1000.'
26
+ c.action do |_global_options, options, _args|
27
+ puts JSON.dump(@client.admin_analytics_slackbot_tools(options))
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -45,7 +45,7 @@ module Slack
45
45
  c.flag 'app_id', desc: 'Encoded ID of the app.'
46
46
  c.flag 'permission_type', desc: 'The type of permission that defines who can access the app.'
47
47
  c.flag 'user_ids', desc: 'List of user IDs to allow for named_entities visibility.'
48
- c.flag 'usergroup_ids', desc: 'List of encoded usergroup IDs.'
48
+ c.flag 'usergroup_ids', desc: 'List of encoded usergroup IDs the permission applies to. With named_entities the listed groups may access the app; with named_entities_exclude they may not.'
49
49
  c.flag 'channel_restriction_mode', desc: 'The mode that defines where the app can be used in channels.'
50
50
  c.flag 'channel_ids', desc: 'List of encoded channel IDs for channel restrictions. Semantics depend on channel_restriction_mode: allowlist for specific_channels, exclusion list for all_channels_except.'
51
51
  c.action do |_global_options, options, _args|
@@ -164,6 +164,16 @@ module Slack
164
164
  end
165
165
  end
166
166
 
167
+ g.desc 'Remove multiple users from a conversation. Admin version of conversations.kick with support for bulk user removal.'
168
+ g.long_desc %( Remove multiple users from a conversation. Admin version of conversations.kick with support for bulk user removal. )
169
+ g.command 'kick' do |c|
170
+ c.flag 'channel_id', desc: 'ID of conversation to remove users from.'
171
+ c.flag 'user_ids', desc: 'The users to remove from the channel.'
172
+ c.action do |_global_options, options, _args|
173
+ puts JSON.dump(@client.admin_conversations_kick(options))
174
+ end
175
+ end
176
+
167
177
  g.desc 'Link a Salesforce record to a channel'
168
178
  g.long_desc %( Link a Salesforce record to a channel )
169
179
  g.command 'linkObjects' do |c|
@@ -212,7 +222,7 @@ module Slack
212
222
  g.command 'search' do |c|
213
223
  c.flag 'team_ids', desc: 'Comma separated string of team IDs, signifying the internal workspaces to search through.'
214
224
  c.flag 'connected_team_ids', desc: 'Array of encoded team IDs, signifying the external orgs to search through.'
215
- c.flag 'query', desc: 'Name of the the channel to query by.'
225
+ c.flag 'query', desc: 'Name of the channel to query by.'
216
226
  c.flag 'limit', desc: 'Maximum number of items to be returned. Must be between 1 - 20 both inclusive. Default is 10.'
217
227
  c.flag 'cursor', desc: 'Set cursor to next_cursor returned by the previous call to list items in the next page.'
218
228
  c.flag 'search_channel_types', desc: 'The type of channel to include or exclude in the search. For example private will search private channels, while private_exclude will exclude them. For a full list of types, check the Types section.'
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ module Slack
5
+ module Cli
6
+ class App
7
+ desc 'AdminSlackbotSkills methods.'
8
+ command 'admin_slackbot_skills' do |g|
9
+ g.desc 'Lists metadata for skills owned by the organization, including invite-only skills.'
10
+ g.long_desc %( Lists metadata for skills owned by the organization, including invite-only skills. )
11
+ g.command 'list' do |c|
12
+ c.flag 'category', desc: 'Only return skills in this category.'
13
+ c.flag 'cursor', desc: 'Continuation from the previous page. Keep all filters and sorting unchanged. Pages can be empty while a continuation remains; continue until next_cursor is empty. Changes during traversal may move results; pagination is not a snapshot.'
14
+ c.flag 'limit', desc: 'The maximum number of skills to return. Fewer may be returned even when more remain.'
15
+ c.flag 'creator_ids', desc: 'Only return skills created by these users. Accepts U or W user IDs.'
16
+ c.flag 'publish_status', desc: 'Filter by publication to the org catalog.'
17
+ c.flag 'auto_enabled_status', desc: 'Filter by org deployment, independently of publication.'
18
+ c.flag 'sort', desc: 'Sort across the inventory. Name uses case-insensitive ordering. Unedited skills use their creation date for date_updated sorting.'
19
+ c.flag 'sort_dir', desc: 'Sort direction; file ID breaks ties.'
20
+ c.action do |_global_options, options, _args|
21
+ puts JSON.dump(@client.admin_slackbot_skills_list(options))
22
+ end
23
+ end
24
+
25
+ g.desc "Publishes Slackbot skills to an organization's catalog."
26
+ g.long_desc %( Publishes Slackbot skills to an organization's catalog. )
27
+ g.command 'publish' do |c|
28
+ c.flag 'skill_ids', desc: 'One to 50 skill IDs. Successful items are not rolled back if other items fail.'
29
+ c.action do |_global_options, options, _args|
30
+ puts JSON.dump(@client.admin_slackbot_skills_publish(options))
31
+ end
32
+ end
33
+
34
+ g.desc 'Sets who a Slackbot skill is automatically turned on for.'
35
+ g.long_desc %( Sets who a Slackbot skill is automatically turned on for. )
36
+ g.command 'setAutoEnabled' do |c|
37
+ c.flag 'skill_id', desc: 'Canvas skill to deploy.'
38
+ c.flag 'permission_type', desc: 'Deployment audience.'
39
+ c.flag 'usergroup_ids', desc: 'One to 100 user groups for named_entities. Duplicates count toward the input limit and are stored once. Omit for other permission types.'
40
+ c.action do |_global_options, options, _args|
41
+ puts JSON.dump(@client.admin_slackbot_skills_setAutoEnabled(options))
42
+ end
43
+ end
44
+
45
+ g.desc 'Removes Slackbot skills from the org catalog, preserving access, libraries, and deployments.'
46
+ g.long_desc %( Removes Slackbot skills from the org catalog, preserving access, libraries, and deployments. )
47
+ g.command 'unpublish' do |c|
48
+ c.flag 'skill_ids', desc: 'One to 50 skill IDs. Successful items are not rolled back if other items fail.'
49
+ c.action do |_global_options, options, _args|
50
+ puts JSON.dump(@client.admin_slackbot_skills_unpublish(options))
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -19,6 +19,15 @@ module Slack
19
19
  end
20
20
  end
21
21
 
22
+ g.desc 'Deactivate a user from an enterprise organization and all its workspaces.'
23
+ g.long_desc %( Deactivate a user from an enterprise organization and all its workspaces. )
24
+ g.command 'deactivate' do |c|
25
+ c.flag 'user_id', desc: 'The ID of the user to deactivate.'
26
+ c.action do |_global_options, options, _args|
27
+ puts JSON.dump(@client.admin_users_deactivate(options))
28
+ end
29
+ end
30
+
22
31
  g.desc 'Fetches the expiration timestamp for a guest'
23
32
  g.long_desc %( Fetches the expiration timestamp for a guest )
24
33
  g.command 'getExpiration' do |c|
@@ -104,8 +113,8 @@ module Slack
104
113
  end
105
114
  end
106
115
 
107
- g.desc 'Set an existing guest user, admin user, or owner to be a regular user.'
108
- g.long_desc %( Set an existing guest user, admin user, or owner to be a regular user. )
116
+ g.desc 'Set an existing guest user, admin user, or owner to be a regular user. When team_id is an organization, the user is also set to a regular user on every workspace where they are a workspace owner, including workspaces where they were an owner before becoming an org admin or owner.'
117
+ g.long_desc %( Set an existing guest user, admin user, or owner to be a regular user. When team_id is an organization, the user is also set to a regular user on every workspace where they are a workspace owner, including workspaces where they were an owner before becoming an org admin or owner. )
109
118
  g.command 'setRegular' do |c|
110
119
  c.flag 'team_id', desc: 'The ID of the workspace or organization.'
111
120
  c.flag 'user_id', desc: 'The ID of the user to designate as a regular user.'
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+ # This file was auto-generated by lib/tasks/web.rake
3
+
4
+ module Slack
5
+ module Cli
6
+ class App
7
+ desc 'AdminUsersAccess methods.'
8
+ command 'admin_users_access' do |g|
9
+ g.desc 'Pause access across the organization for up to 1,000 frontline members. Success means the request was queued, not that all updates have completed.'
10
+ g.long_desc %( Pause access across the organization for up to 1,000 frontline members. Success means the request was queued, not that all updates have completed. )
11
+ g.command 'pause' do |c|
12
+ c.flag 'user_ids', desc: 'IDs of frontline members in the authenticated organization. Valid users are queued; rejected IDs are returned in invalid_users.'
13
+ c.flag 'reason', desc: 'Optional explanation for the access change.'
14
+ c.action do |_global_options, options, _args|
15
+ puts JSON.dump(@client.admin_users_access_pause(options))
16
+ end
17
+ end
18
+
19
+ g.desc 'Resume access across the organization for up to 1,000 frontline members. Success means the request was queued, not that all updates have completed.'
20
+ g.long_desc %( Resume access across the organization for up to 1,000 frontline members. Success means the request was queued, not that all updates have completed. )
21
+ g.command 'resume' do |c|
22
+ c.flag 'user_ids', desc: 'IDs of frontline members in the authenticated organization. Valid users are queued; rejected IDs are returned in invalid_users.'
23
+ c.flag 'reason', desc: 'Optional explanation for the access change.'
24
+ c.action do |_global_options, options, _args|
25
+ puts JSON.dump(@client.admin_users_access_resume(options))
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end