Fixes for DE-LIST notifications

This commit is contained in:
Deon George 2024-09-08 20:39:10 +10:00
parent 9d7455233b
commit 7f95305d75
5 changed files with 13 additions and 9 deletions

View File

@ -51,8 +51,8 @@ class AddressIdle implements ShouldQueue
// Delist DOWN nodes // Delist DOWN nodes
foreach ($this->old($this->do,config('fido.idle.delist'),Address::NODE_DOWN,$this->ao) as $ao) { foreach ($this->old($this->do,config('fido.idle.delist'),Address::NODE_DOWN,$this->ao) as $ao) {
// Only delist system that has been marked down // Only delist system that has been marked down
// Only mark delist them if its been 7 days since they were marked DOWN // Only mark delist them if its been 14 days since they were marked DOWN
if ((! $ao->is_down) || ($ao->updated_at->isPast(Carbon::now()->subWeek()))) if ((! $ao->is_down) || ($ao->updated_at->greaterThan(Carbon::now()->subWeeks(2))))
continue; continue;
Log::info(sprintf('%s:- Delisting [%s], not seen for [%d] days',self::LOGKEY,$ao->ftn,config('fido.idle.delist'))); Log::info(sprintf('%s:- Delisting [%s], not seen for [%d] days',self::LOGKEY,$ao->ftn,config('fido.idle.delist')));
@ -130,8 +130,9 @@ class AddressIdle implements ShouldQueue
$result->push($ao); $result->push($ao);
} }
// @todo Make sure we only process addresses that we are responsible for, eg: 1/999 shouldnt have been processed even though 3/999 as eligible (and they are were connected to the same system)
// Mark nodes as HOLD // Mark nodes as HOLD
foreach ($this->old($this->do,config('fido.idle.hold'),0,$this->ao) as $ao) { foreach ($this->old($this->do,config('fido.idle.hold'),Address::NODE_ALL,$this->ao) as $ao) {
// Ignore any systems that are a Discoverd System // Ignore any systems that are a Discoverd System
if ($ao->system->name === System::default) { if ($ao->system->name === System::default) {
Log::alert(sprintf('%s:! Ignoring HOLD for discovered System [%s]',self::LOGKEY,$ao->ftn)); Log::alert(sprintf('%s:! Ignoring HOLD for discovered System [%s]',self::LOGKEY,$ao->ftn));

View File

@ -228,7 +228,7 @@ class Address extends Model
}) })
->orWhere('host_id',$ftn['n']); ->orWhere('host_id',$ftn['n']);
}) })
->with(['system:id,active,name,address,pkt_msgs']) ->with(['system:id,active,name,address,pkt_msgs,last_session'])
->first(); ->first();
// Check and see if we are a flattened domain, our address might be available with a different zone. // Check and see if we are a flattened domain, our address might be available with a different zone.

View File

@ -58,7 +58,7 @@ class AbsentNodes extends Echomails
$msg->addText("The following nodes have had their status changed, because they are absent from the network.\r\r"); $msg->addText("The following nodes have had their status changed, because they are absent from the network.\r\r");
// Nodes marked HOLD - will be marked down ... // Nodes marked HOLD - will be marked down ...
if (($x=$this->aos->filter(fn($item)=>$item->role & Address::NODE_HOLD))->count()) { if (($x=$this->aos->filter(fn($item)=>$item->active && ($item->role & Address::NODE_HOLD)))->count()) {
$msg->addText("The following nodes have been marked HOLD:\r"); $msg->addText("The following nodes have been marked HOLD:\r");
foreach ($x as $ao) foreach ($x as $ao)
@ -68,7 +68,7 @@ class AbsentNodes extends Echomails
} }
// Nodes marked DOWN - will be delisted on... // Nodes marked DOWN - will be delisted on...
if (($x=$this->aos->filter(fn($item)=>$item->role & Address::NODE_DOWN))->count()) { if (($x=$this->aos->filter(fn($item)=>$item->active && ($item->role & Address::NODE_DOWN)))->count()) {
$msg->addText("The following nodes have been marked DOWN:\r"); $msg->addText("The following nodes have been marked DOWN:\r");
foreach ($x as $ao) foreach ($x as $ao)

View File

@ -35,9 +35,9 @@ class NodeDelisted extends Netmails //implements ShouldQueue
$o = $this->setupNetmail($notifiable); $o = $this->setupNetmail($notifiable);
$ao = $notifiable->routeNotificationFor(static::via); $ao = $notifiable->routeNotificationFor(static::via);
Log::info(sprintf('%s:+ Sending a NODE MARKED HOLD for address [%s]',self::LOGKEY,$ao->ftn)); Log::info(sprintf('%s:+ Sending a NODE DE-LISTED for address [%s]',self::LOGKEY,$ao->ftn));
$o->subject = sprintf('Your system has been DE-LISTED from %s',$x=$ao->zone->domain->name); $o->subject = sprintf('Your system has been DE-LISTED from %s',$x=$this->ao->zone->domain->name);
$o->flags = (Message::FLAG_LOCAL|Message::FLAG_PRIVATE|Message::FLAG_CRASH); $o->flags = (Message::FLAG_LOCAL|Message::FLAG_PRIVATE|Message::FLAG_CRASH);
// Message // Message
@ -46,7 +46,7 @@ class NodeDelisted extends Netmails //implements ShouldQueue
$msg->addText(sprintf("Hi %s,\r\r",$this->ao->system->sysop)) $msg->addText(sprintf("Hi %s,\r\r",$this->ao->system->sysop))
->addText(sprintf("Your system has been marked **DE-LISTED**, because it hasnt polled **%s** with address %s since **%s** (%d days).\r",$this->ao->zone->domain->name,$this->ao->ftn4d,$this->ao->system->last_session->format('Y-m-d'),$this->ao->system->last_session->diffInDays($now))) ->addText(sprintf("Your system has been marked **DE-LISTED**, because it hasnt polled **%s** with address %s since **%s** (%d days).\r",$this->ao->zone->domain->name,$this->ao->ftn4d,$this->ao->system->last_session->format('Y-m-d'),$this->ao->system->last_session->diffInDays($now)))
->addText("\r") ->addText("\r")
->addText("If you think this was a mistake, please let me know.\r") ->addText("If you think this was a mistake, please let me know.\r\r")
->addText(sprintf('If you think about returning to %s, then reach out and we can get you back online pretty quickly.',$x)); ->addText(sprintf('If you think about returning to %s, then reach out and we can get you back online pretty quickly.',$x));
$o->msg = $msg->render(); $o->msg = $msg->render();

View File

@ -180,6 +180,9 @@
@if (($x=$o->uplink()) && ($x->id !== $o->id)) @if (($x=$o->uplink()) && ($x->id !== $o->id))
<br><small>[via <a href="{{ url('system/addedit',$x->system_id) }}">{{ $x->ftn4d }}</a>]</small> <br><small>[via <a href="{{ url('system/addedit',$x->system_id) }}">{{ $x->ftn4d }}</a>]</small>
@endif @endif
@if($o->is_down || $o->is_hold)
<br><div class="btn btn-sm btn-secondary p-1 m-0"><small>@if($o->is_down)DOWN @elseif($o->is_hold)HOLD @else? @endif</small></div>
@endif
</td> </td>
<td>{{ $o->ftn4d }}</td> <td>{{ $o->ftn4d }}</td>
<td class="text-end">{{ number_format($o->uncollected_echomail ?? 0) }}</td> <td class="text-end">{{ number_format($o->uncollected_echomail ?? 0) }}</td>