Automatically mark idle nodes HOLD/DOWN/DE-LIST. Automatically validate presented addresses.
This commit is contained in:
@@ -46,24 +46,19 @@ abstract class Echomails extends Notification //implements ShouldQueue
|
||||
*/
|
||||
abstract public function toEchomail(object $notifiable): Echomail;
|
||||
|
||||
protected function setupEchomail(Echomail $mo,object $notifiable): Echomail
|
||||
protected function setupEchomail(Echoarea $eo): Echomail
|
||||
{
|
||||
$echoarea = $notifiable->routeNotificationFor(static::via);
|
||||
|
||||
$o = new Echomail;
|
||||
$o->from = Setup::PRODUCT_NAME;
|
||||
$o->replyid = $mo->msgid;
|
||||
$o->echoarea_id = $echoarea->id;
|
||||
|
||||
$o->echoarea_id = $eo->id;
|
||||
|
||||
$o->datetime = Carbon::now();
|
||||
$o->tzoffset = $o->datetime->utcOffset();
|
||||
|
||||
$o->fftn_id = ($x=our_address($mo->fftn))->id;
|
||||
$o->flags = (Message::FLAG_LOCAL);
|
||||
|
||||
$o->tearline = sprintf('%s (%04X)',Setup::PRODUCT_NAME,Setup::PRODUCT_ID);
|
||||
$o->origin = sprintf('%s (%s)',Setup::PRODUCT_NAME,$x->ftn4d);
|
||||
$o->kludges->put('CHRS:',$mo->kludges->get('chrs') ?: 'CP437 2');
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
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;
|
||||
|
49
app/Notifications/Emails/NodeDelisted.php
Normal file
49
app/Notifications/Emails/NodeDelisted.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications\Emails;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
use App\Models\Address;
|
||||
|
||||
class NodeDelisted extends Notification //implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct(private Address $ao)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*/
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
$now = Carbon::now();
|
||||
|
||||
return (new MailMessage)
|
||||
->cc(our_address($this->ao)->system->users->first()->email)
|
||||
->subject(sprintf('Your system has been DE-LISTED on %s from %s',$now->format('Y-m-d'),$x=$this->ao->zone->domain->name))
|
||||
->line(sprintf('Your system has been DE-LISTED, because it hasnt polled **%s** since **%s** (%d days).',$x,$this->ao->system->last_session->format('Y-m-d'),$this->ao->system->last_session->diffInDays($now)))
|
||||
->line('')
|
||||
->line('If you think this was a mistake, please let me know.')
|
||||
->line(sprintf('If you think about returning to %s, then reach out and we can get you back online pretty quickly.',$x));
|
||||
}
|
||||
}
|
54
app/Notifications/Emails/NodeMarkedDown.php
Normal file
54
app/Notifications/Emails/NodeMarkedDown.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications\Emails;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
use App\Models\Address;
|
||||
|
||||
class NodeMarkedDown extends Notification //implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct(private Address $ao)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*/
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
$now = Carbon::now();
|
||||
|
||||
return (new MailMessage)
|
||||
->cc(our_address($this->ao)->system->users->first()->email)
|
||||
->subject(sprintf('ACTION REQUIRED: Your system will be delisted on %s',$now->format('Y-m-d')))
|
||||
->line(sprintf('Your system has been marked **DOWN**, because it hasnt polled **%s** since **%s** (%d days).',$this->ao->zone->domain->name,$this->ao->system->last_session->format('Y-m-d'),$this->ao->system->last_session->diffInDays($now)))
|
||||
->line('')
|
||||
->line('You have (waiting for collection):')
|
||||
->lineIf($this->ao->uncollected_netmail,sprintf('* %s Netmails',number_format($this->ao->uncollected_netmail)))
|
||||
->lineIf($this->ao->uncollected_echomail,sprintf('* %s Echomails',number_format($this->ao->uncollected_echomail)))
|
||||
->lineIf($this->ao->uncollected_files,sprintf('* %s Files',number_format($this->ao->uncollected_files)))
|
||||
->line('')
|
||||
->line(sprintf('Your system will automatically be **DE-LISTED** if your system hasnt polled to collected your mail/file(s) by **%s**',$now->addDays(7)->format('Y-m-d')))
|
||||
->line('If you think you\'ve received this email by mistake or need help, please let me know.');
|
||||
}
|
||||
}
|
54
app/Notifications/Emails/NodeMarkedHold.php
Normal file
54
app/Notifications/Emails/NodeMarkedHold.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications\Emails;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
use App\Models\Address;
|
||||
|
||||
class NodeMarkedHold extends Notification //implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct(private Address $ao)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*/
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
$now = Carbon::now();
|
||||
|
||||
return (new MailMessage)
|
||||
->cc(our_address($this->ao)->system->users->first()->email)
|
||||
->subject('Your system has been marked HOLD')
|
||||
->line(sprintf('Your system has been marked **HOLD**, because it hasnt polled **%s** since **%s** (%d days).',$this->ao->zone->domain->name,$this->ao->system->last_session->format('Y-m-d'),$this->ao->system->last_session->diffInDays($now)))
|
||||
->line('')
|
||||
->line('You have (waiting for collection):')
|
||||
->lineIf($this->ao->uncollected_netmail,sprintf('* %s Netmails',number_format($this->ao->uncollected_netmail)))
|
||||
->lineIf($this->ao->uncollected_echomail,sprintf('* %s Echomails',number_format($this->ao->uncollected_echomail)))
|
||||
->lineIf($this->ao->uncollected_files,sprintf('* %s Files',number_format($this->ao->uncollected_files)))
|
||||
->line('')
|
||||
->line(sprintf('To clear this status, all you need to do make sure your system polls and collects mail by **%s**',$this->ao->system->last_session->addDays(config('fido.idle.down'))->format('Y-m-d')))
|
||||
->line('If you think you\'ve received this email by mistake or need help, please let me know.');
|
||||
}
|
||||
}
|
@@ -31,6 +31,7 @@ abstract class Netmails extends Notification //implements ShouldQueue
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
* @todo change to object $notifiable
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
|
60
app/Notifications/Netmails/NodeDelisted.php
Normal file
60
app/Notifications/Netmails/NodeDelisted.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications\Netmails;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\FTN\Message;
|
||||
use App\Notifications\Netmails;
|
||||
use App\Models\{Address,Netmail};
|
||||
use App\Traits\PageTemplate;
|
||||
|
||||
class NodeDelisted extends Netmails //implements ShouldQueue
|
||||
{
|
||||
use Queueable,PageTemplate;
|
||||
|
||||
private const LOGKEY = 'NMD';
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct(private Address $ao)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*/
|
||||
public function toNetmail(object $notifiable): Netmail
|
||||
{
|
||||
$now = Carbon::now();
|
||||
|
||||
$o = $this->setupNetmail($notifiable);
|
||||
$ao = $notifiable->routeNotificationFor(static::via);
|
||||
|
||||
Log::info(sprintf('%s:+ Sending a NODE MARKED HOLD for address [%s]',self::LOGKEY,$ao->ftn));
|
||||
|
||||
$o->subject = sprintf('Your system has been DE-LISTED from %s',$x=$ao->zone->domain->name);
|
||||
$o->flags = (Message::FLAG_LOCAL|Message::FLAG_PRIVATE|Message::FLAG_CRASH);
|
||||
|
||||
// Message
|
||||
$msg = $this->page(TRUE,'delist');
|
||||
|
||||
$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("\r")
|
||||
->addText("If you think this was a mistake, please let me know.\r")
|
||||
->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->tagline = 'You\'ve been DE-LISTED';
|
||||
|
||||
$o->save();
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
65
app/Notifications/Netmails/NodeMarkedDown.php
Normal file
65
app/Notifications/Netmails/NodeMarkedDown.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications\Netmails;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\FTN\Message;
|
||||
use App\Notifications\Netmails;
|
||||
use App\Models\{Address,Netmail};
|
||||
use App\Traits\PageTemplate;
|
||||
|
||||
class NodeMarkedDown extends Netmails //implements ShouldQueue
|
||||
{
|
||||
use Queueable,PageTemplate;
|
||||
|
||||
private const LOGKEY = 'NMD';
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct(private Address $ao)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*/
|
||||
public function toNetmail(object $notifiable): Netmail
|
||||
{
|
||||
$now = Carbon::now();
|
||||
|
||||
$o = $this->setupNetmail($notifiable);
|
||||
$ao = $notifiable->routeNotificationFor(static::via);
|
||||
|
||||
Log::info(sprintf('%s:+ Sending a NODE MARKED DOWN for address [%s]',self::LOGKEY,$ao->ftn));
|
||||
|
||||
$o->subject = sprintf('ACTION REQUIRED: Your system will be delisted on %s',$now->format('Y-m-d'));
|
||||
$o->flags = (Message::FLAG_LOCAL|Message::FLAG_PRIVATE|Message::FLAG_CRASH);
|
||||
|
||||
// Message
|
||||
$msg = $this->page(TRUE,'down');
|
||||
|
||||
$msg->addText(sprintf("Hi %s,\r\r",$this->ao->system->sysop))
|
||||
->addText(sprintf("Your system has been marked **DOWN**, 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("You have (waiting for collection):\r")
|
||||
->addText(sprintf("* %s Netmails\r",number_format($this->ao->uncollected_netmail)))
|
||||
->addText(sprintf("* %s Echomails\r",number_format($this->ao->uncollected_echomail)))
|
||||
->addText(sprintf("* %s Files\r",number_format($this->ao->uncollected_files)))
|
||||
->addText("\r")
|
||||
->addText(sprintf("Your system will automatically be **DE-LISTED** if your system hasnt polled to collected your mail/file(s) by **%s**\r\r",$now->addDays(7)->format('Y-m-d')))
|
||||
->addText("If you think you've received this netmail by mistake or need help, please let me know.\r");
|
||||
|
||||
$o->msg = $msg->render();
|
||||
$o->tagline = 'Pending de-list';
|
||||
|
||||
$o->save();
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
65
app/Notifications/Netmails/NodeMarkedHold.php
Normal file
65
app/Notifications/Netmails/NodeMarkedHold.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications\Netmails;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\FTN\Message;
|
||||
use App\Notifications\Netmails;
|
||||
use App\Models\{Address,Netmail};
|
||||
use App\Traits\PageTemplate;
|
||||
|
||||
class NodeMarkedHold extends Netmails //implements ShouldQueue
|
||||
{
|
||||
use Queueable,PageTemplate;
|
||||
|
||||
private const LOGKEY = 'NMD';
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct(private Address $ao)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*/
|
||||
public function toNetmail(object $notifiable): Netmail
|
||||
{
|
||||
$now = Carbon::now();
|
||||
|
||||
$o = $this->setupNetmail($notifiable);
|
||||
$ao = $notifiable->routeNotificationFor(static::via);
|
||||
|
||||
Log::info(sprintf('%s:+ Sending a NODE MARKED HOLD for address [%s]',self::LOGKEY,$ao->ftn));
|
||||
|
||||
$o->subject = 'Your system has been marked HOLD';
|
||||
$o->flags = (Message::FLAG_LOCAL|Message::FLAG_PRIVATE|Message::FLAG_CRASH);
|
||||
|
||||
// Message
|
||||
$msg = $this->page(TRUE,'hold');
|
||||
|
||||
$msg->addText(sprintf("Hi %s,\r\r",$this->ao->system->sysop))
|
||||
->addText(sprintf("Your system has been marked **HOLD**, 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("You have (waiting for collection):\r")
|
||||
->addText(sprintf("* %s Netmails\r",number_format($this->ao->uncollected_netmail)))
|
||||
->addText(sprintf("* %s Echomails\r",number_format($this->ao->uncollected_echomail)))
|
||||
->addText(sprintf("* %s Files\r",number_format($this->ao->uncollected_files)))
|
||||
->addText("\r")
|
||||
->addText(sprintf("To clear this status, all you need to do make sure your system polls and collects mail by **%s**\r\r",$this->ao->system->last_session->addDays(config('fido.idle.down'))->format('Y-m-d')))
|
||||
->addText("If you think you've received this netmail by mistake or need help, please let me know.\r");
|
||||
|
||||
$o->msg = $msg->render();
|
||||
$o->tagline = 'You\'ve been marked HOLD';
|
||||
|
||||
$o->save();
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user