Rework address roles, making Address::role optional, rework determining uplink/downlinks/parent/children
This commit is contained in:
@@ -69,7 +69,7 @@ class MailSend #implements ShouldQueue
|
||||
|
||||
// Return the system we poll
|
||||
$u = $u->transform(function($item) {
|
||||
if ($x=$item->parent()) {
|
||||
if ($x=$item->uplink()) {
|
||||
$x->uncollected_echomail = $item->uncollected_echomail;
|
||||
$x->uncollected_netmail = $item->uncollected_netmail;
|
||||
$x->uncollected_files = $item->uncollected_files;
|
||||
|
@@ -178,6 +178,7 @@ class NodelistImport implements ShouldQueue
|
||||
}
|
||||
|
||||
$node = 0;
|
||||
$role = NULL;
|
||||
|
||||
switch ($fields[0]) {
|
||||
case 'Zone':
|
||||
@@ -193,7 +194,6 @@ class NodelistImport implements ShouldQueue
|
||||
$region = 0;
|
||||
$host = 0;
|
||||
$hub_id = NULL;
|
||||
$role = Address::NODE_ZC;
|
||||
|
||||
break;
|
||||
|
||||
@@ -201,14 +201,12 @@ class NodelistImport implements ShouldQueue
|
||||
$region = (int)$fields[1];
|
||||
$host = (int)$fields[1];
|
||||
$hub_id = NULL;
|
||||
$role = Address::NODE_RC;
|
||||
|
||||
break;
|
||||
|
||||
case 'Host':
|
||||
$host = (int)$fields[1];
|
||||
$hub_id = NULL;
|
||||
$role = Address::NODE_NC;
|
||||
|
||||
break;
|
||||
|
||||
@@ -238,7 +236,6 @@ class NodelistImport implements ShouldQueue
|
||||
|
||||
case '':
|
||||
$node = $fields[1];
|
||||
$role = Address::NODE_ACTIVE;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -431,7 +428,7 @@ class NodelistImport implements ShouldQueue
|
||||
$so->sysop = $sysop;
|
||||
|
||||
// We have the same name has changed (except for ZC/RC addresses)
|
||||
} elseif (($so->name !== $system) && (! ((Address::NODE_ZC|Address::NODE_RC|Address::NODE_NC) & $ao->role))) {
|
||||
} elseif (($so->name !== $system) && (! ((Address::NODE_ZC|Address::NODE_RC|Address::NODE_NC) & $ao->role_id))) {
|
||||
Log::alert(sprintf('%s:! System Name changed for BBS [%s:%s] to [%s]',
|
||||
self::LOGKEY,$so->id,$so->name,$system));
|
||||
|
||||
@@ -499,6 +496,7 @@ class NodelistImport implements ShouldQueue
|
||||
throw new \Exception($e->getMessage());
|
||||
}
|
||||
|
||||
// @todo This should be a bit test ($ao->rule & Address::NODE_PVT)?
|
||||
if ($methods->count() && ($ao->role != Address::NODE_PVT)) {
|
||||
$methods->transform(function($item) { $item['active'] = Arr::get($item,'active',TRUE); return $item; });
|
||||
$so->mailers()->sync($methods);
|
||||
@@ -519,7 +517,7 @@ class NodelistImport implements ShouldQueue
|
||||
try {
|
||||
$so->addresses()->save($ao);
|
||||
|
||||
if ($ao->role === Address::NODE_HC)
|
||||
if ($ao->role_id === Address::NODE_HC)
|
||||
$hub_id = $ao->id;
|
||||
|
||||
$no->addresses()->attach($ao,['role'=>$ao->role]);
|
||||
|
@@ -44,7 +44,7 @@ class SystemHeartbeat #implements ShouldQueue
|
||||
->whereNotNull('pollmode')
|
||||
->where(function($query) {
|
||||
return $query
|
||||
->where('role','<',Address::NODE_ACTIVE)
|
||||
->where('role','<',Address::NODE_NN)
|
||||
->orWhereNotNull('heartbeat');
|
||||
})
|
||||
->when(! $this->force,function($query) {
|
||||
@@ -62,7 +62,7 @@ class SystemHeartbeat #implements ShouldQueue
|
||||
if (Job::where('queue','poll')->get()->pluck('command.address.id')->search($oo->id) === FALSE) {
|
||||
if ((! $oo->system->last_session)
|
||||
|| ($oo->system->hearbeat && ($oo->system->last_session->addHours($oo->system->heartbeat) < Carbon::now()))
|
||||
|| ((! $oo->system->hearbeat) && ($oo->role < Address::NODE_ACTIVE) && ($oo->system->last_session->addHours(6) < Carbon::now())))
|
||||
|| ((! $oo->system->hearbeat) && ($oo->role_id < Address::NODE_NN) && ($oo->system->last_session->addHours(6) < Carbon::now())))
|
||||
{
|
||||
Log::info(sprintf('%s:- Polling [%s] (%s) - we havent seen them since [%s], heartbeat [%d]',
|
||||
self::LOGKEY,
|
||||
|
Reference in New Issue
Block a user