mod/notification-email: $FlushEmailQueue: move the check up...

... as this needs to be done before creating a scheduler. 😜

Also remove the scheduler and return.
This commit is contained in:
Christian Hesse 2024-12-11 11:51:17 +01:00
parent 1e2ca3d214
commit 8c8c75ca66

View file

@ -47,6 +47,12 @@
:local QueueLen [ :len $EmailQueue ];
:local Scheduler [ /system/scheduler/find where name="_FlushEmailQueue" ];
:if ([ :len $Scheduler ] > 0 && $QueueLen = 0) do={
$LogPrint warning $0 ("Flushing E-Mail messages from scheduler, but queue is empty.");
/system/scheduler/remove $Scheduler;
:return false;
}
:if ([ :len $Scheduler ] < 0) do={
/system/scheduler/add name="_FlushEmailQueue" interval=1m start-time=startup \
comment="Doing initial checks..." on-event=(":global FlushEmailQueue; \$FlushEmailQueue;");
@ -74,10 +80,6 @@
:return false;
}
:if ([ :len $Scheduler ] > 0 && $QueueLen = 0) do={
$LogPrint warning $0 ("Flushing E-Mail messages from scheduler, but queue is empty.");
}
/system/scheduler/set interval=($QueueLen . "m") comment="Sending..." $Scheduler;
:foreach Id,Message in=$EmailQueue do={