From a886a389a81153520d20a59321ae8a744ff5d246 Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 26 Oct 2023 11:02:36 +1100 Subject: [PATCH] Fix for echomail notifications, when echomails come from a point. Auto detect address when manually processing packets. --- app/Console/Commands/PacketInfo.php | 12 ++++++++++-- app/Console/Commands/PacketProcess.php | 24 ++++++++++++++++++++---- app/Notifications/Echomails.php | 2 +- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/app/Console/Commands/PacketInfo.php b/app/Console/Commands/PacketInfo.php index 96d0246..4335695 100644 --- a/app/Console/Commands/PacketInfo.php +++ b/app/Console/Commands/PacketInfo.php @@ -37,12 +37,20 @@ class PacketInfo extends Command { $fs = Storage::disk(config('fido.local_disk')); $rel_name = sprintf('%s/%s',config('fido.dir'),$this->argument('file')); + $a = NULL; $f = new File($fs->path($rel_name)); - $a = $this->argument('ftn') ? Address::findFTN($this->argument('ftn')) : NULL; + + $m = NULL; + if ($this->argument('ftn')) { + $a = Address::findFTN($this->argument('ftn')); + + } elseif (preg_match('/^(([0-9]+)-)+/',$this->argument('file'),$m)) { + $a = Address::findOrFail(hexdec($m[2])); + } foreach ($f as $packet) { - $pkt = Packet::process($packet,$x=$f->itemName(),$f->itemSize(),$a->zone->domain); + $pkt = Packet::process($packet,$x=$f->itemName(),$f->itemSize(),$a?->zone->domain); $this->alert(sprintf('File Name: %s',$x)); diff --git a/app/Console/Commands/PacketProcess.php b/app/Console/Commands/PacketProcess.php index f33fcf3..3365e31 100644 --- a/app/Console/Commands/PacketProcess.php +++ b/app/Console/Commands/PacketProcess.php @@ -4,6 +4,7 @@ namespace App\Console\Commands; use Carbon\Carbon; use Illuminate\Console\Command; +use Illuminate\Support\Facades\Storage; use App\Classes\File; use App\Classes\FTN\Packet; @@ -20,7 +21,7 @@ class PacketProcess extends Command protected $signature = 'packet:process' .' {file : Packet to process}' .' {--N|nobot : Dont process bots}' - .' {ftn : System the packet is from}'; + .' {ftn? : System the packet is from}'; /** * The console command description. @@ -38,11 +39,26 @@ class PacketProcess extends Command */ public function handle() { - $f = new File($this->argument('file')); - $a = Address::findFTN($this->argument('ftn')); + $fs = Storage::disk(config('fido.local_disk')); + $rel_name = sprintf('%s/%s',config('fido.dir'),$this->argument('file')); + $a = NULL; + + $f = new File($fs->path($rel_name)); + + $m = NULL; + if ($this->argument('ftn')) { + $a = Address::findFTN($this->argument('ftn')); + + } elseif (preg_match('/^(([0-9]+)-)+/',$this->argument('file'),$m)) { + $a = Address::findOrFail(hexdec($m[2])); + + } else { + $this->error('Unable to determine sender FTN address'); + exit(1); + } foreach ($f as $packet) { - foreach ($pkt = Packet::process($packet,$f->itemName(),$f->itemSize(),$a->zone->domain) as $msg) { + foreach ($pkt = Packet::process($packet,$f->itemName(),$f->itemSize(),$a?->zone->domain) as $msg) { // @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())); diff --git a/app/Notifications/Echomails.php b/app/Notifications/Echomails.php index e114418..d369640 100644 --- a/app/Notifications/Echomails.php +++ b/app/Notifications/Echomails.php @@ -61,7 +61,7 @@ abstract class Echomails extends Notification //implements ShouldQueue $o->datetime = Carbon::now(); $o->tzoffset = $o->datetime->utcOffset(); - $o->fftn_id = ($x=$so->match($mo->fftn_o->zone)->first())->id; + $o->fftn_id = ($x=$so->match($mo->fboss_o->zone)->first())->id; $o->flags = (Message::FLAG_LOCAL); $o->tearline = sprintf('%s (%04X)',Setup::PRODUCT_NAME,Setup::PRODUCT_ID);