From 4f6e1e90c67356f6fd5df2531a8a8b42711efe56 Mon Sep 17 00:00:00 2001 From: Deon George Date: Fri, 21 Jun 2024 12:15:22 +1000 Subject: [PATCH] Fix file sending, as a result of moving $size into Send::class when optimising mail sending --- app/Classes/File/File.php | 3 ++- app/Classes/File/Tic.php | 5 ++--- app/Models/Address.php | 15 +++++++++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/Classes/File/File.php b/app/Classes/File/File.php index cbe06a6..0d83980 100644 --- a/app/Classes/File/File.php +++ b/app/Classes/File/File.php @@ -41,7 +41,6 @@ final class File extends Send return $this->f->datetime->timestamp; case 'name': - case 'size': return $this->f->{$key}; case 'type': @@ -84,6 +83,8 @@ final class File extends Send */ public function open(string $compress=''): bool { + $this->size = $this->f->size; + // If sending file is a File::class, then our file is s3 if ($this->nameas && $this->f instanceof FileModel) { $this->fd = Storage::readStream($this->f->rel_name); diff --git a/app/Classes/File/Tic.php b/app/Classes/File/Tic.php index 2b13d7d..aaef2ac 100644 --- a/app/Classes/File/Tic.php +++ b/app/Classes/File/Tic.php @@ -43,9 +43,6 @@ final class Tic extends Send case 'mtime': return $this->f->datetime->timestamp; - case 'size': - return strlen($this->tic); - case 'type': return ($this->ftype&0xff00)>>8; @@ -67,6 +64,8 @@ final class Tic extends Send public function open(string $compress=''): bool { + $this->size = strlen($this->tic); + return TRUE; } diff --git a/app/Models/Address.php b/app/Models/Address.php index b0caee4..703fcbb 100644 --- a/app/Models/Address.php +++ b/app/Models/Address.php @@ -1043,9 +1043,20 @@ class Address extends Model */ public function filesWaiting(): Collection { - return $this->file_seen() - ->whereNull('sent_at') + return File::select('files.*') + ->join('file_seenby',['file_seenby.file_id'=>'files.id']) + ->where('address_id',$this->id) + ->whereNull('files.deleted_at') ->whereNotNull('export_at') + ->whereNull('sent_at') + ->orderby('id') + ->with([ + 'filearea:id,name,domain_id', + 'filearea.domain:id,name', + 'fftn:id,zone_id,host_id,node_id,point_id', + 'fftn.zone:id,domain_id,zone_id', + 'fftn.zone.domain:id,name', + ]) ->get(); }