aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2012-04-27 10:58:36 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2012-04-27 10:58:36 +0100
commit5ad5aea6512f43a06e720d0b8e0fbf405d532dca (patch)
tree12d91d81962bf32972ddd6097c815e2ccdad9cd3 /lib/mauve
parent050d56934033c1cb1c2a6e613c706e3415acbd53 (diff)
Added default configuration options for a person.
Diffstat (limited to 'lib/mauve')
-rw-r--r--lib/mauve/configuration_builders/person.rb23
-rw-r--r--lib/mauve/person.rb29
2 files changed, 39 insertions, 13 deletions
diff --git a/lib/mauve/configuration_builders/person.rb b/lib/mauve/configuration_builders/person.rb
index 7a20491..afb967b 100644
--- a/lib/mauve/configuration_builders/person.rb
+++ b/lib/mauve/configuration_builders/person.rb
@@ -72,10 +72,31 @@ module Mauve
def created_person(person)
name = person.username
raise ArgumentError.new("Duplicate person '#{name}'") if @result.people[name]
+
#
# Add a default notification threshold
#
- person.notification_thresholds[60] = Array.new(10) if person.notification_thresholds.empty?
+ person.notification_thresholds[600] = Array.new(5) if person.notification_thresholds.empty?
+
+ #
+ # Add a default notify clause
+ #
+ if person.notifications.empty?
+ default_notification = Notification.new(person)
+ default_notification.every = 30.minutes
+ default_notification.during = lambda { working_hours? }
+ person.notifications << default_notification
+ end
+
+ #
+ # Set up some default notify levels.
+ #
+ if person.urgent.nil? and person.normal.nil? and person.low.nil?
+ person.urgent = lambda { sms ; xmpp ; email }
+ person.normal = lambda { xmpp ; email }
+ person.low = lambda { email }
+ end
+
@result.people[person.username] = person
end
diff --git a/lib/mauve/person.rb b/lib/mauve/person.rb
index 929f511..9ea36f7 100644
--- a/lib/mauve/person.rb
+++ b/lib/mauve/person.rb
@@ -22,10 +22,8 @@ module Mauve
@username = username
@password = nil
- @urgent = lambda { false }
- @normal = lambda { false }
- @low = lambda { false }
- @email = @sms = @xmpp = nil
+ @urgent = @normal = @low = nil
+ @email = @sms = @xmpp = nil
@notify_when_on_holiday = @notify_when_off_sick = false
end
@@ -240,14 +238,21 @@ module Mauve
return true
end
- result = NotificationCaller.new(
- self,
- alert,
- [],
- # current_alerts,
- {:will_suppress => will_suppress,
- :was_suppressed => was_suppressed, }
- ).instance_eval(&__send__(level))
+ result = false
+
+ #
+ # Make sure the level we want has been defined as a Proc.
+ #
+ if __send__(level).is_a?(Proc)
+ result = NotificationCaller.new(
+ self,
+ alert,
+ [],
+ # current_alerts,
+ {:will_suppress => will_suppress,
+ :was_suppressed => was_suppressed, }
+ ).instance_eval(&__send__(level))
+ end
if [result].flatten.any?
#