2023-07-23 07:27:52 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Notifications\Netmails;
|
|
|
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
use Carbon\CarbonInterface;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
use App\Classes\FTN\Message;
|
|
|
|
use App\Notifications\Netmails;
|
2024-05-19 13:28:45 +00:00
|
|
|
use App\Models\Netmail;
|
2023-07-23 07:27:52 +00:00
|
|
|
use App\Traits\{MessagePath,PageTemplate};
|
|
|
|
|
|
|
|
class Ping extends Netmails
|
|
|
|
{
|
|
|
|
use MessagePath,PageTemplate;
|
|
|
|
|
|
|
|
private const LOGKEY = 'NNP';
|
|
|
|
|
2024-05-19 13:28:45 +00:00
|
|
|
private Netmail $mo;
|
2023-07-23 07:27:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reply to a netmail ping request.
|
|
|
|
*
|
|
|
|
* @param Message $mo
|
|
|
|
*/
|
2024-05-19 13:28:45 +00:00
|
|
|
public function __construct(Netmail $mo)
|
2023-07-23 07:27:52 +00:00
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$this->mo = $mo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the mail representation of the notification.
|
|
|
|
*
|
|
|
|
* @param mixed $notifiable
|
|
|
|
* @return Netmail
|
|
|
|
* @throws \Exception
|
|
|
|
*/
|
2023-12-18 04:13:16 +00:00
|
|
|
public function toNetmail(object $notifiable): Netmail
|
2023-07-23 07:27:52 +00:00
|
|
|
{
|
2023-12-18 04:13:16 +00:00
|
|
|
$o = $this->setupNetmail($notifiable);
|
2023-07-23 07:27:52 +00:00
|
|
|
$ao = $notifiable->routeNotificationFor(static::via);
|
|
|
|
|
2023-12-10 21:48:30 +00:00
|
|
|
Log::info(sprintf('%s:+ Creating PING netmail to [%s]',self::LOGKEY,$ao->ftn));
|
2023-07-23 07:27:52 +00:00
|
|
|
|
2024-05-19 13:28:45 +00:00
|
|
|
$o->to = $this->mo->from;
|
2023-07-23 07:27:52 +00:00
|
|
|
$o->replyid = $this->mo->msgid;
|
|
|
|
$o->subject = 'Ping Reply';
|
|
|
|
|
|
|
|
// Message
|
|
|
|
$msg = $this->page(FALSE,'Ping');
|
|
|
|
|
|
|
|
$msg->addText(
|
|
|
|
sprintf("Your ping 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 = 'My ping pong opponent was not happy with my serve. He kept returning it.';
|
|
|
|
|
|
|
|
$o->save();
|
|
|
|
|
|
|
|
return $o;
|
|
|
|
}
|
|
|
|
}
|