Change the way we figure out zones in packets, some packet testing, fix Echomail import

This commit is contained in:
Deon George
2021-08-29 23:58:12 +10:00
parent 271f066667
commit 9fb6d191d0
11 changed files with 218 additions and 48 deletions

View File

@@ -0,0 +1,35 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\Echomail;
class EchomailDump extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'echomail:dump {id}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Echomail Dump';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
dump(Echomail::findOrFail($this->argument('id')));
}
}

View File

@@ -6,8 +6,7 @@ use Illuminate\Console\Command;
use Symfony\Component\HttpFoundation\File\File;
use App\Classes\FTN\Packet;
use App\Jobs\ProcessPacket as Job;
use App\Models\Domain;
use App\Models\Zone;
class PacketInfo extends Command
{
@@ -16,7 +15,7 @@ class PacketInfo extends Command
*
* @var string
*/
protected $signature = 'packet:info {pkt : Packet to process} {domain : Domain the packet is from}';
protected $signature = 'packet:info {pkt : Packet to process} {zone? : Zone the packet is from}';
/**
* The console command description.
@@ -34,9 +33,9 @@ class PacketInfo extends Command
public function handle()
{
$f = new File($this->argument('pkt'));
$d = Domain::where('name',$this->argument('domain'))->singleOrFail();
$z = $this->argument('zone') ? Zone::where('zone_id',$this->argument('zone'))->singleOrFail() : NULL;
$pkt = Packet::open($f,$d);
$pkt = Packet::open($f,$z);
$this->info(sprintf('Packet Type: %s',$pkt->type));
$this->info(sprintf('From: %s to %s',$pkt->fftn,$pkt->tftn));

View File

@@ -16,7 +16,7 @@ class ProcessPacket extends Command
*
* @var string
*/
protected $signature = 'packet:process {pkt : Packet to process} {domain : Domain the packet is from}';
protected $signature = 'packet:process {pkt : Packet to process} {domain? : Domain the packet is from}';
/**
* The console command description.
@@ -34,14 +34,14 @@ class ProcessPacket extends Command
public function handle()
{
$f = new File($this->argument('pkt'));
$d = Domain::where('name',$this->argument('domain'))->singleOrFail();
$d = $this->argument('domain') ? Domain::where('name',$this->argument('domain'))->singleOrFail() : NULL;
foreach (Packet::open($f,$d) as $msg) {
// @todo Quick check that the packet should be processed by us.
// @todo validate that the packet's zone is in the domain.
// Dispatch job.
Job::dispatch($msg);
Job::dispatchSync($msg);
}
}
}