clrghouz/app/Notifications/Echomails/Test.php

80 lines
1.8 KiB
PHP
Raw Normal View History

<?php
namespace App\Notifications\Echomails;
use Carbon\Carbon;
use Carbon\CarbonInterface;
use Illuminate\Support\Facades\Log;
use App\Classes\{Fonts\Thick,Fonts\Thin,FTN\Message,Page};
use App\Models\{Echomail,System};
use App\Notifications\Echomails;
use App\Traits\MessagePath;
class Test extends Echomails
{
use MessagePath;
private const LOGKEY = 'NNP';
private Message $mo;
/**
* Reply to a netmail ping request.
*
* @param Message $mo
*/
public function __construct(Message $mo)
{
parent::__construct();
$this->mo = $mo;
}
/**
* Get the mail representation of the notification.
*
* @param System $so
* @param mixed $notifiable
* @return Echomail
* @throws \Exception
*/
public function toEchomail(System $so,object $notifiable): Echomail
{
$o = $this->setupEchomail($this->mo,$so,$notifiable);
$echoarea = $notifiable->routeNotificationFor(static::via);
Log::info(sprintf('%s:+ Creating test echomail to [%s]',self::LOGKEY,$echoarea));
$o->to = $this->mo->user_from;
$o->subject = 'Test Reply';
// Message
$msg = new Page;
$header = new Thick;
$header->addText('Clearing Houz');
$msg->addHeader($header,'FTN Mailer and Tosser',TRUE,0xc4);
$lbc = new Thin;
$lbc->addText('Test');
$msg->addLeftBoxContent($lbc,TRUE);
$msg->addText(
sprintf("Your test was received here on %s and it looks like you sent it on %s. If that is correct, then it took %s to get here.\r\r",
Carbon::now()->utc()->toDateTimeString(),
$this->mo->date->utc()->toDateTimeString(),
$this->mo->date->diffForHumans(['parts'=>3,'syntax'=>CarbonInterface::DIFF_ABSOLUTE])
)
);
$msg->addText($this->message_path($this->mo));
$o->msg = $msg->render();
$o->tagline = 'I ate a clock yesterday, it was very time-consuming.';
$o->save();
return $o;
}
}