aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2011-09-06 15:55:47 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2011-09-06 15:55:47 +0100
commit91d6e6d32c7c1a1455479b7e65cb09ae0ad44b16 (patch)
tree0f06065bcddf152c514da5fd7a74e6c6ec603f1e
parentd2309ac606e008123d42fcea0819f80fe2204f70 (diff)
Fixed XMPP interface to save note.
-rw-r--r--lib/mauve/notifiers/xmpp.rb25
1 files changed, 21 insertions, 4 deletions
diff --git a/lib/mauve/notifiers/xmpp.rb b/lib/mauve/notifiers/xmpp.rb
index a2ca14d..faeefb0 100644
--- a/lib/mauve/notifiers/xmpp.rb
+++ b/lib/mauve/notifiers/xmpp.rb
@@ -561,7 +561,12 @@ EOF
"wallclock"
end
- ack_until = Time.now.in_x_hours(n_hours, type_hours)
+ begin
+ ack_until = Time.now.in_x_hours(n_hours, type_hours)
+ rescue => RangeError
+ return "I'm sorry, you tried to acknowedge for far too long, and my buffers overflowed!"
+ end
+
username = get_username_for(msg.from)
if is_muc?(Configuration.current.people[username].xmpp)
@@ -569,7 +574,9 @@ EOF
end
msg = []
- msg << "Acknowledgment results:" if alerts.length > 1
+ msg << "Acknowledgement results:" if alerts.length > 1
+
+ succeeded = []
alerts.each do |alert_id|
alert = Alert.get(alert_id)
@@ -585,11 +592,21 @@ EOF
end
if alert.acknowledge!(Configuration.current.people[username], ack_until)
- msg << "#{alert_id}: Acknowledged until #{ack_until.to_s_human}"
+ msg << "#{alert_id}: Acknowledged until #{alert.will_unacknowledge_at}"
+ succeeded << alert
else
- msg << "#{alert_id}: Acknowledgment failed."
+ msg << "#{alert_id}: Acknowledgement failed."
end
end
+
+ #
+ # Add the note.
+ #
+ unless note.to_s.empty?
+ note = Alert.remove_html(note)
+ h = History.new(:alerts => succeeded, :type => "note", :event => username+" noted "+note.to_s)
+ logger.debug h.errors unless h.save
+ end
return msg.join("\n")
end