Skip to content

Commit

Permalink
Updates slack_service.rb to include local/demo console printout messa…
Browse files Browse the repository at this point in the history
…ge (#22343)
  • Loading branch information
mbeardy authored Aug 2, 2024
1 parent 8928874 commit b73a390
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions app/services/slack_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: [
{
Expand All @@ -72,8 +76,4 @@ def format_slack_msg(msg, title, channel)
]
}
end

def aws_env
ENV.fetch("DEPLOY_ENV", "development")
end
end

0 comments on commit b73a390

Please sign in to comment.