aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mauve')
-rw-r--r--lib/mauve/alert.rb7
-rw-r--r--lib/mauve/alert_changed.rb6
-rw-r--r--lib/mauve/notification.rb2
-rw-r--r--lib/mauve/notifier.rb14
-rw-r--r--lib/mauve/notifiers/debug.rb12
5 files changed, 16 insertions, 25 deletions
diff --git a/lib/mauve/alert.rb b/lib/mauve/alert.rb
index 706b0e3..28079a2 100644
--- a/lib/mauve/alert.rb
+++ b/lib/mauve/alert.rb
@@ -401,12 +401,7 @@ module Mauve
#
# @return [Boolean] Showing if an alert has been sent.
def notify(at = Time.now)
- if self.alert_group.nil?
- logger.warn "Could not notify for #{self} since there are no matching alert groups"
- false
- else
- self.alert_group.notify(self, at)
- end
+ Server.notification_push([self, at])
end
# Acknowledge an alert
diff --git a/lib/mauve/alert_changed.rb b/lib/mauve/alert_changed.rb
index 7cfdb76..0e0d257 100644
--- a/lib/mauve/alert_changed.rb
+++ b/lib/mauve/alert_changed.rb
@@ -98,7 +98,11 @@ module Mauve
return save
end
- alert_group.notify(alert, Time.now)
+ #
+ # Push this notifitcation onto the queue.
+ #
+ Server.notification_push([alert, Time.now])
+
#
# Need to make sure this reminder is cleared.
#
diff --git a/lib/mauve/notification.rb b/lib/mauve/notification.rb
index 522f9fa..3c902a2 100644
--- a/lib/mauve/notification.rb
+++ b/lib/mauve/notification.rb
@@ -239,7 +239,7 @@ module Mauve
if already_sent_to.include?(person.username)
logger.info("Already sent notification of #{alert} to #{person.username}")
else
- Server.notification_push([person, level, alert])
+ person.send_alert(level, alert)
already_sent_to << person.username
end
end
diff --git a/lib/mauve/notifier.rb b/lib/mauve/notifier.rb
index bf36162..8a26b2c 100644
--- a/lib/mauve/notifier.rb
+++ b/lib/mauve/notifier.rb
@@ -86,14 +86,12 @@ module Mauve
# Empty the buffer, one notification at a time.
#
sz.times do
- person, *args = Server.notification_pop
-
- #
- # Nil person.. that's craaazy too!
- #
- next if person.nil?
-
- person.send_alert(*args)
+ alert, at = Server.notification_pop
+ if alert.alert_group.nil?
+ logger.warn "Could not notify for #{alert} since there are no matching alert groups"
+ else
+ alert.alert_group.notify(alert, at)
+ end
end
end
diff --git a/lib/mauve/notifiers/debug.rb b/lib/mauve/notifiers/debug.rb
index 417bc94..a9afc52 100644
--- a/lib/mauve/notifiers/debug.rb
+++ b/lib/mauve/notifiers/debug.rb
@@ -53,27 +53,21 @@ module Mauve
end
def send_alert_to_debug_channels(destination, alert, all_alerts, conditions = nil)
- message = if respond_to?(:prepare_message)
+ message = if self.respond_to?(:prepare_message)
prepare_message(destination, alert, all_alerts, conditions)
else
[destination, alert, all_alerts].inspect
end
if deliver_to_file
- #lock_file = "#{deliver_to_file}.lock"
- #while File.exists?(lock_file)
- # sleep 0.1
- #end
- #FileUtils.touch(lock_file)
File.open("#{deliver_to_file}", "a+") do |fh|
fh.flock(File::LOCK_EX)
- fh.print("#{Time.now} from #{self.class}: " + message + "\n")
+ fh.print YAML.dump([Time.now, self.class, destination, message])
fh.flush()
end
- #FileUtils.rm(lock_file)
end
- deliver_to_queue << [destination, alert, all_alerts, conditions] if deliver_to_queue
+ deliver_to_queue << [Time.now, self.class, destination, message] if deliver_to_queue
if @disable_normal_delivery
true # pretend it happened OK if we're just testing