From 4e93857386ca1c4d6ad744195a672c25f2fb45ae Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Fri, 23 Nov 2012 15:08:14 +0000 Subject: Tidied notifier a little. Alert#cached_alert_group is reset before notification. --- lib/mauve/notifier.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/mauve/notifier.rb') diff --git a/lib/mauve/notifier.rb b/lib/mauve/notifier.rb index acbbab4..d433e96 100644 --- a/lib/mauve/notifier.rb +++ b/lib/mauve/notifier.rb @@ -36,15 +36,22 @@ module Mauve # This sends the notification for an alert # def notify(alert, at) + # + # Make sure we're looking at a fresh copy of the alert. + # alert.reload + if alert.alert_group.nil? logger.warn "Could not notify for #{alert} since there are no matching alert groups" + else + # Forces alert-group to be re-evaluated on notification. + alert.cached_alert_group = nil alert.alert_group.notify(alert, at) # - # This saves without callbacks. + # This saves without callbacks if the alert has been altered. # - alert.save! if alert.is_a?(Alert) and alert.original_attributes.has_key?("cached_alert_group") + alert.save! if alert.dirty? end end -- cgit v1.2.1