<?php namespace App\Notifications\Netmails; use Carbon\Carbon; use Illuminate\Support\Facades\Log; use App\Notifications\Netmails; use App\Models\{Echomail,Netmail}; use App\Traits\{MessagePath,PageTemplate}; class EchoareaNoWrite extends Netmails { use MessagePath,PageTemplate; private const LOGKEY = 'NNW'; private Echomail $mo; /** * Send a sysop a message if they attempt to write to an area that they dont have permission. * * @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 ECHOAREA NO WRITE netmail to [%s]',self::LOGKEY,$ao->ftn)); $o->subject = sprintf('Echomail #%s rejected to %s',$this->mo->msgid,$this->mo->echoarea->name); // Message $msg = $this->page(FALSE,'nowrite'); $msg->addText($this->sourceSummary($this->mo)."\r\r"); $msg->addText(sprintf("It appears that you do not have permission to post in [%s] using the address [%s], so the message from your system was rejected.\r\r",$this->mo->echoarea->name,$ao->ftn)); $msg->addText("Please contact the ZC if you think this is a mistake.\r\r"); $msg->addText($this->message_path($this->mo)); $o->msg = $msg->render(); $o->set_tagline = 'See something wrong? Do something right.'; $o->save(); return $o; } }