Changed nodelist import processing since we have a DB contraint on mailer address and port
This commit is contained in:
parent
6b8704b1cf
commit
12f9ee1960
@ -54,6 +54,7 @@ class EchoareaImport implements ShouldQueue
|
||||
{
|
||||
// Get the file from the host
|
||||
$file = $this->getFileFromHost('',self::importkey,$this->file);
|
||||
Log::debug(sprintf('%s:Loading file [%s] (%s).',static::LOGKEY,$file,getcwd()));
|
||||
$lines = $this->getFileLines($file);
|
||||
Log::debug(sprintf('%s:Processing [%d] lines.',static::LOGKEY,$lines));
|
||||
|
||||
|
@ -54,6 +54,7 @@ class NodelistImport implements ShouldQueue
|
||||
|
||||
// Get the file from the host
|
||||
$file = $this->getFileFromHost('',self::importkey,$this->file);
|
||||
Log::debug(sprintf('%s:Loading file [%s] (%s).',static::LOGKEY,$file,getcwd()));
|
||||
$lines = $this->getFileLines($file);
|
||||
Log::debug(sprintf('%s:Processing [%d] lines.',static::LOGKEY,$lines));
|
||||
|
||||
@ -81,7 +82,7 @@ class NodelistImport implements ShouldQueue
|
||||
return;
|
||||
}
|
||||
|
||||
Log::debug(sprintf('%s:Importing nodelist for [%s] dated [%s] lines.',static::LOGKEY,$do->name,$date->format('Y-m-d')));
|
||||
Log::debug(sprintf('%s:Importing nodelist for [%s] dated [%s].',static::LOGKEY,$do->name,$date->format('Y-m-d')));
|
||||
|
||||
DB::beginTransaction();
|
||||
$no = Nodelist::firstOrCreate(['date'=>$date,'domain_id'=>$do->id]);
|
||||
@ -212,56 +213,6 @@ class NodelistImport implements ShouldQueue
|
||||
$sysop = trim(str_replace('_',' ',$fields[4]));
|
||||
$system = trim(str_replace('_',' ',$fields[2]));
|
||||
|
||||
// Get the System
|
||||
if ($ao->system_id && (($ao->system->sysop === $sysop) || ($ao->system->name === $system))) {
|
||||
$so = $ao->system;
|
||||
|
||||
// Dont change the system details if a user exists here, or its us
|
||||
if ((! $so->users->count()) && ($so->id != $us->system_id)) {
|
||||
// If the sysop name is different
|
||||
if ($so->sysop !== $sysop) {
|
||||
Log::debug(sprintf('%s:Sysop Name changed for BBS [%s:%s] from [%s] to [%s]',
|
||||
self::LOGKEY,$so->id,$so->name,$so->sysop,$sysop));
|
||||
|
||||
$so->sysop = $sysop;
|
||||
|
||||
// We have the same name has changed.
|
||||
} elseif ($so->name !== $system) {
|
||||
Log::debug(sprintf('%s:System Name changed for BBS [%s:%s] to [%s]',
|
||||
self::LOGKEY,$so->id,$so->name,$system));
|
||||
|
||||
$so->name = $system;
|
||||
}
|
||||
}
|
||||
|
||||
// We'll search and see if we already have that system
|
||||
} else {
|
||||
$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));
|
||||
else
|
||||
Log::debug(sprintf('%s:New System [%s] with address [%d:%d/%d]',self::LOGKEY,$system,$zo->zone_id,$ao->host_id,$ao->node_id));
|
||||
|
||||
$so->name = $system;
|
||||
$so->sysop = $sysop;
|
||||
$so->active = TRUE;
|
||||
|
||||
if (! $so->exists)
|
||||
$so->notes = sprintf('Created by Nodelist Import: %d',$no->id);
|
||||
}
|
||||
|
||||
$so->phone = $fields[5] != '-Unpublished-' ? $fields[5] : NULL;
|
||||
$so->location = trim(str_replace('_',' ',$fields[3]));
|
||||
/*
|
||||
if (! in_array($fields[5],['-Unpublished-']))
|
||||
$so->phone = $fields[5];
|
||||
|
||||
$so->baud = $fields[6];
|
||||
*/
|
||||
|
||||
// Flags
|
||||
$method = NULL;
|
||||
$address = '';
|
||||
@ -318,12 +269,68 @@ class NodelistImport implements ShouldQueue
|
||||
Log::debug(sprintf('%s: - Not configured to handle flag [%s]',self::LOGKEY,$x->first()));
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
if ($method && ($ao->role != DomainController::NODE_PVT)) {
|
||||
$so->mailer_type = $method;
|
||||
$so->mailer_address = $address;
|
||||
$so->mailer_port = $port;
|
||||
// Get the System
|
||||
if ($ao->system_id && (($ao->system->sysop === $sysop) || ($ao->system->name === $system))) {
|
||||
$so = $ao->system;
|
||||
|
||||
// Dont change the system details if a user exists here, or its us
|
||||
if ((! $so->users->count()) && ($so->id != $us->system_id)) {
|
||||
// If the sysop name is different
|
||||
if ($so->sysop !== $sysop) {
|
||||
Log::debug(sprintf('%s:Sysop Name changed for BBS [%s:%s] from [%s] to [%s]',
|
||||
self::LOGKEY,$so->id,$so->name,$so->sysop,$sysop));
|
||||
|
||||
$so->sysop = $sysop;
|
||||
|
||||
// We have the same name has changed.
|
||||
} elseif ($so->name !== $system) {
|
||||
Log::debug(sprintf('%s:System Name changed for BBS [%s:%s] to [%s]',
|
||||
self::LOGKEY,$so->id,$so->name,$system));
|
||||
|
||||
$so->name = $system;
|
||||
}
|
||||
}
|
||||
|
||||
// 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();
|
||||
|
||||
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));
|
||||
else
|
||||
Log::debug(sprintf('%s:New System [%s] with address [%d:%d/%d]',self::LOGKEY,$system,$zo->zone_id,$ao->host_id,$ao->node_id));
|
||||
|
||||
$so->name = $system;
|
||||
$so->sysop = $sysop;
|
||||
$so->active = TRUE;
|
||||
|
||||
if (! $so->exists)
|
||||
$so->notes = sprintf('Created by Nodelist Import: %d',$no->id);
|
||||
}
|
||||
|
||||
$so->phone = $fields[5] != '-Unpublished-' ? $fields[5] : NULL;
|
||||
$so->location = trim(str_replace('_',' ',$fields[3]));
|
||||
/*
|
||||
if (! in_array($fields[5],['-Unpublished-']))
|
||||
$so->phone = $fields[5];
|
||||
|
||||
$so->baud = $fields[6];
|
||||
*/
|
||||
|
||||
if ($method && ($ao->role != DomainController::NODE_PVT)) {
|
||||
$so->mailer_type = $method;
|
||||
$so->mailer_address = $address;
|
||||
$so->mailer_port = $port;
|
||||
}
|
||||
|
||||
// Save the system record
|
||||
|
Loading…
Reference in New Issue
Block a user