clrghouz/app/Notifications/Netmails/PacketPasswordInvalid.php

83 lines
1.9 KiB
PHP

<?php
namespace App\Notifications\Netmails;
use Illuminate\Support\Facades\Log;
use App\Notifications\Netmails;
use App\Classes\FTN\Message;
use App\Models\Netmail;
use App\Traits\PageTemplate;
class PacketPasswordInvalid extends Netmails
{
use PageTemplate;
private const LOGKEY = 'NPP';
private string $packet;
private string $invalidpass;
/**
* Create a new notification instance.
*/
public function __construct(string $invalidpass,string $packet)
{
parent::__construct();
$this->invalidpass = $invalidpass;
$this->packet = $packet;
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @throws \Exception
*/
public function toNetmail(object $notifiable): Netmail
{
$o = $this->setupNetmail($notifiable);
$ao = $notifiable->routeNotificationFor(static::via);
Log::info(sprintf('%s:+ Creating netmail to [%s] - system using invalid packet password',self::LOGKEY,$ao->ftn));
$o->subject = $this->invalidpass.':Incorrect Packet Password';
$o->flags = (Message::FLAG_LOCAL|Message::FLAG_PRIVATE|Message::FLAG_PKTPASSWD|Message::FLAG_CRASH);
// Message
$msg = $this->page(FALSE,'badpass');
if ($this->invalidpass)
$msg->addText(
sprintf("Hi there,\r\r".
"You sent me a mail packet (%s) with the incorrect password \"%s\". It wasnt processed.\r\r"
,$this->packet,$this->invalidpass));
else
$msg->addText(
sprintf("Hi there,\r\r".
"You sent me a mail packet (%s) with no password? It wasnt processed.\r\r"
,$this->packet));
$msg->addText("Head over to the website if you dont know what your packet password should be :)\r");
$o->msg = $msg->render();
$o->set_tagline = 'Safety first, password second.';
$o->save();
return $o;
}
/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
//
];
}
}