slack-ruby-bot-server 1.1.0 → 1.2.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: d96988aebe8c1dadd75c95e086ad63f5aaa81a8c93ecb1a92ae2f6a1908f6b6d
4
- data.tar.gz: a1519cf75e0afadc610fc92b975613d7817c5a8cf243f849c6ecb9587e504df0
3
+ metadata.gz: 4f81d3aefa974e927adeaa66b98092695463ff4f4dc8d1c0294a0efb7c824c01
4
+ data.tar.gz: 17731a13443a9c2cdc4e8bfa0183501c07395c670a04b4fa45efdaec503cd30e
5
5
  SHA512:
6
- metadata.gz: e52881e9b3faa4754a4c582eb9269a6b9eacf0f3f80f4dc20d7332e0d9304d2580b47185409ace983422f6e800bd2ae9bed00d3829eb457c4299eee5294630c3
7
- data.tar.gz: 91a903e372af38353a914d61f04d1e7016e1e25edf3f9b41afeee523279c1b5c29fefb23ec8d1acc1bb6fdaaf8b6cd0ef4d1c6a2b2f1ac9707ac036a22f4881e
6
+ metadata.gz: d2f99691dda8529a626456196f0359fd0a16e5ee28c831e23f7fc061038fb95b34b9bb0dc10cba562490c2d2b8b84bf23530d6d2e489e7747100e360d7fef8f9
7
+ data.tar.gz: ecb8a80e8c191111daab48367d7f9d2afa0a9ee0618d9ad339484af25e6a80cf36af9c047295a626b43403e94514343b19a383b7ecdb97d3875133fec8ab669f
@@ -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): Add support for OAuth v2 - [@dblock](https://github.com/dblock).
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). 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.
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
 
@@ -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 SlackRubyBotServer::Config.oauth_version
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,
@@ -18,6 +18,8 @@ module SlackRubyBotServer
18
18
  t.string :name
19
19
  t.string :domain
20
20
  t.string :token
21
+ t.string :oauth_scope
22
+ t.string :oauth_version, default: 'v1', null: false
21
23
  t.string :bot_user_id
22
24
  t.string :activated_user_id
23
25
  t.string :activated_user_access_token
@@ -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
@@ -1,3 +1,3 @@
1
1
  module SlackRubyBotServer
2
- VERSION = '1.1.0'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
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.1.0
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-17 00:00:00.000000000 Z
11
+ date: 2020-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async