clrghouz/app/Notifications/Netmails/EchomailBadAddress.php
Deon George 1bedad17a4
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 37s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m56s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
Fix packet processing issue - we now find recent deleted address when creatingFTN, fix netmail processing with points, fix processing badly address netmails
2024-07-11 23:33:17 +10:00

65 lines
1.6 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 EchomailBadAddress extends Netmails
{
use MessagePath,PageTemplate;
private const LOGKEY = 'NBA';
private Echomail $mo;
/**
* Send a sysop a message if they give us a message with a bad address in it.
*
* @param Echomail $mo
*/
public function __construct(Echomail $mo)
{
parent::__construct();
$this->mo = $mo;
}
/**
* 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 ECHOMAIL BAD ADDRESS netmail to [%s]',self::LOGKEY,$ao->ftn));
$o->subject = sprintf('Bad address in echomail [%s]',$this->mo->msgid);
// Message
$msg = $this->page(FALSE,'badmsg');
$msg->addText($this->sourceSummary($this->mo)."\r\r");
$msg->addText(sprintf("The address in this echomail [%s] is the wrong address for the domain [%s].\r\r",$this->mo->fftn,$ao->zone->domain->name));
$msg->addText("This echomail has been rejected and not stored here - so no downstream nodes will receive it. If you think this is a mistake, please let me know.\r\r");
$msg->addText($this->message_path($this->mo));
$o->msg = $msg->render();
$o->set_tagline = 'I enjoyed reading your message, even though nobody else will get it :)';
$o->save();
return $o;
}
}