From 4f8448563d7bfe533eb3b075f4dc00e870d4699f Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 23 May 2024 17:36:47 +1000 Subject: [PATCH] Fix for when adding our address to path for outgoing echomails - introduced in 5fc6906 --- app/Classes/FTN/Message.php | 4 +++- app/Classes/File/Mail.php | 8 ++++++-- app/Models/Address.php | 2 +- app/Traits/MessageAttributes.php | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/Classes/FTN/Message.php b/app/Classes/FTN/Message.php index 3355e46..5fb0f50 100644 --- a/app/Classes/FTN/Message.php +++ b/app/Classes/FTN/Message.php @@ -152,6 +152,7 @@ class Message extends FTNBase * * @param Echomail|Netmail $o * @return self + * @throws \Exception */ public static function packMessage(Echomail|Netmail $o): self { @@ -572,7 +573,8 @@ class Message extends FTNBase // FTS-0004.001/FSC-0068.001 The message SEEN-BY lines // FTS-0004.001/FSC-0068.001 The message PATH lines - $path = $this->mo->path->push($this->us)->filter(fn($item)=>($item->point_id === 0)); + // @todo This unique() function here shouldnt be required, but is while system generated messages are storing path/seenby + $path = $this->mo->path->push($this->us)->unique('ftn')->filter(fn($item)=>($item->point_id === 0)); // Create our rogue seenby objects $seenby = $this->mo->seenby; diff --git a/app/Classes/File/Mail.php b/app/Classes/File/Mail.php index e07ec78..c6297c6 100644 --- a/app/Classes/File/Mail.php +++ b/app/Classes/File/Mail.php @@ -16,6 +16,7 @@ final class Mail extends Send /** @var int Our internal position counter */ private int $readpos; + private ?string $content; /** * @throws \Exception @@ -84,6 +85,8 @@ final class Mail extends Send 'sent_at'=>Carbon::now(), 'sent_pkt'=>$this->name, ]); + + $this->content = NULL; } } @@ -94,12 +97,13 @@ final class Mail extends Send public function open(string $compress=''): bool { + $this->content = (string)$this->f; return TRUE; } public function read(int $length): string { - $result = substr((string)$this->f,$this->readpos,$length); + $result = substr($this->content,$this->readpos,$length); $this->readpos += strlen($result); return $result; @@ -108,7 +112,7 @@ final class Mail extends Send public function seek(int $pos): bool { $this->readpos = ($pos < $this->size) ? $pos : $this->size; - return TRUE; + return TRUE; } private function youngest(): Carbon diff --git a/app/Models/Address.php b/app/Models/Address.php index ba6b117..3257f4e 100644 --- a/app/Models/Address.php +++ b/app/Models/Address.php @@ -340,7 +340,7 @@ class Address extends Model $zone_id = $parent?->zone->zone_id; // For flattened domains - if ($zo->domain->flatten && is_null($zone_id)) + if ($zo?->domain->flatten && is_null($zone_id)) foreach ($zo->domain->zones as $zoo) { $o->zone_id = $zoo->id; $parent = $o->parent(); diff --git a/app/Traits/MessageAttributes.php b/app/Traits/MessageAttributes.php index 466b09e..b3c97e8 100644 --- a/app/Traits/MessageAttributes.php +++ b/app/Traits/MessageAttributes.php @@ -167,7 +167,7 @@ trait MessageAttributes */ public function packet(Address $ao): Message { - Log::debug(sprintf('%s:+ Bundling [%s]',self::LOGKEY,$this->id),['type'=>get_class($this)]); + Log::debug(sprintf('%s:+ Bundling [%s] for [%s]',self::LOGKEY,$this->id,$ao->ftn),['type'=>get_class($this)]); // For netmails, our tftn is the next hop $this->tftn = $ao;