Multiple enhancements to interactive messages, moved messages to Notifications, send netmail back when invalid packet password
This commit is contained in:
73
app/Notifications/Netmails/Ping.php
Normal file
73
app/Notifications/Netmails/Ping.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?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;
|
||||
use App\Models\{Netmail,System};
|
||||
use App\Traits\{MessagePath,PageTemplate};
|
||||
|
||||
class Ping extends Netmails
|
||||
{
|
||||
use MessagePath,PageTemplate;
|
||||
|
||||
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 Netmail
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function toNetmail(System $so,object $notifiable): Netmail
|
||||
{
|
||||
$o = $this->setupNetmail($so,$notifiable);
|
||||
$ao = $notifiable->routeNotificationFor(static::via);
|
||||
|
||||
Log::info(sprintf('%s:+ Creating test netmail to [%s]',self::LOGKEY,$ao->ftn));
|
||||
|
||||
$o->to = $this->mo->user_from;
|
||||
$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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user