From 6498e364fb5d13f9ffe3d640a5b7ac1f3b5426af Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 5 Sep 2023 21:57:34 +1200 Subject: [PATCH] More TIC processing fixes --- app/Classes/FTN.php | 2 +- app/Classes/FTN/Tic.php | 15 +++++++++++++++ app/Jobs/TicProcess.php | 6 +++--- app/Models/File.php | 10 +++++----- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/app/Classes/FTN.php b/app/Classes/FTN.php index 71ae4a0..509a390 100644 --- a/app/Classes/FTN.php +++ b/app/Classes/FTN.php @@ -8,7 +8,7 @@ abstract class FTN { protected ?Zone $zone; // Zone the packet is from - public function __get($key) + public function __get(string $key) { switch ($key) { case 'fftn': diff --git a/app/Classes/FTN/Tic.php b/app/Classes/FTN/Tic.php index dfbc259..896bab5 100644 --- a/app/Classes/FTN/Tic.php +++ b/app/Classes/FTN/Tic.php @@ -73,9 +73,22 @@ class Tic extends FTNBase $this->values = collect(); } + public function __get(string $key): mixed + { + switch ($key) { + case 'fo': + return $this->{$key}; + + default: + return parent::__get($key); + } + } + /** * Generate a TIC file for an address * + * @param Address $ao + * @param File $fo * @return string */ public static function generate(Address $ao,File $fo): string @@ -193,9 +206,11 @@ class Tic extends FTNBase case 'pw': $pw = $matches[2]; + break; case 'lfile': $this->fo->lname = $matches[2]; + break; case 'desc': case 'magic': diff --git a/app/Jobs/TicProcess.php b/app/Jobs/TicProcess.php index 4574ad1..47fdff5 100644 --- a/app/Jobs/TicProcess.php +++ b/app/Jobs/TicProcess.php @@ -57,11 +57,11 @@ class TicProcess implements ShouldQueue public function handle() { $to = new Tic; - $to->load(storage_path('app').$this->file); + $to->load(storage_path('app').'/'.$this->file); - Log::info(sprintf('%s:Processed [%s] storing [%s] as id [%d]',self::LOGKEY,$this->file,$to->fo->file,$to->fo->id)); + Log::info(sprintf('%s:Processed [%s] storing [%s] as id [%d]',self::LOGKEY,$this->file,$to->fo->name,$to->fo->id)); - unlink(storage_path('app').$this->file); + unlink(storage_path('app').'/'.$this->file); if ($to->isNodelist()) NodelistImport::dispatch($to->fo,$this->domain); diff --git a/app/Models/File.php b/app/Models/File.php index 5a3942f..6c782c3 100644 --- a/app/Models/File.php +++ b/app/Models/File.php @@ -81,18 +81,18 @@ class File extends Model // Our address $ftns = $so ->system - ->match($model->fftn->zone,Address::NODE_ACTIVE|Address::NODE_PVT|Address::NODE_HOLD); + ->match($model->fftn->zone); // Add our address to the seenby; $model->set_seenby = $model->set_seenby->merge($ftns->pluck('id'))->unique(); $model->set_path = $model->set_path->merge([[ 'address'=>$ftns->first(), - 'datetime'=>($x=Carbon::now())->timestamp, + 'datetime'=>$x=Carbon::now(), 'extra'=>sprintf('%s %s (%s)',$x->toRfc7231String(),$so::PRODUCT_NAME,$so->version), ]]); // Make sure all the path is in the seenby - $model->set_seenby = $model->set_seenby->merge($model->set_path->pluck('address.id'))->unique(); + $model->set_seenby = $model->set_seenby->merge($model->set_path->pluck('address.id'))->unique()->filter(); // Save the seenby $model->seenby()->sync($model->set_seenby); @@ -111,12 +111,12 @@ class File extends Model $ppoid = $po[0]->id; } - // See if we need to export this message. + // See if we need to export this file. if ($model->filearea->sec_read) { $exportto = $model ->filearea ->addresses - ->filter(function($item) use ($model) { return $item->security >= $model->echoarea->sec_read; }) + ->filter(function($item) use ($model) { return $item->security >= $model->filearea->sec_read; }) ->pluck('id') ->diff($model->set_seenby);