From e088c9be92a88b77da5f9adb4f6a0791fc5fbee2 Mon Sep 17 00:00:00 2001
From: Richard Frith-MacDonald
The Email array lists email addresses to which email
* alerts are to be sent.
- * The address '{ResponsibleEmail}' may be used, if the alert is for an alarm,
- * to email to the person/entity with primary responsibility for the alarm
- * (as defined by the userInfo dictionary of the alarm).
+ * An address with the prefix '{ResponsibleEmail}' may be used as a
+ * special case. It means that if an alarm has a ResponsibleEmail value
+ * set in its userInfo dictionary, that value is used as the address,
+ * otherwise the text after '{ResponsibleEmail}' is used as a fallback.
* An optional Subject field may be present in the rule ...
* this is used to specify that the email is to be tagged with the given
* subject line. This defeats batching of messages in that
diff --git a/EcAlerter.m b/EcAlerter.m
index fb5d98b..4243c63 100644
--- a/EcAlerter.m
+++ b/EcAlerter.m
@@ -1131,9 +1131,22 @@ replaceFields(NSDictionary *fields, NSString *template)
while ((d = [e nextObject]) != nil)
{
- if (YES == [d isEqualToString: @"{ResponsibleEmail}"])
+ if (YES == [d hasPrefix: @"{ResponsibleEmail}"])
{
- d = [m objectForKey: @"ResponsibleEmail"];
+ NSString *s = [m objectForKey: @"ResponsibleEmail"];
+
+ if ([s length] > 0)
+ {
+ /* Use the ResponsibleEmail address from the alarm
+ */
+ d = s;
+ }
+ else
+ {
+ /* Use the fallback (remaining text in the address)
+ */
+ d = [d substringFromIndex: 18];
+ }
}
if (0 == [d length])
{