From 9590ddcadb91be1bb9c3d440086a15261ea8c99b Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 17 Apr 2025 14:18:15 +1000 Subject: [PATCH] Additional fixes for 14616471 --- app/Jobs/AddressPoll.php | 2 +- app/Models/Address.php | 28 +++++++++++----------------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/app/Jobs/AddressPoll.php b/app/Jobs/AddressPoll.php index 428a21f..a8d2399 100644 --- a/app/Jobs/AddressPoll.php +++ b/app/Jobs/AddressPoll.php @@ -177,7 +177,7 @@ class AddressPoll implements ShouldQueue, ShouldBeUnique Skip::unless(function(): bool { if ($this->force || ($this->ao->echomailWaitingCount() > 0) - || ($this->ao->fileWaitingCount() > 0) + || ($this->ao->filesWaitingCount() > 0) || ($this->ao->netmailWaitingCount() > 0)) { return TRUE; diff --git a/app/Models/Address.php b/app/Models/Address.php index 32aaee2..7fa477f 100644 --- a/app/Models/Address.php +++ b/app/Models/Address.php @@ -976,14 +976,13 @@ class Address extends Model /** * Echomail waiting to be sent to this address * - * @return Collection + * @return Builder */ - public function echomailWaiting(): Collection + public function echomailWaiting(): Builder { return Echomail::Uncollected() ->where('address_id',$this->id) - ->orderby('id') - ->get(); + ->orderby('id'); } /** @@ -993,22 +992,20 @@ class Address extends Model */ public function echomailWaitingCount(): int { - return Echomail::Uncollected() - ->where('address_id',$this->id) + return $this->echomailWaiting() ->count(); } /** * Files waiting to be sent to this address * - * @return Collection + * @return Builder */ - public function filesWaiting(): Collection + public function filesWaiting(): Builder { return File::Uncollected() ->where('address_id',$this->id) - ->orderby('id') - ->get(); + ->orderby('id'); } /** @@ -1018,8 +1015,7 @@ class Address extends Model */ public function filesWaitingCount(): int { - return File::Uncollected() - ->where('address_id',$this->id) + return $this->filesWaiting() ->count(); } @@ -1169,16 +1165,14 @@ class Address extends Model } /** - * Count of echomail waiting to be sent to this address + * Count of netmail waiting to be sent to this address * * @return int + * @throws \Exception */ public function netmailWaitingCount(): int { - return Netmail::Uncollected() - ->whereIn('tftn_id',$this->downlinks() - ->add($this) - ->pluck('id')) + return $this->netmailWaiting() ->count(); }