Automatically mark idle nodes HOLD/DOWN/DE-LIST. Automatically validate presented addresses.
This commit is contained in:
86
app/Notifications/Echomails/AbsentNodes.php
Normal file
86
app/Notifications/Echomails/AbsentNodes.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications\Echomails;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\{Fonts\Thick,Page};
|
||||
use App\Models\{Address,Echomail,Setup};
|
||||
use App\Notifications\Echomails;
|
||||
use App\Traits\MessagePath;
|
||||
|
||||
class AbsentNodes extends Echomails
|
||||
{
|
||||
use MessagePath;
|
||||
|
||||
private const LOGKEY = 'NNP';
|
||||
|
||||
private Echomail $mo;
|
||||
|
||||
/**
|
||||
* Reply to a netmail ping request.
|
||||
*
|
||||
* @param Echomail $mo
|
||||
*/
|
||||
public function __construct(private Collection $aos)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return Echomail
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function toEchomail(object $notifiable): Echomail
|
||||
{
|
||||
$echoarea = $notifiable->routeNotificationFor(static::via);
|
||||
$o = $this->setupEchomail($echoarea);
|
||||
$now = Carbon::now();
|
||||
|
||||
Log::info(sprintf('%s:+ Creating NODE ABSENT echomail in [%s]',self::LOGKEY,$echoarea->name));
|
||||
|
||||
$o->to = 'All';
|
||||
$o->subject = 'Status changes for nodes';
|
||||
$o->fftn_id = ($x=our_address($echoarea->domain)->last())->id;
|
||||
$o->kludges->put('CHRS:','CP437 2');
|
||||
$o->origin = sprintf('%s (%s)',Setup::PRODUCT_NAME,$x->ftn4d);
|
||||
|
||||
// Message
|
||||
$msg = new Page;
|
||||
|
||||
$header = new Thick;
|
||||
$header->addText('Clearing Houz');
|
||||
$msg->addHeader($header,'FTN Mailer and Tosser',TRUE,0xc4);
|
||||
|
||||
$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 ...
|
||||
foreach ($this->aos->filter(fn($item)=>$item->role & Address::NODE_HOLD) as $ao)
|
||||
$msg->addText(sprintf('* %s marked HOLD, last seen %d days ago',$ao->ftn4d,$ao->system->last_session->diffInDays($now)).($ao->contacted ? '': ' ^')."\r");
|
||||
|
||||
// Nodes marked DOWN - will be delisted on...
|
||||
foreach ($this->aos->filter(fn($item)=>$item->role & Address::NODE_DOWN) as $ao)
|
||||
$msg->addText(sprintf('* %s marked DOWN, last seen %d days ago',$ao->ftn4d,$ao->system->last_session->diffInDays($now)).($ao->contacted ? '': ' ^')."\r");
|
||||
|
||||
// Nodes DELISTED
|
||||
foreach ($this->aos->filter(fn($item)=>! $item->active) as $ao)
|
||||
$msg->addText(sprintf('* %s DE-LISTED, last seen %d days ago',$ao->ftn4d,$ao->system->last_session->diffInDays($now)).($ao->contacted ? '': ' ^')."\r");
|
||||
|
||||
if ($this->aos->filter(fn($item)=>(! $item->contacted))->count())
|
||||
$msg->addText("\r^ Unable to contact these nodes.\r");
|
||||
|
||||
$msg->addText("\rEmails and/or Netmails have been sent to these nodes. If you can help let them know that they have outstanding mail on the Hub, that would be helpful :)");
|
||||
|
||||
$o->msg = $msg->render();
|
||||
$o->tagline = 'When life gives you lemons, freeze them and throw them back.';
|
||||
|
||||
$o->save();
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
@@ -7,7 +7,7 @@ use Carbon\CarbonInterface;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\{Fonts\Thick,Fonts\Thin,Page};
|
||||
use App\Models\Echomail;
|
||||
use App\Models\{Echomail,Setup};
|
||||
use App\Notifications\Echomails;
|
||||
use App\Traits\MessagePath;
|
||||
|
||||
@@ -40,13 +40,17 @@ class Test extends Echomails
|
||||
*/
|
||||
public function toEchomail(object $notifiable): Echomail
|
||||
{
|
||||
$o = $this->setupEchomail($this->mo,$notifiable);
|
||||
$echoarea = $notifiable->routeNotificationFor(static::via);
|
||||
$o = $this->setupEchomail($echoarea);
|
||||
|
||||
Log::info(sprintf('%s:+ Creating TEST echomail in [%s]',self::LOGKEY,$echoarea->name));
|
||||
|
||||
$o->to = $this->mo->from;
|
||||
$o->fftn_id = ($x=our_address($this->mo->fftn))->id;
|
||||
$o->replyid = $this->mo->msgid;
|
||||
$o->subject = 'Test Reply';
|
||||
$o->kludges->put('CHRS:',$this->mo->kludges->get('chrs') ?: 'CP437 2');
|
||||
$o->origin = sprintf('%s (%s)',Setup::PRODUCT_NAME,$x->ftn4d);
|
||||
|
||||
// Message
|
||||
$msg = new Page;
|
||||
|
Reference in New Issue
Block a user