2023-12-01 07:14:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands\Areafix;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
2024-10-31 11:40:58 +00:00
|
|
|
use App\Jobs\AreafixRescan;
|
|
|
|
use App\Models\{Address,Echoarea};
|
2023-12-01 07:14:51 +00:00
|
|
|
|
|
|
|
class Rescan extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2024-10-21 00:21:48 +00:00
|
|
|
protected $signature = 'areafix:rescan'
|
|
|
|
.' {ftn : FTN Address}'
|
|
|
|
.' {area : Echoarea Tag}'
|
|
|
|
.' {days? : Limit to messages authored days ago}'
|
2024-10-31 11:40:58 +00:00
|
|
|
.' {--j|queue : Queue the Job}'
|
|
|
|
.' {--Q|queuename=default : Queue on queue}'
|
|
|
|
.' {--R|export : Re-export previously sent messages}';
|
2023-12-01 07:14:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Resend some echomail to a node';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
2024-05-27 05:08:39 +00:00
|
|
|
* @return int
|
2023-12-01 07:14:51 +00:00
|
|
|
* @throws \Exception
|
|
|
|
*/
|
2024-05-27 05:08:39 +00:00
|
|
|
public function handle(): int
|
2023-12-01 07:14:51 +00:00
|
|
|
{
|
|
|
|
if (($this->argument('days')) && (! is_numeric($this->argument('days'))))
|
|
|
|
throw new \Exception('Days must be numeric: '.$this->argument('days'));
|
|
|
|
|
|
|
|
$ao = Address::findFtn($this->argument('ftn'));
|
|
|
|
|
|
|
|
if (! $ao)
|
|
|
|
throw new \Exception('FTN not found: '.$this->argument('ftn'));
|
|
|
|
|
|
|
|
// Check that the area belongs to the domain for the FTN
|
|
|
|
if (! $this->argument('area'))
|
|
|
|
throw new \Exception('Areaname is required');
|
|
|
|
|
2024-10-31 11:40:58 +00:00
|
|
|
$eo = Echoarea::where('name',$this->argument('area'))->sole();
|
2023-12-01 07:14:51 +00:00
|
|
|
|
2024-10-31 11:40:58 +00:00
|
|
|
if ($this->option('queue'))
|
|
|
|
AreafixRescan::dispatch($ao,$eo,$this->argument('days'))->onQueue($this->option('queuename'));
|
|
|
|
else
|
|
|
|
AreafixRescan::dispatchSync($ao,$eo,$this->argument('days'));
|
2023-12-01 07:14:51 +00:00
|
|
|
|
|
|
|
return self::SUCCESS;
|
|
|
|
}
|
|
|
|
}
|