From b5b4b4b611cb493cf6eb12b4d5228bf45fd23433 Mon Sep 17 00:00:00 2001 From: Kristian Garza Date: Tue, 20 Nov 2018 22:37:07 +0100 Subject: [PATCH] notifications --- app/jobs/usage_update_parse_job.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/jobs/usage_update_parse_job.rb b/app/jobs/usage_update_parse_job.rb index 6763de84..9fcffeff 100644 --- a/app/jobs/usage_update_parse_job.rb +++ b/app/jobs/usage_update_parse_job.rb @@ -1,6 +1,9 @@ class UsageUpdateParseJob < ActiveJob::Base queue_as :levriero + ICON_URL = "https://raw.githubusercontent.com/datacite/toccatore/master/lib/toccatore/images/toccatore.png" + + def perform(item, options={}) logger = Logger.new(STDOUT) response = UsageUpdate.get_data(item, options) @@ -40,6 +43,17 @@ def send_message data, item, options={} end logger.info text - send_notification_to_slack(text, options) if options[:slack_webhook_url].present? + + if options[:slack_webhook_url].present? + attachment = { + title: options[:title] || "Report", + text: text, + color: options[:level] || "good" + } + notifier = Slack::Notifier.new options[:slack_webhook_url], + username: "Event Data Agent", + icon_url: ICON_URL + notifier.post attachments: [attachment] + end end end