From c8e22f33c25db61a3f8287aae812017f79e8cba1 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 11 Jan 2023 09:42:25 +0100 Subject: mod/notification-email: split off generation of subject --- mod/notification-email | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'mod') diff --git a/mod/notification-email b/mod/notification-email index 5262ee5..8868941 100644 --- a/mod/notification-email +++ b/mod/notification-email @@ -5,6 +5,7 @@ :global FlushEmailQueue; :global LogForwardFilterLogForwarding; +:global NotificationEMailSubject; :global NotificationFunctions; :global QuotedPrintable; :global SendEMail; @@ -92,24 +93,30 @@ # generate filter for log-forward :set LogForwardFilterLogForwarding do={ - :global Identity; - :global EscapeForRegEx; - :global QuotedPrintable; + :global NotificationEMailSubject; :global SymbolForNotification; :return ("^Error sending e-mail <(" . \ - [ $EscapeForRegEx [ $QuotedPrintable ("[" . $Identity . "] " . \ - [ $SymbolForNotification "memo" ] . "Log Forwarding") ] ] . "|" . \ - [ $EscapeForRegEx [ $QuotedPrintable ("[" . $Identity . "] " . \ - [ $SymbolForNotification "warning-sign" ] . "Log Forwarding") ] ] . ")>:"); + [ $EscapeForRegEx [ $NotificationEMailSubject ([ $SymbolForNotification \ + "memo" ] . "Log Forwarding") ] ] . "|" . \ + [ $EscapeForRegEx [ $NotificationEMailSubject ([ $SymbolForNotification \ + "warning-sign" ] . "Log Forwarding") ] ] . ")>:"); +} + +# generate the e-mail subject +:set NotificationEMailSubject do={ + :global Identity; + + :global QuotedPrintable; + + :return [ $QuotedPrintable ("[" . $Identity . "] " . $1) ]; } # send notification via e-mail - expects one array argument :set ($NotificationFunctions->"email") do={ :local Notification $1; - :global Identity; :global EmailGeneralTo; :global EmailGeneralToOverride; :global EmailGeneralCc; @@ -118,7 +125,7 @@ :global EitherOr; :global IfThenElse; - :global QuotedPrintable; + :global NotificationEMailSubject; :local To [ $EitherOr ($EmailGeneralToOverride->($Notification->"origin")) $EmailGeneralTo ]; :local Cc [ $EitherOr ($EmailGeneralCcOverride->($Notification->"origin")) $EmailGeneralCc ]; @@ -134,7 +141,7 @@ :local Signature [ /system/note/get note ]; :set ($EmailQueue->[ :len $EmailQueue ]) { to=$To; cc=$Cc; - subject=[ $QuotedPrintable ("[" . $Identity . "] " . ($Notification->"subject")) ]; + subject=[ $NotificationEMailSubject ($Notification->"subject") ]; body=(($Notification->"message") . \ [ $IfThenElse ([ :len ($Notification->"link") ] > 0) ("\n\n" . ($Notification->"link")) "" ] . \ [ $IfThenElse ([ :len $Signature ] > 0) ("\n-- \n" . $Signature) "" ]); \ -- cgit v1.2.3-70-g09d2