More TIC processing fixes

This commit is contained in:
Deon George 2023-09-05 21:57:34 +12:00
parent 63a9c06fb0
commit 6498e364fb
4 changed files with 24 additions and 9 deletions

View File

@ -8,7 +8,7 @@ abstract class FTN
{ {
protected ?Zone $zone; // Zone the packet is from protected ?Zone $zone; // Zone the packet is from
public function __get($key) public function __get(string $key)
{ {
switch ($key) { switch ($key) {
case 'fftn': case 'fftn':

View File

@ -73,9 +73,22 @@ class Tic extends FTNBase
$this->values = collect(); $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 * Generate a TIC file for an address
* *
* @param Address $ao
* @param File $fo
* @return string * @return string
*/ */
public static function generate(Address $ao,File $fo): string public static function generate(Address $ao,File $fo): string
@ -193,9 +206,11 @@ class Tic extends FTNBase
case 'pw': case 'pw':
$pw = $matches[2]; $pw = $matches[2];
break;
case 'lfile': case 'lfile':
$this->fo->lname = $matches[2]; $this->fo->lname = $matches[2];
break;
case 'desc': case 'desc':
case 'magic': case 'magic':

View File

@ -57,11 +57,11 @@ class TicProcess implements ShouldQueue
public function handle() public function handle()
{ {
$to = new Tic; $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()) if ($to->isNodelist())
NodelistImport::dispatch($to->fo,$this->domain); NodelistImport::dispatch($to->fo,$this->domain);

View File

@ -81,18 +81,18 @@ class File extends Model
// Our address // Our address
$ftns = $so $ftns = $so
->system ->system
->match($model->fftn->zone,Address::NODE_ACTIVE|Address::NODE_PVT|Address::NODE_HOLD); ->match($model->fftn->zone);
// Add our address to the seenby; // Add our address to the seenby;
$model->set_seenby = $model->set_seenby->merge($ftns->pluck('id'))->unique(); $model->set_seenby = $model->set_seenby->merge($ftns->pluck('id'))->unique();
$model->set_path = $model->set_path->merge([[ $model->set_path = $model->set_path->merge([[
'address'=>$ftns->first(), 'address'=>$ftns->first(),
'datetime'=>($x=Carbon::now())->timestamp, 'datetime'=>$x=Carbon::now(),
'extra'=>sprintf('%s %s (%s)',$x->toRfc7231String(),$so::PRODUCT_NAME,$so->version), 'extra'=>sprintf('%s %s (%s)',$x->toRfc7231String(),$so::PRODUCT_NAME,$so->version),
]]); ]]);
// Make sure all the path is in the seenby // 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 // Save the seenby
$model->seenby()->sync($model->set_seenby); $model->seenby()->sync($model->set_seenby);
@ -111,12 +111,12 @@ class File extends Model
$ppoid = $po[0]->id; $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) { if ($model->filearea->sec_read) {
$exportto = $model $exportto = $model
->filearea ->filearea
->addresses ->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') ->pluck('id')
->diff($model->set_seenby); ->diff($model->set_seenby);