Added %SCAN command, to send unsent mail from an area
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user