Method: SlackNotification#deliver_message

Defined in:
lib/app/models/slack_notification.rb

#deliver_messageObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/app/models/slack_notification.rb', line 34

def deliver_message
  if SystemConfiguration.slack_configured?
    start_processing
    payload = { text: message }
    payload[:channel] = to.presence || SystemConfiguration.slack_support_channel
    # Use the environment as the default, otherwise set it as the from
    payload[:username] = from.presence || Rails.env
    # Setup the delivery method for this message only.
    RestClient.post(SystemConfiguration.slack_api_url, payload.to_json)
    finish_processing
  else
    finish_processing 'Slack is not configured'
  end
rescue StandardError => error
  log_warn '!!! Error sending SLACK notification !!!', error
  finish_processing error.message
end