From 9d7455233b4c65c74f9214970737a09cdd8c13c9 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 8 Sep 2024 18:57:48 +1000 Subject: [PATCH] Improvements for finding intransit netmails to upstream and peer hubs --- app/Classes/Node.php | 2 +- app/Jobs/MailSend.php | 1 - app/Models/Address.php | 9 ++++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Classes/Node.php b/app/Classes/Node.php index 85abf3a..97b34f1 100644 --- a/app/Classes/Node.php +++ b/app/Classes/Node.php @@ -277,7 +277,7 @@ class Node public function originate(Address $o): void { $this->originate = $o; - $this->ftns_authed = $o->system->match($o->zone); + $this->ftns_authed = $o->system->match($o->zone,Address::NODE_ALL); } /** diff --git a/app/Jobs/MailSend.php b/app/Jobs/MailSend.php index 309b693..f5504a4 100644 --- a/app/Jobs/MailSend.php +++ b/app/Jobs/MailSend.php @@ -67,7 +67,6 @@ class MailSend #implements ShouldQueue } }) ->filter(function($item) { - if ($item->ftn3d === '1337:1/100') dump(['item'=>$item,'ftn'=>$item->ftn,'autohold'=>$item->system->authold,'pollmode'=>$item->system->pollmode,'crash'=>$this->crash]); if ($item->system->autohold) return NULL; diff --git a/app/Models/Address.php b/app/Models/Address.php index a1aaffc..9e20570 100644 --- a/app/Models/Address.php +++ b/app/Models/Address.php @@ -1193,10 +1193,17 @@ class Address extends Model */ public function netmailWaiting(): Builder { + // Addresses that our downstream of this address, except anybody that has session details with us + $ours = our_nodes($this->zone->domain)->pluck('id'); + + $addresses = $this->downstream() + ->filter(fn($item)=>! $ours->contains($item->id)) + ->merge($this->system->match($this->zone,Address::NODE_ALL)); + $netmails = $this ->UncollectedNetmail() ->select('netmails.id') - ->whereIn('addresses.id',$this->downlinks()->add($this)->pluck('id')) + ->whereIn('addresses.id',$addresses->pluck('id')) ->groupBy(['netmails.id']) ->get();