mod/notification-email: check that attachment exists

This commit is contained in:
Christian Hesse 2022-11-17 22:18:16 +01:00
parent 71d1f2a781
commit b517b26517

View file

@ -43,8 +43,15 @@
:foreach Id,Message in=$EmailQueue do={
:if ([ :typeof $Message ] = "array" ) do={
:local Attach [ :toarray [ $EitherOr ($Message->"attach") "" ] ];
:local Attach ({});
:while ([ /tool/e-mail/get last-status ] = "in-progress") do={ :delay 1s; }
:foreach File in=[ :toarray [ $EitherOr ($Message->"attach") "" ] ] do={
:if ([ :len [ /file/find where name=$File ] ] = 1) do={
:set Attach ($Attach, $File);
} else={
$LogPrintExit2 warning $0 ("File '" . $File . "' does not exist, can not attach.") false;
}
}
/tool/e-mail/send to=($Message->"to") cc=($Message->"cc") subject=($Message->"subject") \
body=($Message->"body") file=$Attach;
:local Wait true;