Automatically mark idle nodes HOLD/DOWN/DE-LIST. Automatically validate presented addresses.
This commit is contained in:
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.');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user