For nodelist import, find based on mailer_address first

This commit is contained in:
Deon George 2021-09-11 18:00:39 +10:00
parent 7e176d7bc1
commit ff2b246d31

View File

@ -295,15 +295,14 @@ class NodelistImport implements ShouldQueue
// We'll search and see if we already have that system // We'll search and see if we already have that system
} else { } else {
$so = System::where(function ($q) use ($system,$sysop) { $so = System::where('mailer_address',$address)
return $q->where('name',$system) ->where('mailer_port',$port)
->where('sysop',$sysop); ->single();
})
->orWhere(function ($q) use ($address,$port) { if (! $so)
return $q->where('mailer_address',$address) $so = System::where('name',$system)
->where('mailer_port',$port); ->where('sysop',$sysop)
}) ->firstOrNew();
->firstOrNew();
if ($so->exists) 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)); 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));