From 75f5424d4fb944e359653b104398273b874231bd Mon Sep 17 00:00:00 2001 From: Deon George Date: Mon, 9 Sep 2024 11:50:41 +1000 Subject: [PATCH] Change our mail packet name to be the youngest ID in the packet, not the youngest date --- app/Classes/FTN/Packet.php | 2 +- app/Classes/File/Base.php | 2 +- app/Classes/File/Mail.php | 19 +++++++++++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/Classes/FTN/Packet.php b/app/Classes/FTN/Packet.php index 2468395..7fc4a79 100644 --- a/app/Classes/FTN/Packet.php +++ b/app/Classes/FTN/Packet.php @@ -362,7 +362,7 @@ abstract class Packet extends FTNBase implements \Iterator, \Countable $this->content .= "\00\00"; - $this->messages = $msgs->map(fn($item)=>$item->only(['id','date'])); + $this->messages = $msgs->map(fn($item)=>$item->only(['id','datetime'])); return $this; } diff --git a/app/Classes/File/Base.php b/app/Classes/File/Base.php index 29a3db1..c7226de 100644 --- a/app/Classes/File/Base.php +++ b/app/Classes/File/Base.php @@ -11,7 +11,7 @@ use Illuminate\Support\Collection; * When sending, we can queue up a list of items, and mark one active (the one being sent) at a time. * * + Netmail/Echomail/TIC - * + name is dynamically calculated, based on timew() of the youngest item in the mail bundle + * + name is the hex ID of the youngest item in the mail bundle * + size is dynamically calculated based on the size of the bundle * + mtime is dynamically calculated, based on the age of the youngest item * + sendas (nameas) is name + [.pkt|.tic] diff --git a/app/Classes/File/Mail.php b/app/Classes/File/Mail.php index 55441a2..eb43d49 100644 --- a/app/Classes/File/Mail.php +++ b/app/Classes/File/Mail.php @@ -4,6 +4,7 @@ namespace App\Classes\File; use Carbon\Carbon; +use Illuminate\Support\Arr; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; @@ -36,13 +37,13 @@ final class Mail extends Send return $this->f->messages->pluck('id'); case 'name': - return sprintf('%08x',timew($this->youngest())); + return sprintf('%08x',$this->youngest_id()); case 'nameas': return sprintf('%s.pkt',$this->name); case 'mtime': - return $this->youngest()->timestamp; + return $this->youngest_date()->timestamp; case 'type': return ($this->ftype&0xff00)>>8; @@ -114,8 +115,18 @@ final class Mail extends Send return TRUE; } - private function youngest(): Carbon + private function youngest(): array { - return $this->f->messages->pluck('date')->sort()->last(); + return $this->f->messages->sortBy(fn($item)=>Arr::get($item,'datetime'))->first(); + } + + private function youngest_id(): int + { + return Arr::get($this->youngest(),'id',0); + } + + private function youngest_date(): Carbon + { + return Arr::get($this->youngest(),'datetime',Carbon::now()); } } \ No newline at end of file