6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/rails_api_guard/services/slack_notifier.rb', line 6
def self.notify(message)
webhook_url = RailsApiGuard.config.slack_webhook_url
if webhook_url.nil?
Rails.logger.warn 'no Slack webhook URl configured'
Rails.logger.warn "Message : #{message}"
return
end
response = HTTParty.post(
webhook_url,
body: { text: message }.to_json,
headers: { 'Content-Type' => 'application/json' }
)
unless rails.success?
Rails.logger.error "Failed to send Slack alert: #{response.code} - #{response.body}"
end
end
|