clrghouz/app/Notifications/Netmails/NetmailForward.php
Deon George 8fb3a21fcd
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 39s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m51s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
Normalise tagline/tearline/origin
2024-06-03 19:09:09 +10:00

70 lines
1.7 KiB
PHP

<?php
namespace App\Notifications\Netmails;
use Illuminate\Support\Facades\Log;
use App\Notifications\Netmails;
use App\Models\{Address,Netmail};
use App\Traits\{MessagePath,PageTemplate};
class NetmailForward extends Netmails
{
use MessagePath,PageTemplate;
private const LOGKEY = 'NNP';
private Address $ao;
private Netmail $mo;
/**
* Reply to a netmail ping request.
*
* @param Netmail $mo
* @param Address $ao
*/
public function __construct(Netmail $mo,Address $ao)
{
parent::__construct();
$this->mo = $mo;
$this->ao = $ao;
}
/**
* 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:+ Advising [%s@%s] that netmail to [%s] will be forwarded to [%s].',self::LOGKEY,$this->mo->from,$ao->ftn,$this->mo->to,$this->ao->ftn));
$o->to = $this->mo->from;
$o->replyid = $this->mo->msgid;
$o->subject = sprintf('Your netmail is being forwarded to %s',$this->ao->ftn3d);
// Message
$msg = $this->page(FALSE,'Forward');
$msg->addText("Howdy, Clrghouz is not a BBS, so users cannot login to collect netmail.\r\r\r");
$msg->addText(sprintf("Never fear, your msg [%s] to [%s] has been forwarded, to [%s].\r\r",
$this->mo->msgid,
$this->mo->to,
$this->ao->ftn3d,
));
$msg->addText(sprintf("To avoid receiving this netmail, send messages to [%s] to [%s].\r\r",$this->mo->to,$this->ao->ftn3d));
$o->msg = $msg->render();
$o->set_tagline = 'Thank you so much for your mail. I love it already.';
$o->save();
return $o;
}
}