clrghouz/app/Console/Commands/PacketProcess.php

54 lines
1.3 KiB
PHP
Raw Normal View History

<?php
namespace App\Console\Commands;
use Carbon\Carbon;
use Illuminate\Console\Command;
2022-11-13 13:29:55 +00:00
use App\Classes\File;
use App\Classes\FTN\Packet;
2021-09-06 13:39:32 +00:00
use App\Jobs\MessageProcess as Job;
use App\Models\Address;
class PacketProcess extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'packet:process'
2022-11-13 13:29:55 +00:00
.' {file : Packet to process}'
.' {--N|nobot : Dont process bots}'
.' {ftn : System the packet is from}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Process Packet';
/**
* Execute the console command.
*
* @return mixed
* @throws \App\Classes\FTN\InvalidPacketException
* @todo Should this just call PacketProcess instead?
*/
public function handle()
{
2022-11-13 13:29:55 +00:00
$f = new File($this->argument('file'));
$a = Address::findFTN($this->argument('ftn'));
2022-11-13 13:29:55 +00:00
foreach ($f as $packet) {
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.
$this->info(sprintf('Processing message from [%s] with msgid [%s] in (%s)',$msg->fboss,$msg->msgid,$f->pktName()));
2022-11-13 13:29:55 +00:00
// Dispatch job.
Job::dispatchSync($msg,$f->pktName(),$a,$pkt->fftn_o,Carbon::now(),$this->option('nobot'));
2022-11-13 13:29:55 +00:00
}
}
}
}