Compare commits

...

2 Commits

Author SHA1 Message Date
53c5488df7 When rescanning, choose the echomails date, not the date it was imported. By default dont re-export sent echomail, unless using -R
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 34s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m47s
Create Docker Image / Final Docker Image Manifest (push) Successful in 9s
2024-10-21 11:21:48 +11:00
944053972b Fix for 4bbb82 Job::dispatch doesnt return an int, so cannot be used for success status 2024-10-21 08:47:54 +11:00
4 changed files with 47 additions and 15 deletions

View File

@ -14,7 +14,11 @@ class Rescan extends Command
* *
* @var string * @var string
*/ */
protected $signature = 'areafix:rescan {ftn} {area} {days?}'; protected $signature = 'areafix:rescan'
.' {ftn : FTN Address}'
.' {area : Echoarea Tag}'
.' {days? : Limit to messages authored days ago}'
.' {--R|export : Re-export previously sent messages }';
/** /**
* The console command description. * The console command description.
@ -55,34 +59,51 @@ class Rescan extends Command
if (! $eao->can_read($ao->security)) if (! $eao->can_read($ao->security))
throw new \Exception(sprintf('FTN [%s] doesnt have permission to receive [%s]',$ao->ftn,$eao->name)); throw new \Exception(sprintf('FTN [%s] doesnt have permission to receive [%s]',$ao->ftn,$eao->name));
foreach (Echomail::select('id') foreach (Echomail::select(['id','datetime'])
->where('echoarea_id',$eao->id) ->where('echoarea_id',$eao->id)
->when($this->argument('days'),function($query) { ->when(
return $query->where('created_at','>=',Carbon::now()->subDays($this->argument('days'))->startOfDay()); $this->argument('days'),
}) fn($query)=>$query->where('datetime','>=',
Carbon::now()
->subDays($this->argument('days'))
->startOfDay())
)
->orderBy('datetime') ->orderBy('datetime')
->cursor() as $eo) { ->cursor() as $eo) {
// Echomail hasnt been exported before // Echomail hasnt been exported before
if (! $eo->seenby->count()) { if (! $eo->seenby->count()) {
$eo->seenby()->attach($ao->id,['export_at'=>Carbon::now()]); $eo->seenby()->attach($ao->id,['export_at'=>Carbon::now()]);
$this->info(sprintf('Exported [%d] to [%s]',$eo->id,$ao->ftn3d));
$this->info(sprintf('Exported [%d] MSG (%s) dated (%s) to [%s]',$eo->id,$eo->msgid ?: '*NO MSGID*',$eo->datetime->format('Y-m-d H:i:s'),$ao->ftn3d));
} else { } else {
$export = $eo->seenby->where('id',$ao->id)->pop(); $export = $eo->seenby->where('id',$ao->id)->pop();
// Echomail is pending export if ($export) {
if ($export && $export->pivot->export_at && is_null($export->pivot->sent_at) && is_null($export->pivot->sent_pkt)) { // Echomail is pending export
$this->warn(sprintf('Not exporting [%d] already queued for [%s]',$eo->id,$ao->ftn3d)); if ($export->pivot->export_at && is_null($export->pivot->sent_at) && is_null($export->pivot->sent_pkt)) {
$this->warn(sprintf('Not exporting [%d] MSG (%s) dated (%s) already queued for [%s]',$eo->id,$eo->msgid ?: '*NO MSGID*',$eo->datetime->format('Y-m-d H:i:s'),$ao->ftn3d));
// Echomail has been exported // Echomail has been exported
} elseif ($export) { } elseif ($this->option('export')) {
$eo->seenby()->updateExistingPivot($ao,['export_at'=>Carbon::now(),'sent_at'=>NULL,'sent_pkt'=>NULL]); $eo->seenby()->updateExistingPivot($ao,['export_at'=>Carbon::now(),'sent_at'=>NULL,'sent_pkt'=>NULL]);
$this->info(sprintf('Re-exported [%d] to [%s]',$eo->id,$ao->ftn3d));
$this->info(sprintf('Re-exported [%d] MSG (%s) dated (%s) to [%s]',$eo->id,$eo->msgid ?: '*NO MSGID*',$eo->datetime,$ao->ftn3d));
} else {
$this->info(sprintf('Not resending previously sent message [%d], MSGID (%s) - sent in Pkt [%s] on [%s]',
$eo->id,
$eo->msgid ?: '* NO MSGID*',
$export->pivot->sent_pkt ?: '-',
$export->pivot->sent_at ?: '-',
));
}
// Echomail has not been exported // Echomail has not been exported
} else { } else {
$eo->seenby()->attach($ao,['export_at'=>Carbon::now(),'sent_at'=>NULL,'sent_pkt'=>NULL]); $eo->seenby()->attach($ao,['export_at'=>Carbon::now(),'sent_at'=>NULL,'sent_pkt'=>NULL]);
$this->info(sprintf('Exported [%d] to [%s]',$eo->id,$ao->ftn3d)); $this->info(sprintf('Exported [%d] to [%s]',$eo->id,$ao->ftn3d));
} }
} }

View File

@ -44,6 +44,11 @@ class CommBinkpSend extends Command
$mo = Mailer::where('name',self::ID)->singleOrFail(); $mo = Mailer::where('name',self::ID)->singleOrFail();
return ($this->option('now')) ? Job::dispatchSync($ao,$mo) : Job::dispatch($ao,$mo); if ($this->option('now'))
Job::dispatchSync($ao,$mo);
else
Job::dispatch($ao,$mo);
return self::SUCCESS;
} }
} }

View File

@ -44,6 +44,11 @@ class CommEMSISend extends Command
$mo = Mailer::where('name',self::ID)->singleOrFail(); $mo = Mailer::where('name',self::ID)->singleOrFail();
return ($this->option('now')) ? Job::dispatchSync($ao,$mo) : Job::dispatch($ao,$mo); if ($this->option('now'))
Job::dispatchSync($ao,$mo);
else
Job::dispatch($ao,$mo);
return self::SUCCESS;
} }
} }

View File

@ -290,6 +290,7 @@ final class Echomail extends Model implements Packet
return $this->belongsToMany(Address::class,'echomail_seenby') return $this->belongsToMany(Address::class,'echomail_seenby')
->select(['id','zone_id','host_id','node_id']) ->select(['id','zone_id','host_id','node_id'])
->withPivot(['export_at','sent_at','sent_pkt']) ->withPivot(['export_at','sent_at','sent_pkt'])
->dontCache()
->FTN2DOrder(); ->FTN2DOrder();
} }