Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Commit 4f81318

Browse files
committed
Do not deactivate teams that have upgraded oauth v1 to v2.
1 parent 54ac5b5 commit 4f81318

File tree

6 files changed

+10
-8
lines changed

6 files changed

+10
-8
lines changed

.rubocop_todo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2020-11-25 13:42:05 -0500 using RuboCop version 0.81.0.
3+
# on 2020-11-27 15:32:33 -0500 using RuboCop version 0.81.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new

Gemfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,3 @@ end
3838
group :test do
3939
gem 'slack-ruby-danger', '~> 0.2.0', require: false
4040
end
41-
42-
gem 'slack-ruby-bot-server', github: 'dblock/slack-ruby-bot-server', branch: 'oauth-version'

lib/slack-ruby-bot-server-rtm/lifecycle.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
end
2929

3030
SlackRubyBotServer::Config.service_class.instance.on :deactivated do |team, _error, _options|
31-
SlackRubyBotServer::Config.service_class.instance.logger.info "De-activating real-time team #{team}."
31+
SlackRubyBotServer::Config.service_class.instance.logger.info "De-activated real-time team #{team}."
3232
team.server = nil
3333
end

lib/slack-ruby-bot-server-rtm/server.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ def self.start_server!(team, server, wait = 1)
2323
rescue StandardError => e
2424
SlackRubyBotServer::Config.service_class.instance.send(:run_callbacks, :error, team, e)
2525
case e.message
26-
when 'account_inactive', 'invalid_auth' then
27-
SlackRubyBotServer::Config.service_class.instance.logger.error "#{team.name}: #{e.message}, team will be deactivated."
28-
SlackRubyBotServer::Config.service_class.instance.deactivate! team
26+
when 'account_inactive', 'invalid_auth'
27+
if team.respond_to?(:oauth_version) && team.oauth_version != 'v1'
28+
SlackRubyBotServer::Config.service_class.instance.logger.info "#{team.name}: #{e.message}, team OAuth scope has been upgraded."
29+
else
30+
SlackRubyBotServer::Config.service_class.instance.logger.error "#{team.name}: #{e.message}, team will be deactivated."
31+
SlackRubyBotServer::Config.service_class.instance.deactivate! team
32+
end
2933
else
3034
wait = e.retry_after if e.is_a?(Slack::Web::Api::Errors::TooManyRequestsError)
3135
SlackRubyBotServer::Config.service_class.instance.logger.error "#{team.name}: #{e.message}, restarting in #{wait} second(s)."

sample_apps/sample_app_activerecord/Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ gem 'otr-activerecord', '~> 1.2.1'
88
gem 'pg'
99
gem 'rack-server-pages'
1010
gem 'rack-test'
11-
gem 'slack-ruby-bot-server', github: 'dblock/slack-ruby-bot-server', branch: 'oauth-version'
1211
gem 'slack-ruby-bot-server-rtm', path: '../../'
1312
gem 'unicorn'
1413

spec/slack-ruby-bot-server-rtm/server_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@
2929
pending 'handles account_inactive'
3030
pending 'handles invalid_auth'
3131
pending 'handles generic error'
32+
pending 'does not deactivate a team that has upgraded oauth from v1 to v2'
3233
end
3334
end

0 commit comments

Comments
 (0)