From 3f7f04c38223f08b178b923c5042bb2afa7947bd Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 30 Jul 2023 12:11:08 +1000 Subject: [PATCH] Detect when we dont have an address in a domain, and pick the first domain address even if we are not in the zone. --- app/Models/Echomail.php | 4 ++++ app/Models/System.php | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Models/Echomail.php b/app/Models/Echomail.php index a6933b8..9664e8e 100644 --- a/app/Models/Echomail.php +++ b/app/Models/Echomail.php @@ -205,6 +205,10 @@ final class Echomail extends Model implements Packet $o->origin = $this->origin; $sysaddress = Setup::findOrFail(config('app.id'))->system->match($this->fftn->zone)->first(); + + if (! $sysaddress) + throw new \Exception(sprintf('%s:! We dont have an address in this network? (%s)',self::LOGKEY,$this->fftn->zone->domain->name)); + $o->seenby = $this->seenby->push($sysaddress)->unique()->pluck('ftn2d'); // Add our address to the path and seenby diff --git a/app/Models/System.php b/app/Models/System.php index bd18d7d..9124329 100644 --- a/app/Models/System.php +++ b/app/Models/System.php @@ -195,7 +195,9 @@ class System extends Model public function match(Zone $o,int $type=(Address::NODE_NC|Address::NODE_HC|Address::NODE_ACTIVE|Address::NODE_PVT|Address::NODE_POINT)): Collection { return $this->akas - ->where('zone_id',$o->id) + ->where(function($item) use($o) { + return ($item->zone_id === $o->id) || ($item->zone->domain_id === $o->domain_id); + }) ->filter(function($item) use ($type) { return $item->role & $type; });