Compare commits
No commits in common. "53c5488df7c8a9160a88e4a69133f6ba07b30cc4" and "6bba18fc5f7cf82d404f89b74d620ca83ea2374a" have entirely different histories.
53c5488df7
...
6bba18fc5f
@ -14,11 +14,7 @@ class Rescan extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'areafix:rescan'
|
||||
.' {ftn : FTN Address}'
|
||||
.' {area : Echoarea Tag}'
|
||||
.' {days? : Limit to messages authored days ago}'
|
||||
.' {--R|export : Re-export previously sent messages }';
|
||||
protected $signature = 'areafix:rescan {ftn} {area} {days?}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
@ -59,51 +55,34 @@ class Rescan extends Command
|
||||
if (! $eao->can_read($ao->security))
|
||||
throw new \Exception(sprintf('FTN [%s] doesnt have permission to receive [%s]',$ao->ftn,$eao->name));
|
||||
|
||||
foreach (Echomail::select(['id','datetime'])
|
||||
foreach (Echomail::select('id')
|
||||
->where('echoarea_id',$eao->id)
|
||||
->when(
|
||||
$this->argument('days'),
|
||||
fn($query)=>$query->where('datetime','>=',
|
||||
Carbon::now()
|
||||
->subDays($this->argument('days'))
|
||||
->startOfDay())
|
||||
)
|
||||
->when($this->argument('days'),function($query) {
|
||||
return $query->where('created_at','>=',Carbon::now()->subDays($this->argument('days'))->startOfDay());
|
||||
})
|
||||
->orderBy('datetime')
|
||||
->cursor() as $eo) {
|
||||
|
||||
// Echomail hasnt been exported before
|
||||
if (! $eo->seenby->count()) {
|
||||
$eo->seenby()->attach($ao->id,['export_at'=>Carbon::now()]);
|
||||
|
||||
$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));
|
||||
$this->info(sprintf('Exported [%d] to [%s]',$eo->id,$ao->ftn3d));
|
||||
|
||||
} else {
|
||||
$export = $eo->seenby->where('id',$ao->id)->pop();
|
||||
|
||||
if ($export) {
|
||||
// Echomail is pending export
|
||||
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));
|
||||
if ($export && $export->pivot->export_at && is_null($export->pivot->sent_at) && is_null($export->pivot->sent_pkt)) {
|
||||
$this->warn(sprintf('Not exporting [%d] already queued for [%s]',$eo->id,$ao->ftn3d));
|
||||
|
||||
// Echomail has been exported
|
||||
} elseif ($this->option('export')) {
|
||||
} elseif ($export) {
|
||||
$eo->seenby()->updateExistingPivot($ao,['export_at'=>Carbon::now(),'sent_at'=>NULL,'sent_pkt'=>NULL]);
|
||||
|
||||
$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 ?: '-',
|
||||
));
|
||||
}
|
||||
$this->info(sprintf('Re-exported [%d] to [%s]',$eo->id,$ao->ftn3d));
|
||||
|
||||
// Echomail has not been exported
|
||||
} else {
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
@ -44,11 +44,6 @@ class CommBinkpSend extends Command
|
||||
|
||||
$mo = Mailer::where('name',self::ID)->singleOrFail();
|
||||
|
||||
if ($this->option('now'))
|
||||
Job::dispatchSync($ao,$mo);
|
||||
else
|
||||
Job::dispatch($ao,$mo);
|
||||
|
||||
return self::SUCCESS;
|
||||
return ($this->option('now')) ? Job::dispatchSync($ao,$mo) : Job::dispatch($ao,$mo);
|
||||
}
|
||||
}
|
||||
|
@ -44,11 +44,6 @@ class CommEMSISend extends Command
|
||||
|
||||
$mo = Mailer::where('name',self::ID)->singleOrFail();
|
||||
|
||||
if ($this->option('now'))
|
||||
Job::dispatchSync($ao,$mo);
|
||||
else
|
||||
Job::dispatch($ao,$mo);
|
||||
|
||||
return self::SUCCESS;
|
||||
return ($this->option('now')) ? Job::dispatchSync($ao,$mo) : Job::dispatch($ao,$mo);
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +290,6 @@ final class Echomail extends Model implements Packet
|
||||
return $this->belongsToMany(Address::class,'echomail_seenby')
|
||||
->select(['id','zone_id','host_id','node_id'])
|
||||
->withPivot(['export_at','sent_at','sent_pkt'])
|
||||
->dontCache()
|
||||
->FTN2DOrder();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user