From 9aaae075b7c9f03adc80c84597e4e0bb65a07cff Mon Sep 17 00:00:00 2001 From: Michael Beard Date: Tue, 30 Jul 2024 10:19:07 -0500 Subject: [PATCH] Updates slack_service.rb to include local/demo console printout message --- app/services/slack_service.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/services/slack_service.rb b/app/services/slack_service.rb index 565452e328e..ba61aa1f07d 100644 --- a/app/services/slack_service.rb +++ b/app/services/slack_service.rb @@ -23,12 +23,16 @@ def initialize(url: ENV["SLACK_DISPATCH_ALERT_URL"]) attr_reader :url def send_notification(msg, title = "", channel = DEFAULT_CHANNEL) - return unless url && (aws_env == "uat" || aws_env == "prodtest" || aws_env == "prod") - slack_msg = format_slack_msg(msg, title, channel) - params = { body: slack_msg.to_json, headers: { "Content-Type" => "application/json" } } - http_service.post(url, params) + if url && (Rails.deploy_env?(:uat) || Rails.deploy_env?(:prodtest) || Rails.deploy_env?(:prod)) + params = { body: slack_msg.to_json, headers: { "Content-Type" => "application/json" } } + http_service.post(url, params) + else + # rubocop:disable Rails/Output + Rails.logger.info(pp(slack_msg)) + # rubocop:enable Rails/Output + end end private @@ -61,7 +65,7 @@ def format_slack_msg(msg, title, channel) channel.prepend("#") unless channel.match?(/^#/) { - username: "Caseflow (#{aws_env})", + username: "Caseflow (#{Rails.deploy_env})", channel: channel, attachments: [ { @@ -72,8 +76,4 @@ def format_slack_msg(msg, title, channel) ] } end - - def aws_env - ENV.fetch("DEPLOY_ENV", "development") - end end