slack-ruby-client 2.6.0 → 2.7.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/workflows/test.yml +1 -0
- data/.github/workflows/update_api.yml +1 -1
- data/.rubocop_todo.yml +22 -13
- data/CHANGELOG.md +8 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +16 -2
- data/examples/files_upload_v2/files_upload_v2.rb +8 -0
- data/lib/slack/events/request.rb +1 -0
- data/lib/slack/version.rb +1 -1
- data/lib/slack/web/api/helpers/files.rb +32 -22
- data/lib/slack/web/api/mixins/conversations.id.rb +14 -3
- data/lib/slack/web/api/mixins/users.id.rb +7 -3
- data/slack-ruby-client.gemspec +1 -1
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c51153c945fdc89a1aa46ba02eb49256f7f2978277901f4d95e68c4d92197856
|
4
|
+
data.tar.gz: 9c450898f129249fcd6e2ab448830ba6e0f118e74c8af2f3e3e26e9419cc16ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1df2c875eb165a043823bd911fc2ac585693dc625bd32070081d01a4cbd4667c32252d287f14960a72266e28f2cd9787b59ef34101fb076e551448094bc1385
|
7
|
+
data.tar.gz: c5bce1883b654790df7992f8dec417cf3976ef210f0d35dd219de54666ec556c957fec9762a094149269c3d195f1c0333fab129ba10320d3f959448924bb42d0
|
data/.github/workflows/test.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2025-
|
3
|
+
# on 2025-07-19 11:04:04 UTC using RuboCop version 1.26.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -47,17 +47,17 @@ Lint/RedundantCopDisableDirective:
|
|
47
47
|
# Offense count: 13
|
48
48
|
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
|
49
49
|
Metrics/AbcSize:
|
50
|
-
Max:
|
50
|
+
Max: 67
|
51
51
|
|
52
52
|
# Offense count: 6
|
53
53
|
# Configuration parameters: IgnoredMethods.
|
54
54
|
Metrics/CyclomaticComplexity:
|
55
|
-
Max:
|
55
|
+
Max: 15
|
56
56
|
|
57
|
-
# Offense count:
|
57
|
+
# Offense count: 17
|
58
58
|
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
|
59
59
|
Metrics/MethodLength:
|
60
|
-
Max:
|
60
|
+
Max: 45
|
61
61
|
|
62
62
|
# Offense count: 1
|
63
63
|
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
|
@@ -67,12 +67,13 @@ Metrics/ParameterLists:
|
|
67
67
|
# Offense count: 3
|
68
68
|
# Configuration parameters: IgnoredMethods.
|
69
69
|
Metrics/PerceivedComplexity:
|
70
|
-
Max:
|
70
|
+
Max: 17
|
71
71
|
|
72
|
-
# Offense count:
|
72
|
+
# Offense count: 2
|
73
73
|
# Configuration parameters: MinSize.
|
74
74
|
Performance/CollectionLiteralInLoop:
|
75
75
|
Exclude:
|
76
|
+
- 'lib/slack/web/api/helpers/files.rb'
|
76
77
|
- 'spec/slack/web/api/endpoints/custom/files_spec.rb'
|
77
78
|
|
78
79
|
# Offense count: 1
|
@@ -93,20 +94,20 @@ Performance/StringInclude:
|
|
93
94
|
Exclude:
|
94
95
|
- 'lib/tasks/web.rake'
|
95
96
|
|
96
|
-
# Offense count:
|
97
|
+
# Offense count: 10
|
97
98
|
# This cop supports safe auto-correction (--auto-correct).
|
98
99
|
RSpec/ContextMethod:
|
99
100
|
Exclude:
|
100
101
|
- 'spec/slack/messages/formatting_spec.rb'
|
101
102
|
- 'spec/slack/web/api/mixins/users_spec.rb'
|
102
103
|
|
103
|
-
# Offense count:
|
104
|
+
# Offense count: 86
|
104
105
|
# Configuration parameters: Prefixes.
|
105
106
|
# Prefixes: when, with, without
|
106
107
|
RSpec/ContextWording:
|
107
108
|
Enabled: false
|
108
109
|
|
109
|
-
# Offense count:
|
110
|
+
# Offense count: 75
|
110
111
|
# Configuration parameters: CountAsOne.
|
111
112
|
RSpec/ExampleLength:
|
112
113
|
Max: 18
|
@@ -117,13 +118,13 @@ RSpec/ExampleLength:
|
|
117
118
|
RSpec/FilePath:
|
118
119
|
Enabled: false
|
119
120
|
|
120
|
-
# Offense count:
|
121
|
+
# Offense count: 86
|
121
122
|
# Configuration parameters: .
|
122
123
|
# SupportedStyles: have_received, receive
|
123
124
|
RSpec/MessageSpies:
|
124
125
|
EnforcedStyle: receive
|
125
126
|
|
126
|
-
# Offense count:
|
127
|
+
# Offense count: 103
|
127
128
|
RSpec/MultipleExpectations:
|
128
129
|
Max: 5
|
129
130
|
|
@@ -151,7 +152,7 @@ RSpec/StubbedMock:
|
|
151
152
|
- 'spec/slack/web/api/pagination/cursor_spec.rb'
|
152
153
|
- 'spec/slack/web/client_spec.rb'
|
153
154
|
|
154
|
-
# Offense count:
|
155
|
+
# Offense count: 14
|
155
156
|
RSpec/SubjectStub:
|
156
157
|
Exclude:
|
157
158
|
- 'spec/slack/web/api/mixins/conversations_spec.rb'
|
@@ -232,6 +233,14 @@ Style/OptionalBooleanParameter:
|
|
232
233
|
Exclude:
|
233
234
|
- 'spec/support/queue_with_timeout.rb'
|
234
235
|
|
236
|
+
# Offense count: 1
|
237
|
+
# This cop supports safe auto-correction (--auto-correct).
|
238
|
+
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods.
|
239
|
+
# AllowedMethods: present?, blank?, presence, try, try!
|
240
|
+
Style/SafeNavigation:
|
241
|
+
Exclude:
|
242
|
+
- 'lib/slack/web/api/helpers/files.rb'
|
243
|
+
|
235
244
|
# Offense count: 1
|
236
245
|
# This cop supports unsafe auto-correction (--auto-correct-all).
|
237
246
|
Style/SlicingWithRange:
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
### 2.7.0 (2025/07/20)
|
2
|
+
|
3
|
+
* [#554](https://github.com/slack-ruby/slack-ruby-client/pull/557): Require Faraday >= 2.0.1 - [@anrichvs](https://github.com/AnrichVS).
|
4
|
+
* [#559](https://github.com/slack-ruby/slack-ruby-client/pull/559): Enable name-to-id translation of non-public channels - [@eizengan](https://github.com/eizengan).
|
5
|
+
* [#560](https://github.com/slack-ruby/slack-ruby-client/pull/560): Name-to-id translation can supply all sensible list options - [@eizengan](https://github.com/eizengan).
|
6
|
+
* [#561](https://github.com/slack-ruby/slack-ruby-client/issues/563): Raise InvalidSignature when verifying a request without a signature - [@wesleyjellis](https://github.com/wesleyjellis).
|
7
|
+
* [#567](https://github.com/slack-ruby/slack-ruby-client/pull/567): Add support for multiple files in `files_upload_v2` - [@dblock](https://github.com/dblock).
|
8
|
+
|
1
9
|
### 2.6.0 (2025/05/24)
|
2
10
|
|
3
11
|
* [#549](https://github.com/slack-ruby/slack-ruby-client/pull/549): Add group ID formatting support for message mentions - [@n0h0](https://github.com/n0h0).
|
data/CONTRIBUTING.md
CHANGED
@@ -27,7 +27,7 @@ bundle exec rake
|
|
27
27
|
|
28
28
|
### Run Examples in Development
|
29
29
|
|
30
|
-
Sign up for Slack, create a private Slack team for yourself, then [generate an API token](https://api.slack.com/tutorials/tracks/getting-a-token) for your app and use it for some interactions.
|
30
|
+
Sign up for Slack, create a private Slack team for yourself, then [generate an API token](https://api.slack.com/tutorials/tracks/getting-a-token) for your app and use it for some interactions. To get a token you will need to install the app in a workspace, and use the "User OAuth Token" from installed app settings.
|
31
31
|
|
32
32
|
Try running the examples in the [examples](examples) directory.
|
33
33
|
|
data/README.md
CHANGED
@@ -4,7 +4,6 @@ Slack Ruby Client
|
|
4
4
|
[](http://badge.fury.io/rb/slack-ruby-client)
|
5
5
|
[](https://github.com/slack-ruby/slack-ruby-client/actions/workflows/integration_test.yml)
|
6
6
|
[](https://github.com/slack-ruby/slack-ruby-client/actions/workflows/test.yml)
|
7
|
-
[](https://codeclimate.com/github/slack-ruby/slack-ruby-client)
|
8
7
|
[](https://coveralls.io/github/slack-ruby/slack-ruby-client?branch=master)
|
9
8
|
|
10
9
|
A Ruby client for the Slack [Web](https://api.slack.com/web), [RealTime Messaging](https://api.slack.com/rtm) and [Events](https://api.slack.com/events-api) APIs. Comes with a handy command-line client, too. If you are not familiar with these concepts, you might want to watch [this video](http://code.dblock.org/2016/03/11/your-first-slack-bot-service-video.html).
|
@@ -82,7 +81,7 @@ A Ruby client for the Slack [Web](https://api.slack.com/web), [RealTime Messagin
|
|
82
81
|
|
83
82
|
## Stable Release
|
84
83
|
|
85
|
-
You're reading the documentation for the **stable** release of slack-ruby-client. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
|
84
|
+
You're reading the documentation for the **stable** release of slack-ruby-client 2.7.0. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
|
86
85
|
|
87
86
|
## Installation
|
88
87
|
|
@@ -174,6 +173,8 @@ Upload files with [sequenced API calls](https://api.slack.com/messaging/files#up
|
|
174
173
|
|
175
174
|
This library provides a helper method `files_upload_v2` that wraps the three separate API calls.
|
176
175
|
|
176
|
+
Upload a single file.
|
177
|
+
|
177
178
|
```ruby
|
178
179
|
client.files_upload_v2(
|
179
180
|
# required options
|
@@ -189,6 +190,19 @@ client.files_upload_v2(
|
|
189
190
|
)
|
190
191
|
```
|
191
192
|
|
193
|
+
Upload multiple files.
|
194
|
+
|
195
|
+
```ruby
|
196
|
+
client.files_upload_v2(
|
197
|
+
files: [
|
198
|
+
{ filename: 'report.pdf', content: File.read('/users/me/report.pdf'), title: 'Monthly Report' },
|
199
|
+
{ filename: 'data.csv', content: File.read('/users/me/data.csv'), title: 'Raw Data' }
|
200
|
+
],
|
201
|
+
channels: ['#general'],
|
202
|
+
initial_comment: 'Here are the monthly results!'
|
203
|
+
)
|
204
|
+
```
|
205
|
+
|
192
206
|
You can use a channel ID passed as `channel_id`, a single channel as `channel`, an array of channel IDs as `channels`, or a channel name or names (prefixed with `#`) in `files_upload_v2`. Lookup by name is not supported by the Slack API and this method called invokes `conversations_list` in order to locate the channel ID. This invocation can have a cost if you have many Slack channels and is only recommended when you intend to list channels anyway.
|
193
207
|
|
194
208
|
Note: This library includes a `files_upload` method that uses a deprecated endpoint `files.upload` that will [no longer be supported on 3/11/2025](https://api.slack.com/methods/files.upload#markdown).
|
@@ -35,3 +35,11 @@ puts client.files_upload_v2(
|
|
35
35
|
content: SecureRandom.hex,
|
36
36
|
channel_id: channel_id
|
37
37
|
).files.first.permalink_public
|
38
|
+
|
39
|
+
client.files_upload_v2(
|
40
|
+
files: [
|
41
|
+
{ filename: 'files_upload_v2_to_general_first_file.txt', content: SecureRandom.hex },
|
42
|
+
{ filename: 'files_upload_v2_to_general_second_file.txt', content: SecureRandom.hex }
|
43
|
+
],
|
44
|
+
channels: ['#general']
|
45
|
+
).files.each { |file| puts file.permalink_public }
|
data/lib/slack/events/request.rb
CHANGED
@@ -55,6 +55,7 @@ module Slack
|
|
55
55
|
# Returns true if the signature coming from Slack is valid.
|
56
56
|
def valid?
|
57
57
|
raise MissingSigningSecret unless signing_secret
|
58
|
+
raise InvalidSignature unless signature
|
58
59
|
|
59
60
|
digest = OpenSSL::Digest.new('SHA256')
|
60
61
|
signature_basestring = [version, timestamp, body].join(':')
|
data/lib/slack/version.rb
CHANGED
@@ -13,6 +13,8 @@ module Slack
|
|
13
13
|
# Name of the file being uploaded.
|
14
14
|
# @option params [string] :content
|
15
15
|
# File contents via a POST variable.
|
16
|
+
# @option params [Array<Hash>] :files
|
17
|
+
# Array of file objects with :filename, :content, and optionally :title, :alt_txt, :snippet_type.
|
16
18
|
# @option params [string] :alt_txt
|
17
19
|
# Description of image for screen-reader.
|
18
20
|
# @option params [string] :snippet_type
|
@@ -32,8 +34,16 @@ module Slack
|
|
32
34
|
# Never use a reply's ts value; use its parent instead.
|
33
35
|
# Also make sure to provide only one channel when using 'thread_ts'.
|
34
36
|
def files_upload_v2(params = {})
|
35
|
-
|
36
|
-
|
37
|
+
files_to_upload = if params[:files] && params[:files].is_a?(Array)
|
38
|
+
params[:files]
|
39
|
+
else
|
40
|
+
[params.slice(:filename, :content, :title, :alt_txt, :snippet_type)]
|
41
|
+
end
|
42
|
+
|
43
|
+
files_to_upload.each_with_index do |file, index|
|
44
|
+
%i[filename content].each do |param|
|
45
|
+
raise ArgumentError, "Required argument :#{param} missing in file (#{index})" if file[param].nil?
|
46
|
+
end
|
37
47
|
end
|
38
48
|
|
39
49
|
channel_params = %i[channel channels channel_id].map { |param| params[param] }.compact
|
@@ -53,31 +63,31 @@ module Slack
|
|
53
63
|
complete_upload_request_params[:channel_id] = params[:channel_id]
|
54
64
|
end
|
55
65
|
|
56
|
-
|
57
|
-
|
66
|
+
uploaded_files = files_to_upload.map do |file|
|
67
|
+
content = file[:content]
|
68
|
+
title = file[:title] || file[:filename]
|
58
69
|
|
59
|
-
|
60
|
-
|
70
|
+
upload_url_request_params = file.slice(:filename, :alt_txt, :snippet_type)
|
71
|
+
upload_url_request_params[:length] = content.bytesize
|
61
72
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
file_id = get_upload_url_response[:file_id]
|
73
|
+
get_upload_url_response = files_getUploadURLExternal(upload_url_request_params)
|
74
|
+
upload_url = get_upload_url_response[:upload_url]
|
75
|
+
file_id = get_upload_url_response[:file_id]
|
66
76
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
77
|
+
::Faraday::Connection.new(upload_url, options) do |connection|
|
78
|
+
connection.request :multipart
|
79
|
+
connection.request :url_encoded
|
80
|
+
connection.use ::Slack::Web::Faraday::Response::WrapError
|
81
|
+
connection.response :logger, logger if logger
|
82
|
+
connection.adapter adapter
|
83
|
+
end.post do |request|
|
84
|
+
request.body = content
|
85
|
+
end
|
77
86
|
|
78
|
-
|
79
|
-
|
87
|
+
{ id: file_id, title: title }
|
88
|
+
end
|
80
89
|
|
90
|
+
complete_upload_request_params[:files] = uploaded_files.to_json
|
81
91
|
files_completeUploadExternal(complete_upload_request_params)
|
82
92
|
end
|
83
93
|
end
|
@@ -12,12 +12,18 @@ module Slack
|
|
12
12
|
#
|
13
13
|
# @option options [channel] :channel
|
14
14
|
# Channel to get ID for, prefixed with #.
|
15
|
+
# @option options [string] :team_id
|
16
|
+
# The team id to search for channels in, required if token belongs to org-wide app.
|
17
|
+
# This field will be ignored if the API call is sent using a workspace-level token.
|
18
|
+
# @option options [boolean] :id_exclude_archived
|
19
|
+
# Set to true to exclude archived channels from the search
|
15
20
|
# @option options [integer] :id_limit
|
16
21
|
# The page size used for conversations_list calls required to find the channel's ID
|
22
|
+
# @option options [string] :id_types
|
23
|
+
# The types of conversations to use when searching for the ID. A comma-separated list
|
24
|
+
# containing one or more of public_channel, private_channel, mpim, im
|
17
25
|
def conversations_id(options = {})
|
18
26
|
name = options[:channel]
|
19
|
-
limit = options.fetch(:id_limit, Slack::Web.config.conversations_id_page_size)
|
20
|
-
|
21
27
|
raise ArgumentError, 'Required arguments :channel missing' if name.nil?
|
22
28
|
|
23
29
|
id_for(
|
@@ -26,7 +32,12 @@ module Slack
|
|
26
32
|
prefix: '#',
|
27
33
|
enum_method: :conversations_list,
|
28
34
|
list_method: :channels,
|
29
|
-
options: {
|
35
|
+
options: {
|
36
|
+
team_id: options.fetch(:team_id, nil),
|
37
|
+
exclude_archived: options.fetch(:id_exclude_archived, nil),
|
38
|
+
limit: options.fetch(:id_limit, Slack::Web.config.conversations_id_page_size),
|
39
|
+
types: options.fetch(:id_types, nil)
|
40
|
+
}.compact
|
30
41
|
)
|
31
42
|
end
|
32
43
|
end
|
@@ -12,12 +12,13 @@ module Slack
|
|
12
12
|
#
|
13
13
|
# @option options [user] :user
|
14
14
|
# User to get ID for, prefixed with '@'.
|
15
|
+
# @option options [string] :team_id
|
16
|
+
# The team id to search for users in, required if token belongs to org-wide app.
|
17
|
+
# This field will be ignored if the API call is sent using a workspace-level token.
|
15
18
|
# @option options [integer] :id_limit
|
16
19
|
# The page size used for users_list calls required to find the user's ID
|
17
20
|
def users_id(options = {})
|
18
21
|
name = options[:user]
|
19
|
-
limit = options.fetch(:id_limit, Slack::Web.config.users_id_page_size)
|
20
|
-
|
21
22
|
raise ArgumentError, 'Required arguments :user missing' if name.nil?
|
22
23
|
|
23
24
|
id_for(
|
@@ -26,7 +27,10 @@ module Slack
|
|
26
27
|
prefix: '@',
|
27
28
|
enum_method: :users_list,
|
28
29
|
list_method: :members,
|
29
|
-
options: {
|
30
|
+
options: {
|
31
|
+
team_id: options.fetch(:team_id, nil),
|
32
|
+
limit: options.fetch(:id_limit, Slack::Web.config.users_id_page_size)
|
33
|
+
}.compact
|
30
34
|
)
|
31
35
|
end
|
32
36
|
end
|
data/slack-ruby-client.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.homepage = 'http://github.com/slack-ruby/slack-ruby-client'
|
18
18
|
s.licenses = ['MIT']
|
19
19
|
s.summary = 'Slack Web and RealTime API client.'
|
20
|
-
s.add_dependency 'faraday', '>= 2.0'
|
20
|
+
s.add_dependency 'faraday', '>= 2.0.1'
|
21
21
|
s.add_dependency 'faraday-mashify'
|
22
22
|
s.add_dependency 'faraday-multipart'
|
23
23
|
s.add_dependency 'gli'
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Doubrovkine
|
8
|
+
autorequire:
|
8
9
|
bindir: bin
|
9
10
|
cert_chain: []
|
10
|
-
date: 2025-
|
11
|
+
date: 2025-07-20 00:00:00.000000000 Z
|
11
12
|
dependencies:
|
12
13
|
- !ruby/object:Gem::Dependency
|
13
14
|
name: faraday
|
@@ -15,14 +16,14 @@ dependencies:
|
|
15
16
|
requirements:
|
16
17
|
- - ">="
|
17
18
|
- !ruby/object:Gem::Version
|
18
|
-
version:
|
19
|
+
version: 2.0.1
|
19
20
|
type: :runtime
|
20
21
|
prerelease: false
|
21
22
|
version_requirements: !ruby/object:Gem::Requirement
|
22
23
|
requirements:
|
23
24
|
- - ">="
|
24
25
|
- !ruby/object:Gem::Version
|
25
|
-
version:
|
26
|
+
version: 2.0.1
|
26
27
|
- !ruby/object:Gem::Dependency
|
27
28
|
name: faraday-mashify
|
28
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,6 +94,7 @@ dependencies:
|
|
93
94
|
- - ">="
|
94
95
|
- !ruby/object:Gem::Version
|
95
96
|
version: '0'
|
97
|
+
description:
|
96
98
|
email: dblock@dblock.org
|
97
99
|
executables:
|
98
100
|
- slack
|
@@ -408,6 +410,7 @@ licenses:
|
|
408
410
|
metadata:
|
409
411
|
rubygems_mfa_required: 'true'
|
410
412
|
changelog_uri: https://github.com/slack-ruby/slack-ruby-client/blob/master/CHANGELOG.md
|
413
|
+
post_install_message:
|
411
414
|
rdoc_options: []
|
412
415
|
require_paths:
|
413
416
|
- lib
|
@@ -422,7 +425,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
422
425
|
- !ruby/object:Gem::Version
|
423
426
|
version: 1.3.6
|
424
427
|
requirements: []
|
425
|
-
rubygems_version: 3.
|
428
|
+
rubygems_version: 3.5.16
|
429
|
+
signing_key:
|
426
430
|
specification_version: 4
|
427
431
|
summary: Slack Web and RealTime API client.
|
428
432
|
test_files: []
|