From b22cbc87927553f6dbb5754281e95fe9bad2eed1 Mon Sep 17 00:00:00 2001 From: Patrick J Cherry Date: Mon, 13 Jun 2011 11:02:37 +0100 Subject: * Tidied up mauveserver to handle HUP restarts * Added HTML santizing to the alert class, so bad HTML is stripped as part of processing. * Alert#cleared? now means "not raised" * Better error handling in the Timer class, making sure that the timer never gets permanently frozen. * Moved notification and packet buffers to the Server class, meaning that if the Processor or Notifier threads crash, we don't lose all the items waiting to be processed/notified. * XMPP/Email Alerts now use templates, instead of instance methods. * Emails now get sent as multipart with HTML to allow detail fields to be shown as nature intended. --- lib/mauve/notifiers/templates/email.html.erb | 28 ++++++++++++++++++++++++++++ lib/mauve/notifiers/templates/email.txt.erb | 24 ++++++++++++++++++++++++ lib/mauve/notifiers/templates/sms.txt.erb | 1 + lib/mauve/notifiers/templates/xmpp.html.erb | 0 lib/mauve/notifiers/templates/xmpp.txt.erb | 15 ++++++++++++++- 5 files changed, 67 insertions(+), 1 deletion(-) mode change 100644 => 120000 lib/mauve/notifiers/templates/sms.txt.erb delete mode 100644 lib/mauve/notifiers/templates/xmpp.html.erb (limited to 'lib/mauve/notifiers/templates') diff --git a/lib/mauve/notifiers/templates/email.html.erb b/lib/mauve/notifiers/templates/email.html.erb index e69de29..fcf0620 100644 --- a/lib/mauve/notifiers/templates/email.html.erb +++ b/lib/mauve/notifiers/templates/email.html.erb @@ -0,0 +1,28 @@ +

<%= alert.update_type.upcase %> <% +case alert.update_type +when :cleared +%><%= MauveTime.now.to_s_relative(alert.cleared_at.to_time) %><% +when :acknowleged +%><%= MauveTime.now.to_s_relative(alert.acknowledged_at.to_time) %><% +else +%><%= MauveTime.now.to_s_relative(alert.raised_at.to_time) %><% +end +%>: <%= alert.summary %><% +if alert.source != alert.subject +%> -- from <%= alert.source %><% +end +%>. + +


+ +
+<%=alert.detail %> +
+ +
+ +
+--
+Love mauve
+xxx. +
diff --git a/lib/mauve/notifiers/templates/email.txt.erb b/lib/mauve/notifiers/templates/email.txt.erb index e69de29..8f7e9a4 100644 --- a/lib/mauve/notifiers/templates/email.txt.erb +++ b/lib/mauve/notifiers/templates/email.txt.erb @@ -0,0 +1,24 @@ +<%= alert.update_type.upcase %>: <% +case alert.update_type +when :cleared +%><%= MauveTime.now.to_s_relative(alert.cleared_at.to_time) %><% +when :acknowleged +%><%= MauveTime.now.to_s_relative(alert.acknowledged_at.to_time) %><% +else +%><%= MauveTime.now.to_s_relative(alert.raised_at.to_time) %><% +end +%>: <%= alert.summary %><% +if alert.source != alert.subject +%> -- from <%= alert.source %><% +end +%>. + +-- Details ------------------------------------------------------------ + +<%= Sanitize.clean(alert.detail) %> + +----------------------------------------------------------------------- + +-- +Love mauve. +xx diff --git a/lib/mauve/notifiers/templates/sms.txt.erb b/lib/mauve/notifiers/templates/sms.txt.erb deleted file mode 100644 index e69de29..0000000 diff --git a/lib/mauve/notifiers/templates/sms.txt.erb b/lib/mauve/notifiers/templates/sms.txt.erb new file mode 120000 index 0000000..802c711 --- /dev/null +++ b/lib/mauve/notifiers/templates/sms.txt.erb @@ -0,0 +1 @@ +xmpp.txt.erb \ No newline at end of file diff --git a/lib/mauve/notifiers/templates/xmpp.html.erb b/lib/mauve/notifiers/templates/xmpp.html.erb deleted file mode 100644 index e69de29..0000000 diff --git a/lib/mauve/notifiers/templates/xmpp.txt.erb b/lib/mauve/notifiers/templates/xmpp.txt.erb index 881c197..22e2d8c 100644 --- a/lib/mauve/notifiers/templates/xmpp.txt.erb +++ b/lib/mauve/notifiers/templates/xmpp.txt.erb @@ -1 +1,14 @@ -<%=arse %> +<%= alert.update_type.upcase %>: <% +case alert.update_type +when :cleared +%><%= MauveTime.now.to_s_relative(alert.cleared_at.to_time) %><% +when :acknowleged +%><%= MauveTime.now.to_s_relative(alert.acknowledged_at.to_time) %><% +else +%><%= MauveTime.now.to_s_relative(alert.raised_at.to_time) %><% +end +%>: <%= alert.summary %><% +if alert.source != alert.subject +%> -- from <%= alert.source %><% +end +%>. -- cgit v1.2.1