2024-05-25 12:25:57 +00:00
< ? 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 ;
2024-05-26 10:53:59 +00:00
use Illuminate\Support\Facades\Log ;
2024-05-25 12:25:57 +00:00
use App\Models\Address ;
class NodeMarkedHold extends Notification //implements ShouldQueue
{
use Queueable ;
2024-05-26 10:53:59 +00:00
private const LOGKEY = 'NEH' ;
2024-05-25 12:25:57 +00:00
/**
* 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
{
2024-05-26 10:53:59 +00:00
Log :: info ( sprintf ( '%s:+ Sending a NODE MARKED HOLD EMAIL for address [%s]' , self :: LOGKEY , $this -> ao -> ftn ));
2024-05-25 12:25:57 +00:00
$now = Carbon :: now ();
return ( new MailMessage )
-> cc ( our_address ( $this -> ao ) -> system -> users -> first () -> email )
-> subject ( 'Your system has been marked HOLD' )
2024-06-30 01:25:04 +00:00
-> line ( sprintf ( 'Your system has been marked **HOLD**, because it hasnt polled **%s** with address %s since **%s** (%d days).' ,
$this -> ao -> zone -> domain -> name ,
$this -> ao -> ftn4d ,
2024-09-15 12:00:40 +00:00
$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
-> line ( '' )
-> line ( 'You have (waiting for collection):' )
2024-10-09 04:41:08 +00:00
-> line ( sprintf ( '* %s Netmails' , number_format ( $this -> ao -> netmailWaiting () -> count ())))
-> line ( sprintf ( '* %s Echomails' , number_format ( $this -> ao -> echomailWaiting () -> count ())))
-> line ( sprintf ( '* %s Files' , number_format ( $this -> ao -> filesWaiting () -> count ())))
2024-05-25 12:25:57 +00:00
-> line ( '' )
2024-09-15 12:00:40 +00:00
-> 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_seen ? : Carbon :: now ()) -> addDays ( config ( 'fido.idle.down' )) -> format ( 'Y-m-d' )))
2024-05-25 12:25:57 +00:00
-> line ( 'If you think you\'ve received this email by mistake or need help, please let me know.' );
}
}