aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/mauve/alert.rb2
-rw-r--r--lib/mauve/alert_changed.rb7
-rw-r--r--lib/mauve/alert_group.rb7
-rw-r--r--lib/mauve/auth_bytemark.rb8
-rw-r--r--lib/mauve/configuration.rb4
-rw-r--r--lib/mauve/web_interface.rb2
6 files changed, 27 insertions, 3 deletions
diff --git a/lib/mauve/alert.rb b/lib/mauve/alert.rb
index 86b49e3..cf88114 100644
--- a/lib/mauve/alert.rb
+++ b/lib/mauve/alert.rb
@@ -138,7 +138,7 @@ module Mauve
other.sort_tuple <=> self.sort_tuple
end
- def subject; attribute_get(:subject) || attribute_get(:source) ; end
+ def subject; attribute_get(:subject) || attribute_get(:source) || "not set" ; end
def detail; attribute_get(:detail) || "_No detail set._" ; end
def subject=(subject); set_changed_if_different( :subject, subject ); end
diff --git a/lib/mauve/alert_changed.rb b/lib/mauve/alert_changed.rb
index 68a0a00..a07dfa1 100644
--- a/lib/mauve/alert_changed.rb
+++ b/lib/mauve/alert_changed.rb
@@ -82,6 +82,13 @@ module Mauve
# the alert has been acknowledged
#
def remind
+ unless alert.is_a?(Alert)
+ logger.debug "#{self.inspect} lost alert #{alert_id}. Killing self."
+ destroy!
+ return false
+ end
+
+
logger.debug "Reminding someone about #{self.inspect}"
alert_group = AlertGroup.matches(alert)[0]
diff --git a/lib/mauve/alert_group.rb b/lib/mauve/alert_group.rb
index a8b1482..4895200 100644
--- a/lib/mauve/alert_group.rb
+++ b/lib/mauve/alert_group.rb
@@ -101,6 +101,13 @@ module Mauve
# @param [Alert] alert An alert to test for belongness to group.
# @return [Boolean] Success or failure.
def matches_alert?(alert)
+
+ unless alert.is_a?(Alert)
+ logger.warn "Got given a #{alert.class} instead of an Alert!"
+ logger.debug caller.join("\n")
+ return false
+ end
+
result = alert.instance_eval(&self.includes)
if true == result or
true == result.instance_of?(MatchData)
diff --git a/lib/mauve/auth_bytemark.rb b/lib/mauve/auth_bytemark.rb
index 52fa610..2273c36 100644
--- a/lib/mauve/auth_bytemark.rb
+++ b/lib/mauve/auth_bytemark.rb
@@ -35,15 +35,19 @@ class AuthBytemark
raise ArgumentError.new("Password must be a string, not a #{password.class}") if String != password.class
raise ArgumentError.new("Login or/and password is/are empty.") if login.empty? || password.empty?
- return false if ENV['RACK_ENV'].to_s == "development"
-
client = XMLRPC::Client.new(@srv,"/",@port,nil,nil,nil,nil,true,@timeout).proxy("bytemark.auth")
begin
challenge = client.getChallengeForUser(login)
response = Digest::SHA1.new.update(challenge).update(password).hexdigest
client.login(login, response)
+ return true
+ rescue XMLRPC::FaultException => fault
+ Mauve::Server.instance.logger.warn "Fault code is #{fault.faultCode} stating #{fault.faultString}"
+ return false
rescue Exception => ex
+ Mauve::Server.instance.logger.warn "Caught #{ex.to_s} whilst trying to loging for #{login}"
+ Mauve::Server.instance.logger.debug ex.backtrace.join("\n")
return false
end
end
diff --git a/lib/mauve/configuration.rb b/lib/mauve/configuration.rb
index 66dfabf..baf6ad1 100644
--- a/lib/mauve/configuration.rb
+++ b/lib/mauve/configuration.rb
@@ -328,6 +328,10 @@ module Mauve
def xmpp(x)
@result.xmpp = x.to_s
end
+
+ def sms(x)
+ @result.sms = x.to_s
+ end
def suppress_notifications_after(h)
raise ArgumentError.new("notification_threshold must be specified as e.g. (10 => 1.minute)") unless
diff --git a/lib/mauve/web_interface.rb b/lib/mauve/web_interface.rb
index 2610fc9..520f344 100644
--- a/lib/mauve/web_interface.rb
+++ b/lib/mauve/web_interface.rb
@@ -186,6 +186,8 @@ EOF
type_hours = params[:type_hours] || "daylight"
alerts = params[:alerts] || []
+ n_hours = (n_hours > 188 ? 188 : n_hours)
+
if ack_until.to_s.empty?
ack_until = Time.now.in_x_hours(n_hours.to_i, type_hours.to_s)
else