Module: ActionSlack::Notifier

Defined in:
lib/action_slack/notifier.rb

Class Method Summary collapse

Class Method Details

.notify(url:, message:) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/action_slack/notifier.rb', line 7

def notify(url:, message:)
  message = ActionSlack.configuration.testflight? ? "[ActionSlack Test Posting]\n#{message}\n" : message

  if ActionSlack.configuration.async?
    notify_later(url, message)
  else
    notify_now(url, message)
  end
end

.notify_later(url, message) ⇒ Object



27
28
29
# File 'lib/action_slack/notifier.rb', line 27

def notify_later(url, message)
  SendJob.perform_later(url: url, message: message)
end

.notify_now(url, message) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/action_slack/notifier.rb', line 17

def notify_now(url, message)
  if ActionSlack.configuration.local?
    ActionSlack.logger.debug { "Post to Slack webhook url: #{url}, message: \"#{message}\"" }
  else
    ActionSlack.logger.info { "Start posting to Slack webhook url: #{url}, message: \"#{message}\"" }
    Slack::Notifier.new(url).post(text: message)
    ActionSlack.logger.info 'Posted to Slack'
  end
end