aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/mauve/configuration_builders/server.rb10
-rw-r--r--lib/mauve/notifiers/email.rb11
-rw-r--r--lib/mauve/notifiers/templates/email.html.erb2
-rw-r--r--lib/mauve/pop3_server.rb10
-rw-r--r--test/tc_mauve_configuration_builders_server.rb19
5 files changed, 46 insertions, 6 deletions
diff --git a/lib/mauve/configuration_builders/server.rb b/lib/mauve/configuration_builders/server.rb
index 0fa811b..3a9f5ec 100644
--- a/lib/mauve/configuration_builders/server.rb
+++ b/lib/mauve/configuration_builders/server.rb
@@ -64,6 +64,15 @@ module Mauve
end
end
+ class Pop3Server < ObjectBuilder
+ is_attribute "ip"
+ is_attribute "port"
+
+ def builder_setup
+ @result = Mauve::Pop3Server.instance
+ end
+ end
+
class Server < ObjectBuilder
#
# Set up second-level builders
@@ -74,6 +83,7 @@ module Mauve
is_builder "timer", Timer
is_builder "notifier", Notifier
is_builder "heartbeat", Heartbeat
+ is_builder "pop3_server", Pop3Server
is_attribute "hostname"
is_attribute "database"
diff --git a/lib/mauve/notifiers/email.rb b/lib/mauve/notifiers/email.rb
index 03384f7..8f2d32b 100644
--- a/lib/mauve/notifiers/email.rb
+++ b/lib/mauve/notifiers/email.rb
@@ -24,7 +24,6 @@ module Mauve
@password = nil
@login_method = nil
@from = "mauve@localhost"
- @hostname = "localhost"
@signature = "This is an automatic mailing, please do not reply."
@subject_prefix = ""
end
@@ -73,7 +72,15 @@ module Mauve
m.header.to = destination
m.header.from = @from
- m.header.date = alert.updated_at.to_time || MauveTime.now
+ m.header.date = case alert.update_type
+ when "cleared"
+ alert.cleared_at
+ when "acknowledged"
+ alert.acknowledged_at
+ else
+ alert.raised_at
+ end
+
m.header['Content-Type'] = "multipart/alternative"
txt_template = File.join(File.dirname(__FILE__), "templates", "email.txt.erb")
diff --git a/lib/mauve/notifiers/templates/email.html.erb b/lib/mauve/notifiers/templates/email.html.erb
index 24b5e7b..fb33de6 100644
--- a/lib/mauve/notifiers/templates/email.html.erb
+++ b/lib/mauve/notifiers/templates/email.html.erb
@@ -1,7 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><title></title></head><body>
-<p><a href="<%= WebInterface.url_for(alert) %>"><%= alert.update_type.upcase %></a>:<%
+<p><a href="<%= WebInterface.url_for(alert) %>"><%= alert.update_type.upcase %></a>: <%
case alert.update_type
when "cleared"
%><%= alert.cleared_at.to_s_relative %><%
diff --git a/lib/mauve/pop3_server.rb b/lib/mauve/pop3_server.rb
index 36a6cd2..b8253b0 100644
--- a/lib/mauve/pop3_server.rb
+++ b/lib/mauve/pop3_server.rb
@@ -28,7 +28,9 @@ module Mauve
#
# Use ipaddr to sanitize our IP.
#
- @ip = IPAddr.new(i)
+ IPAddr.new(i)
+
+ @ip = i
end
def logger
@@ -273,7 +275,9 @@ module Mauve
def messages
if @messages.empty?
@messages = []
- smtp = Mauve::Notifiers::Email::Default.new("TODO: why do I need to put this argument here?")
+
+ email = Configuration.current.notification_methods['email']
+
alerts_seen = []
#
@@ -310,7 +314,7 @@ module Mauve
alerts_seen << [a.alert_id, a.update_type]
- @messages << [a, smtp.prepare_message(self.user, a.alert, [])]
+ @messages << [a, email.prepare_message(self.user, a.alert, [])]
end
end
diff --git a/test/tc_mauve_configuration_builders_server.rb b/test/tc_mauve_configuration_builders_server.rb
index 270c046..6f4255f 100644
--- a/test/tc_mauve_configuration_builders_server.rb
+++ b/test/tc_mauve_configuration_builders_server.rb
@@ -85,6 +85,25 @@ EOF
assert_equal(session_secret, Mauve::HTTPServer.instance.session_secret)
end
+ def test_pop3_server_params
+ ip = "::1"
+ port = 1101
+
+ config=<<EOF
+server {
+ pop3_server {
+ ip "#{ip}"
+ port #{port}
+ }
+}
+EOF
+ assert_nothing_raised { Mauve::ConfigurationBuilder.parse(config) }
+
+ assert_equal(ip, Mauve::Pop3Server.instance.ip)
+ assert_equal(port, Mauve::Pop3Server.instance.port)
+
+ end
+
def test_listener_params
ip = "::"
port = 12341