From ff2b246d31ecba4a19f786801500b3188d55a6ef Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 11 Sep 2021 18:00:39 +1000 Subject: [PATCH] For nodelist import, find based on mailer_address first --- app/Jobs/NodelistImport.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/Jobs/NodelistImport.php b/app/Jobs/NodelistImport.php index e664938..5c6510d 100644 --- a/app/Jobs/NodelistImport.php +++ b/app/Jobs/NodelistImport.php @@ -295,15 +295,14 @@ class NodelistImport implements ShouldQueue // We'll search and see if we already have that system } else { - $so = System::where(function ($q) use ($system,$sysop) { - return $q->where('name',$system) - ->where('sysop',$sysop); - }) - ->orWhere(function ($q) use ($address,$port) { - return $q->where('mailer_address',$address) - ->where('mailer_port',$port); - }) - ->firstOrNew(); + $so = System::where('mailer_address',$address) + ->where('mailer_port',$port) + ->single(); + + if (! $so) + $so = System::where('name',$system) + ->where('sysop',$sysop) + ->firstOrNew(); if ($so->exists) Log::debug(sprintf('%s:Linking address [%d:%d/%d] to [%s:%s]',self::LOGKEY,$zo->zone_id,$ao->host_id,$ao->node_id,$so->id,$so->name));