aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2012-11-23 15:08:14 +0000
committerPatrick J Cherry <patrick@bytemark.co.uk>2012-11-23 15:08:14 +0000
commit4e93857386ca1c4d6ad744195a672c25f2fb45ae (patch)
tree89cb61163deef297bc55076b855fa04d1e171c16 /lib
parentbad279e6bdd0cb06325c7a07ba38156ff52da68c (diff)
Tidied notifier a little. Alert#cached_alert_group is reset before notification.
Diffstat (limited to 'lib')
-rw-r--r--lib/mauve/notifier.rb11
1 files changed, 9 insertions, 2 deletions
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