From c6458219bf2d75e4bfaed71e7543808f0cfc2858 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 | 16 ++++++---------- app/Models/Address.php | 30 ++++++++++++------------------ 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/app/Jobs/AddressPoll.php b/app/Jobs/AddressPoll.php index 428a21f..daa27d1 100644 --- a/app/Jobs/AddressPoll.php +++ b/app/Jobs/AddressPoll.php @@ -170,20 +170,16 @@ class AddressPoll implements ShouldQueue, ShouldBeUnique return TRUE; } - return FALSE; - }), - - // If there is no mail anymore, no need trying - Skip::unless(function(): bool { - if ($this->force - || ($this->ao->echomailWaitingCount() > 0) - || ($this->ao->fileWaitingCount() > 0) - || ($this->ao->netmailWaitingCount() > 0)) { + // If there is no mail anymore, no need trying + if ((! $this->force) + && ($this->ao->echomailWaitingCount() === 0) + && ($this->ao->filesWaitingCount() === 0) + && ($this->ao->netmailWaitingCount() === 0)) { + Log::info(sprintf('%s:/ Nothing waiting - abandoning poll [%s]',self::LOGKEY,$this->ao->ftn)); return TRUE; } - Log::info(sprintf('%s:/ Nothing waiting - abandoning poll [%s]',self::LOGKEY,$this->ao->ftn)); return FALSE; }), ]; diff --git a/app/Models/Address.php b/app/Models/Address.php index 32aaee2..eb8ef19 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(); } @@ -1094,7 +1090,7 @@ class Address extends Model if ($count > $this->system->batch_files) Log::notice(sprintf('%s:= Only sending [%d] files for [%s]',self::LOGKEY,$this->system->batch_files,$this->ftn)); - return $num->take($this->system->batch_files); + return $num->take($this->system->batch_files)->get(); } return new Collection; @@ -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(); }