65 lines
2.2 KiB
PHP
65 lines
2.2 KiB
PHP
|
<?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;
|
||
|
}
|
||
|
}
|