Skip to content

Commit

Permalink
Merge pull request #22 from jusleg/stop-freezing-client
Browse files Browse the repository at this point in the history
Stop freezing client
  • Loading branch information
jusleg authored Mar 5, 2022
2 parents 3934ff9 + 0ff4812 commit 5155260
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 10 deletions.
3 changes: 1 addition & 2 deletions app/controllers/concerns/slack_token_verify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ def verify_token
end

signature = "v0:#{timestamp}:#{request_body}"
calculated_hmac = "v0=" +
OpenSSL::HMAC.hexdigest("sha256", Slackify.configuration.slack_secret_token, signature)
calculated_hmac = "v0=#{OpenSSL::HMAC.hexdigest('sha256', Slackify.configuration.slack_secret_token, signature)}"

return if ActiveSupport::SecurityUtils.secure_compare(calculated_hmac, hmac_header)

Expand Down
1 change: 1 addition & 0 deletions lib/slackify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
module Slackify
class << self
attr_writer :configuration

def configuration
@configuration ||= Configuration.new
end
Expand Down
2 changes: 1 addition & 1 deletion lib/slackify/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def remove_unhandled_handler
# Set the token that we will use to connect to slack
def slack_bot_token=(token)
@slack_bot_token = token
@slack_client = Slack::Web::Client.new(token: token).freeze
@slack_client = Slack::Web::Client.new(token: token)
end

# Set a handler for a specific message subtype
Expand Down
1 change: 1 addition & 0 deletions lib/slackify/handlers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def allow_slash_method(element)
# Any class inheriting from Slackify::Handler::Base will be added to
# the list of supported handlers
def inherited(subclass)
super
@@supported_handlers.push(subclass.to_s)
end

Expand Down
1 change: 1 addition & 0 deletions lib/slackify/parameter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class << self
# Any class inheriting from Slackify::Parameter will be added to
# the list of supported parameters
def inherited(subclass)
super
@@supported_parameters.push(subclass.to_s)
end

Expand Down
2 changes: 1 addition & 1 deletion slackify.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |s|
s.name = 'slackify'
s.version = '0.4.0'
s.version = '0.4.1'
s.date = '2019-12-11'
s.summary = 'Slackbot framework for Rails using the Events API'
s.description = 'Slackbot framework for Rails using the Events API. Supports events, interactive messages and slash commands.'
Expand Down
1 change: 1 addition & 0 deletions test/dummy/app/models/user_param.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class UserParam < Slackify::Parameter
def initialize(value)
super()
@value = value
end

Expand Down
2 changes: 1 addition & 1 deletion test/dummy/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')

if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger = ActiveSupport::Logger.new($stdout)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end
Expand Down
6 changes: 3 additions & 3 deletions test/dummy/config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum; this matches the default thread size of Active Record.
#
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
threads_count = ENV.fetch("RAILS_MAX_THREADS", 5)
threads threads_count, threads_count

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }
port ENV.fetch("PORT", 3000)

# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }
environment ENV.fetch("RAILS_ENV", "development")

# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together
Expand Down
3 changes: 1 addition & 2 deletions test/slack_test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ def build_legacy_slack_interactive_callback(**options)

def build_webhook_headers(params, timestamp: Time.now, token: "123abcslacksecrettokenabc123")
{
"X-Slack-Signature": "v0=" +
OpenSSL::HMAC.hexdigest("sha256", token, "v0:#{timestamp.to_i}:#{params.to_json}"),
"X-Slack-Signature": "v0=#{OpenSSL::HMAC.hexdigest('sha256', token, "v0:#{timestamp.to_i}:#{params.to_json}")}",
"X-Slack-Request-Timestamp": timestamp.to_i,
}
end
Expand Down

0 comments on commit 5155260

Please sign in to comment.