Added %SCAN command, to send unsent mail from an area
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 30s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m34s
Create Docker Image / Final Docker Image Manifest (push) Successful in 8s

This commit is contained in:
2024-11-01 10:04:12 +11:00
parent 247d30505e
commit 7c70c1f12d
6 changed files with 168 additions and 5 deletions

View File

@@ -10,8 +10,10 @@ use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\Middleware\Skip;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Notification;
use App\Models\{Address,Echoarea,Echomail};
use App\Notifications\Netmails\Areafix\Scan;
class AreafixRescan implements ShouldQueue
{
@@ -78,6 +80,10 @@ class AreafixRescan implements ShouldQueue
{
$c = 0;
$s = 0;
$earliest = NULL;
$latest = NULL;
foreach (Echomail::select(['id','datetime'])
->where('echoarea_id',$this->eao->id)
->where('datetime','>=',
@@ -93,6 +99,12 @@ class AreafixRescan implements ShouldQueue
$eo->seenby()->attach($this->ao->id,['export_at'=>Carbon::now()]);
$c++;
if (($eo->datetime < $earliest) || (! $earliest))
$earliest = $eo->datetime;
if (($latest < $eo->datetime) || (! $latest))
$latest = $eo->datetime;
Log::debug(sprintf('Exported [%d] MSG (%s) dated (%s) to [%s]',$eo->id,$eo->msgid ?: '*NO MSGID*',$eo->datetime->format('Y-m-d H:i:s'),$this->ao->ftn3d));
} else {
@@ -109,6 +121,12 @@ class AreafixRescan implements ShouldQueue
$eo->seenby()->updateExistingPivot($this->ao,['export_at'=>Carbon::now(),'sent_at'=>NULL]);
$c++;
if (($eo->datetime < $earliest) || (! $earliest))
$earliest = $eo->datetime;
if (($latest < $eo->datetime) || (! $latest))
$latest = $eo->datetime;
Log::debug(sprintf('Re-exported [%d] MSG (%s) dated (%s) to [%s]',$eo->id,$eo->msgid ?: '*NO MSGID*',$eo->datetime,$this->ao->ftn3d));
} else {
@@ -126,12 +144,26 @@ class AreafixRescan implements ShouldQueue
$eo->seenby()->attach($this->ao,['export_at'=>Carbon::now(),'sent_at'=>NULL,'sent_pkt'=>NULL]);
$c++;
if (($eo->datetime < $earliest) || (! $earliest))
$earliest = $eo->datetime;
if (($latest < $eo->datetime) || (! $latest))
$latest = $eo->datetime;
Log::debug(sprintf('Exported [%d] to [%s]',$eo->id,$this->ao->ftn3d));
}
}
}
// @todo Send a netmail to the node about the rescan
Notification::route('netmail',$this->ao)
->notify(new Scan(collect([
'area'=>$this->eao->name,
'queued'=>$c,
'skipped'=>$s,
'earliest'=>$earliest,
'latest'=>$latest,
])));
Log::info(sprintf('%s:= Queued [%d], Skipped [%d] echomails for [%s] in [%s]',self::LOGKEY,$c,$s,$this->ao->ftn,$this->eao->name));
}
}