2021-07-15 14:54:23 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
2023-08-05 11:32:45 +00:00
|
|
|
use Carbon\Carbon;
|
2021-07-15 14:54:23 +00:00
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
2022-11-13 13:29:55 +00:00
|
|
|
use App\Classes\File;
|
2021-07-15 14:54:23 +00:00
|
|
|
use App\Classes\FTN\Packet;
|
2021-09-06 13:39:32 +00:00
|
|
|
use App\Jobs\MessageProcess as Job;
|
2022-11-11 11:57:40 +00:00
|
|
|
use App\Models\Address;
|
2021-07-15 14:54:23 +00:00
|
|
|
|
2021-08-29 14:24:40 +00:00
|
|
|
class PacketProcess extends Command
|
2021-07-15 14:54:23 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2021-09-10 14:38:11 +00:00
|
|
|
protected $signature = 'packet:process'
|
2022-11-13 13:29:55 +00:00
|
|
|
.' {file : Packet to process}'
|
2021-09-10 14:38:11 +00:00
|
|
|
.' {--N|nobot : Dont process bots}'
|
2023-07-15 00:46:19 +00:00
|
|
|
.' {ftn : System the packet is from}';
|
2021-07-15 14:54:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Process Packet';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
* @throws \App\Classes\FTN\InvalidPacketException
|
2023-09-20 10:29:23 +00:00
|
|
|
* @todo Should this just call PacketProcess instead?
|
2021-07-15 14:54:23 +00:00
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
2022-11-13 13:29:55 +00:00
|
|
|
$f = new File($this->argument('file'));
|
2023-07-15 00:46:19 +00:00
|
|
|
$a = Address::findFTN($this->argument('ftn'));
|
2021-07-15 14:54:23 +00:00
|
|
|
|
2022-11-13 13:29:55 +00:00
|
|
|
foreach ($f as $packet) {
|
2023-09-20 10:29:23 +00:00
|
|
|
foreach ($pkt = Packet::process($packet,$f->itemName(),$f->itemSize(),$a->zone->domain) as $msg) {
|
2022-11-13 13:29:55 +00:00
|
|
|
// @todo Quick check that the packet should be processed by us.
|
2023-01-25 05:26:10 +00:00
|
|
|
$this->info(sprintf('Processing message from [%s] with msgid [%s] in (%s)',$msg->fboss,$msg->msgid,$f->pktName()));
|
2021-09-12 13:06:17 +00:00
|
|
|
|
2022-11-13 13:29:55 +00:00
|
|
|
// Dispatch job.
|
2023-09-20 10:29:23 +00:00
|
|
|
Job::dispatchSync($msg,$f->pktName(),$a,$pkt->fftn_o,Carbon::now(),$this->option('nobot'));
|
2022-11-13 13:29:55 +00:00
|
|
|
}
|
2021-07-15 14:54:23 +00:00
|
|
|
}
|
|
|
|
}
|
2023-07-15 00:46:19 +00:00
|
|
|
}
|