diff --git a/.env.example b/.env.example index a15f32f..c8e403d 100644 --- a/.env.example +++ b/.env.example @@ -4,9 +4,10 @@ PORT=4000 SLACK_CLIENT_ID=your_client_id_here SLACK_CLIENT_SECRET=your_client_secret_here SLACK_SIGNING_SECRET=your_signing_secret_here -SLACK_TEAM_ID=your_slack_workspace_id -SLACK_USER_OAUTH_TOKEN=your_user_oauth_token_here -SLACK_BOT_OAUTH_TOKEN=your_bot_oauth_token_here + +# Sailors' log slack app +SLACK_SAILORS_LOG_SIGNING_SECRET=your_signing_secret_here +SLACK_SAILORS_LOG_BOT_OAUTH_TOKEN=your_bot_oauth_token_here WAKATIME_DATABASE_URL=your_wakatime_database_url_here diff --git a/app/controllers/slack_controller.rb b/app/controllers/slack_controller.rb index 1f29cd6..59af6c1 100644 --- a/app/controllers/slack_controller.rb +++ b/app/controllers/slack_controller.rb @@ -56,7 +56,7 @@ class SlackController < ApplicationController # Skip verification in development return true if Rails.env.development? - slack_signing_secret = ENV["SLACK_SIGNING_SECRET"] + slack_signing_secret = ENV["SAILORS_LOG_SLACK_SIGNING_SECRET"] sig_basestring = "v0:#{timestamp}:#{request.raw_post}" my_signature = "v0=" + OpenSSL::HMAC.hexdigest("SHA256", slack_signing_secret, sig_basestring) diff --git a/app/jobs/sailors_log_notify_job.rb b/app/jobs/sailors_log_notify_job.rb index 15bba78..b4a6d2a 100644 --- a/app/jobs/sailors_log_notify_job.rb +++ b/app/jobs/sailors_log_notify_job.rb @@ -25,7 +25,7 @@ class SailorsLogNotifyJob < ApplicationJob message = ":boat: <@#{slack_uid}> just coded 1 more hour on *#{project_name}* (total: #{hours}hrs). _#{kudos_message}_" - response = HTTP.auth("Bearer #{ENV['SLACK_BOT_OAUTH_TOKEN']}") + response = HTTP.auth("Bearer #{ENV['SAILORS_LOG_SLACK_BOT_OAUTH_TOKEN']}") .post("https://slack.com/api/chat.postMessage", json: { channel: slack_channel_id, diff --git a/config/initializers/slack.rb b/config/initializers/slack.rb deleted file mode 100644 index 36cb450..0000000 --- a/config/initializers/slack.rb +++ /dev/null @@ -1,3 +0,0 @@ -Slack.configure do |config| - config.token = ENV["SLACK_BOT_OAUTH_TOKEN"] # Using the existing env variable name -end diff --git a/config/routes.rb b/config/routes.rb index a63d1e0..8130882 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -44,5 +44,7 @@ Rails.application.routes.draw do get "my/settings", to: "users#edit", as: :my_settings patch "my/settings", to: "users#update" - post "/slack/commands", to: "slack#create" + namespace :sailors_log do + post "/slack/commands", to: "slack#create" + end end