aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mauve')
-rw-r--r--lib/mauve/mauve_time.rb6
-rw-r--r--lib/mauve/notifiers/xmpp.rb31
-rw-r--r--lib/mauve/web_interface.rb8
3 files changed, 24 insertions, 21 deletions
diff --git a/lib/mauve/mauve_time.rb b/lib/mauve/mauve_time.rb
index d2949d9..f564fdb 100644
--- a/lib/mauve/mauve_time.rb
+++ b/lib/mauve/mauve_time.rb
@@ -34,11 +34,15 @@ class Time
# @return [Time]
#
def in_x_hours(n, type="wallclock")
+ raise ArgumentError, "n must be numeric" unless n.is_a?(Numeric)
+ raise ArgumentError, "type must be a string" unless type.is_a?(String)
+
t = self.dup
+
#
# Do this in seconds rather than hours
#
- n = n.to_i*3600
+ n = (n*3600).to_i
test = case type
when "working"
diff --git a/lib/mauve/notifiers/xmpp.rb b/lib/mauve/notifiers/xmpp.rb
index ae9734f..fa1751c 100644
--- a/lib/mauve/notifiers/xmpp.rb
+++ b/lib/mauve/notifiers/xmpp.rb
@@ -12,6 +12,10 @@ require 'mauve/notifiers/debug'
# A couple of monkey patches to fix up all this nonsense.
#
module Jabber
+ #
+ # Monkey patch of the close commands. For good reasons, though I can't
+ # remember why.
+ #
class Stream
def close
#
@@ -47,22 +51,17 @@ end
module Mauve
- module Notifiers
+ module Notifiers
+
+ #
+ # This is the Jabber/XMMP notifiers module.
+ #
module Xmpp
-
-# class CountingMUCClient < Jabber::MUC::SimpleMUCClient
-#
-# attr_reader :participants
-#
-# def initialize(*a)
-# super(*a)
-# @participants = 0
-# self.on_join { @participants += 1 }
-# self.on_leave { @participants -= 1 }
-# end
-#
-# end
-#
+
+ #
+ # The default provider is XMMP, although this should really be broken out
+ # into its own provider to allow multple ways of doing XMPP.
+ #
class Default
include Jabber
@@ -624,7 +623,7 @@ EOF
end
if alert.acknowledge!(Configuration.current.people[username], ack_until)
- msg << "#{alert_id}: Acknowledged until #{alert.will_unacknowledge_at}"
+ msg << "#{alert_id}: Acknowledged until #{alert.will_unacknowledge_at.to_s_human}"
succeeded << alert
else
msg << "#{alert_id}: Acknowledgement failed."
diff --git a/lib/mauve/web_interface.rb b/lib/mauve/web_interface.rb
index 707014a..716aaf3 100644
--- a/lib/mauve/web_interface.rb
+++ b/lib/mauve/web_interface.rb
@@ -197,7 +197,7 @@ EOF
alerts = params[:alerts] || []
note = params[:note] || nil
- n_hours = (n_hours.to_i > 188 ? 188 : n_hours.to_i)
+ n_hours = (n_hours.to_f > 188 ? 188 : n_hours.to_f)
if ack_until.to_s.empty?
ack_until = Time.now.in_x_hours(n_hours, type_hours.to_s)
@@ -247,7 +247,7 @@ EOF
get '/ajax/time_in_x_hours/:n_hours/:type_hours' do
content_type :text
- n_hours = params[:n_hours].to_i
+ n_hours = params[:n_hours].to_f
type_hours = params[:type_hours].to_s
#
@@ -335,7 +335,7 @@ EOF
alert = Alert.get(params[:id])
ack_until = params[:ack_until].to_i
- n_hours = params[:n_hours].to_i
+ n_hours = params[:n_hours].to_f
type_hours = params[:type_hours].to_s
note = params[:note] || nil
@@ -355,7 +355,7 @@ EOF
logger.debug h.errors unless h.save
end
- flash['notice'] = "Successfully acknowledged alert <em>#{alert.alert_id}</em> from source #{alert.source}."
+ flash['notice'] = "Successfully acknowledged alert <em>#{alert.alert_id}</em> from source #{alert.source} until #{alert.will_unacknowledge_at.to_s_human}."
redirect "/alert/#{alert.id}"
end