slack-ruby-bot-server 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +2 -2
- data/UPGRADING.md +22 -0
- data/lib/slack-ruby-bot-server/api/endpoints/teams_endpoint.rb +10 -1
- data/lib/slack-ruby-bot-server/config/database_adapters/activerecord.rb +2 -0
- data/lib/slack-ruby-bot-server/models/team/mongoid.rb +2 -0
- data/lib/slack-ruby-bot-server/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f81d3aefa974e927adeaa66b98092695463ff4f4dc8d1c0294a0efb7c824c01
|
4
|
+
data.tar.gz: 17731a13443a9c2cdc4e8bfa0183501c07395c670a04b4fa45efdaec503cd30e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2f99691dda8529a626456196f0359fd0a16e5ee28c831e23f7fc061038fb95b34b9bb0dc10cba562490c2d2b8b84bf23530d6d2e489e7747100e360d7fef8f9
|
7
|
+
data.tar.gz: ecb8a80e8c191111daab48367d7f9d2afa0a9ee0618d9ad339484af25e6a80cf36af9c047295a626b43403e94514343b19a383b7ecdb97d3875133fec8ab669f
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
### Changelog
|
2
2
|
|
3
|
+
#### 1.2.0 (2020/11/27)
|
4
|
+
|
5
|
+
* [#133](https://github.com/slack-ruby/slack-ruby-bot-server/pull/133): Added `Team#oauth_version` and `#scope` - [@dblock](https://github.com/dblock).
|
6
|
+
|
3
7
|
#### 1.1.0 (2020/11/17)
|
4
8
|
|
5
|
-
* [#132](https://github.com/slack-ruby/slack-ruby-bot-server/pull/132):
|
9
|
+
* [#132](https://github.com/slack-ruby/slack-ruby-bot-server/pull/132): Added support for OAuth v2 - [@dblock](https://github.com/dblock).
|
6
10
|
|
7
11
|
#### 1.0.0 (2020/11/15)
|
8
12
|
|
data/README.md
CHANGED
@@ -38,7 +38,7 @@ A library that contains a web server and a RESTful [Grape](http://github.com/rub
|
|
38
38
|
|
39
39
|
## Stable Release
|
40
40
|
|
41
|
-
You're reading the documentation for the **stable** release of slack-ruby-bot-server. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
|
41
|
+
You're reading the documentation for the **stable** release of slack-ruby-bot-server, v1.2.0. See [UPGRADING](UPGRADING.md) when upgrading from an older version.
|
42
42
|
|
43
43
|
## Make Your Own
|
44
44
|
|
@@ -272,7 +272,7 @@ end
|
|
272
272
|
|
273
273
|
### Access Tokens
|
274
274
|
|
275
|
-
By default the implementation of [Team](lib/slack-ruby-bot-server/models/team) stores the value of the token with all the requested OAuth scopes in both `token` and `activated_user_access_token` (for backwards compatibility)
|
275
|
+
By default the implementation of [Team](lib/slack-ruby-bot-server/models/team) stores the value of the token with all the requested OAuth scopes in both `token` and `activated_user_access_token` (for backwards compatibility), along with `oauth_version` and `oauth_scope`. If a legacy Slack bot integration `bot_access_token` is present, it is stored as `token`, and `activated_user_access_token` is the token that has all the requested OAuth scopes.
|
276
276
|
|
277
277
|
## Sample Bots Using Slack Ruby Bot Server
|
278
278
|
|
data/UPGRADING.md
CHANGED
@@ -1,6 +1,28 @@
|
|
1
1
|
Upgrading Slack-Ruby-Bot-Server
|
2
2
|
===============================
|
3
3
|
|
4
|
+
### Upgrading to >= 1.2.0
|
5
|
+
|
6
|
+
#### New Team Fields
|
7
|
+
|
8
|
+
The following fields have been added to `Team`.
|
9
|
+
|
10
|
+
* `oauth_scope`: Slack OAuth scope
|
11
|
+
* `oauth_version`: Slack OAuth version used
|
12
|
+
|
13
|
+
No action is required for Mongoid.
|
14
|
+
|
15
|
+
If you're using ActiveRecord, create a migration to add these fields.
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
class AddOauthFields < ActiveRecord::Migration[5.0]
|
19
|
+
def change
|
20
|
+
add_column :teams, :oauth_scope, :string
|
21
|
+
add_column :teams, :oauth_version, :string, default: 'v1', null: false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
```
|
25
|
+
|
4
26
|
### Upgrading to >= 1.1.0
|
5
27
|
|
6
28
|
#### Extracted RealTime (Legacy) Support
|
@@ -54,8 +54,10 @@ module SlackRubyBotServer
|
|
54
54
|
bot_user_id = nil
|
55
55
|
team_id = nil
|
56
56
|
team_name = nil
|
57
|
+
oauth_scope = nil
|
58
|
+
oauth_version = SlackRubyBotServer::Config.oauth_version
|
57
59
|
|
58
|
-
case
|
60
|
+
case oauth_version
|
59
61
|
when :v2
|
60
62
|
access_token = rc.access_token
|
61
63
|
token = rc.access_token
|
@@ -63,6 +65,7 @@ module SlackRubyBotServer
|
|
63
65
|
bot_user_id = rc.bot_user_id
|
64
66
|
team_id = rc.team&.id
|
65
67
|
team_name = rc.team&.name
|
68
|
+
oauth_scope = rc.scope
|
66
69
|
when :v1
|
67
70
|
access_token = rc.access_token
|
68
71
|
bot = rc.bot if rc.key?(:bot)
|
@@ -71,15 +74,19 @@ module SlackRubyBotServer
|
|
71
74
|
bot_user_id = bot ? bot.bot_user_id : nil
|
72
75
|
team_id = rc.team_id
|
73
76
|
team_name = rc.team_name
|
77
|
+
oauth_scope = rc.scope
|
74
78
|
end
|
75
79
|
|
76
80
|
team = Team.where(token: token).first
|
81
|
+
team ||= Team.where(team_id: team_id, oauth_version: oauth_version).first
|
77
82
|
team ||= Team.where(team_id: team_id).first
|
78
83
|
|
79
84
|
if team
|
80
85
|
team.ping_if_active!
|
81
86
|
|
82
87
|
team.update_attributes!(
|
88
|
+
oauth_version: oauth_version,
|
89
|
+
oauth_scope: oauth_scope,
|
83
90
|
activated_user_id: user_id,
|
84
91
|
activated_user_access_token: access_token,
|
85
92
|
bot_user_id: bot_user_id
|
@@ -91,6 +98,8 @@ module SlackRubyBotServer
|
|
91
98
|
else
|
92
99
|
team = Team.create!(
|
93
100
|
token: token,
|
101
|
+
oauth_version: oauth_version,
|
102
|
+
oauth_scope: oauth_scope,
|
94
103
|
team_id: team_id,
|
95
104
|
name: team_name,
|
96
105
|
activated_user_id: user_id,
|
@@ -8,6 +8,8 @@ class Team
|
|
8
8
|
field :name, type: String
|
9
9
|
field :domain, type: String
|
10
10
|
field :token, type: String
|
11
|
+
field :oauth_scope, type: String
|
12
|
+
field :oauth_version, type: String, default: 'v1'
|
11
13
|
field :active, type: Boolean, default: true
|
12
14
|
field :bot_user_id, type: String
|
13
15
|
field :activated_user_id, type: String
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack-ruby-bot-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Doubrovkine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|