clrghouz/app/Notifications/Netmails/UnexpectedPacketFromYou.php
Deon George 67dad76bd1
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 31s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m30s
Create Docker Image / Final Docker Image Manifest (push) Successful in 9s
Process netmails from unlisted systems
2024-11-20 16:01:11 +09:30

59 lines
1.4 KiB
PHP

<?php
namespace App\Notifications\Netmails;
use Illuminate\Support\Facades\Log;
use App\Notifications\Netmails;
use App\Models\{Echomail,Netmail};
use App\Traits\{MessagePath,PageTemplate};
class UnexpectedPacketFromYou extends Netmails
{
use MessagePath,PageTemplate;
private const LOGKEY = 'NUP';
private string $filename;
/**
* Send a sysop a message if they send us echomail and they are not defined with us.
*
* @param Echomail $mo
*/
public function __construct(string $filename)
{
parent::__construct();
$this->filename = $filename;
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return Netmail
* @throws \Exception
*/
public function toNetmail(object $notifiable): Netmail
{
$o = $this->setupNetmail($notifiable);
$ao = $notifiable->routeNotificationFor(static::via);
Log::info(sprintf('%s:+ Creating NETMAIL UNEXPECTED PACKET netmail to [%s]',self::LOGKEY,$ao->ftn));
$o->subject = sprintf('Unexpected packet from you [%s]',$this->filename);
// Message
$msg = $this->page(FALSE,'unexpected');
$msg->addText("We received a packet from you with echomail, but your node is not defined here. Those echomail messages were ignored. If you think this is a mistake, please let me know.\r\r");
$o->msg = $msg->render();
$o->set_tagline = 'The unexpected moment is always sweeter';
$o->save();
return $o;
}
}