aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve/alert_group.rb
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2012-05-03 19:42:20 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2012-05-03 19:42:20 +0100
commit58f5a950200f5957307a8552b92ce9e92f948b73 (patch)
treee7e5dbf2178dfd46e88e8e6d60d6665c58b538fa /lib/mauve/alert_group.rb
parent3a008fd3fff00852533d0df1f597595505373c6b (diff)
* Person and people lists have now become interchangeable, with notifications
only recording the username, rather than the Person/PeopleList. This means that notifications in alert groups can use default #during clauses and #every values from people lists and persons. * Notify clauses can now take an array of persons/people_lists, and people_lists can refer to other people lists. * PeopleList names are now in the same namespace as usernames. * Tests to go with.
Diffstat (limited to 'lib/mauve/alert_group.rb')
-rw-r--r--lib/mauve/alert_group.rb24
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/mauve/alert_group.rb b/lib/mauve/alert_group.rb
index 05488fd..76c2e98 100644
--- a/lib/mauve/alert_group.rb
+++ b/lib/mauve/alert_group.rb
@@ -157,9 +157,17 @@ module Mauve
#
# This is where we set the reminder -- i.e. on a per-alert-group basis.
-
+ #
remind_at = nil
- notifications.each do |notification|
+
+ these_notifications = self.resolve_notifications(at)
+
+ these_notifications.each do |notification|
+ #
+ # Make sure the level is set.
+ #
+ notification.level = self.level
+
#
# Create a new during_runner for this notification clause, and keep it
# handy.
@@ -208,7 +216,7 @@ module Mauve
# The notifications are specified in the config file.
#
sent_to = []
- notifications.each do |notification|
+ these_notifications.each do |notification|
sent_to << notification.notify(alert, sent_to, during_runners.shift)
end
@@ -240,6 +248,16 @@ module Mauve
[LEVELS.index(self.level), self.name] <=> [LEVELS.index(other.level), other.name]
end
+ #
+ #
+ #
+ def resolve_notifications(at = Time.now)
+ self.notifications.collect do |notification|
+ notification.people.collect do |person|
+ person.resolve_notifications(notification.every, notification.during, at)
+ end
+ end.flatten.compact
+ end
end
end