2024-05-25 12:25:57 +00:00
< ? php
namespace App\Notifications\Netmails ;
use Carbon\Carbon ;
use Illuminate\Bus\Queueable ;
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 ;
2024-05-26 10:53:59 +00:00
private const LOGKEY = 'NNM' ;
2024-05-25 12:25:57 +00:00
/**
* 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 ();
$ao = $notifiable -> routeNotificationFor ( static :: via );
2024-05-26 10:53:59 +00:00
Log :: info ( sprintf ( '%s:+ Sending a NODE MARKED DOWN NETMAIL for address [%s]' , self :: LOGKEY , $ao -> ftn ));
2024-05-25 12:25:57 +00:00
2024-09-15 12:00:40 +00:00
$o = $this -> setupNetmail ( $notifiable );
2024-05-25 12:25:57 +00:00
$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 ))
2024-09-15 12:00:40 +00:00
-> 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_seen ? -> format ( 'Y-m-d' ) ? : 'Not seen' , $this -> ao -> system -> last_seen ? -> diffInDays ( $now )))
2024-05-25 12:25:57 +00:00
-> addText ( " \r " )
-> addText ( " You have (waiting for collection): \r " )
2024-10-09 04:41:08 +00:00
-> addText ( sprintf ( '* %s Netmails' , number_format ( $this -> ao -> netmailWaiting () -> count ())))
-> addText ( sprintf ( '* %s Echomails' , number_format ( $this -> ao -> echomailWaiting () -> count ())))
-> addText ( sprintf ( '* %s Files' , number_format ( $this -> ao -> filesWaiting () -> count ())))
2024-05-25 12:25:57 +00:00
-> 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 ();
2024-06-03 09:08:40 +00:00
$o -> set_tagline = 'Pending de-list' ;
2024-05-25 12:25:57 +00:00
$o -> save ();
return $o ;
}
}