Allow fallback value for responsible email address

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/ec/trunk@36512 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2013-04-12 11:27:16 +00:00
parent e8243011fb
commit e088c9be92
3 changed files with 26 additions and 7 deletions

View file

@ -37,9 +37,14 @@
},
{
Type = "Clear";
/* Set a good subject for the email.
*/
Subject = "Clear {Identifier} ({SeverityText})";
Email = (
"myaccount@localhost.localdomain"
/* Send to the responsible email destination defined in the alarm
* or fall back to sending to myaccount@localhost.localdomain
*/
"{ResponsibleEmail}myaccount@localhost.localdomain"
);
Stop = YES; /* Don't go on to any general alerts */
},
@ -61,7 +66,7 @@
Type = "Alarm";
Subject = "Alarm {Identifier} ({SeverityText})";
Email = (
"myaccount@localhost.localdomain"
"{ResponsibleEmail}myaccount@localhost.localdomain"
);
Stop = YES; /* Don't go on to any general alerts */
},

View file

@ -237,9 +237,10 @@
* </p>
* <p>The <em>Email</em> array lists email addresses to which email
* alerts are to be sent.<br />
* 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).<br />
* 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.<br />
* An optional <em>Subject</em> 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 <em>defeats</em> batching of messages in that

View file

@ -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])
{