Multiple enhancements to interactive messages, moved messages to Notifications, send netmail back when invalid packet password

This commit is contained in:
2023-07-23 17:27:52 +10:00
parent 9f0fa0a8ec
commit 17fe7e910d
28 changed files with 837 additions and 475 deletions

View File

@@ -0,0 +1,69 @@
<?php
namespace App\Notifications\Netmails;
use Illuminate\Support\Facades\Log;
use App\Classes\FTN\Message;
use App\Notifications\Netmails;
use App\Models\{Netmail,System,User};
use App\Traits\PageTemplate;
class AddressLink extends Netmails
{
use PageTemplate;
private const LOGKEY = 'NAL';
private User $uo;
/**
* Create a netmail to enable a sysop to activate an address.
*
* @param User $uo
*/
public function __construct(User $uo)
{
parent::__construct();
$this->uo = $uo;
}
/**
* 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:+ Sending a link code for address [%s]',self::LOGKEY,$ao->ftn));
$o->subject = 'Address Link Code';
$o->flags = (Message::FLAG_LOCAL|Message::FLAG_PRIVATE|Message::FLAG_CRASH);
// Message
$msg = $this->page(TRUE,'#link');
$msg->addText(sprintf(
"Hi %s,\r\r".
"This message is to link your address [%s] to your user ID in the Clearing Houz web site.\r\r".
"If you didnt start this process, then you can safely ignore this netmail. But if you wanted to link this address, please head over to [%s] and paste in the following:\r\r%s\r",
$ao->system->sysop,
$ao->ftn3d,
url('/link'),
$ao->set_activation($this->uo)
));
$o->msg = $msg->render();
$o->tagline = 'Address Linking...';
$o->save();
return $o;
}
}

View File

@@ -0,0 +1,80 @@
<?php
namespace App\Notifications\Netmails;
use Illuminate\Support\Facades\Log;
use App\Notifications\Netmails;
use App\Classes\FTN\Message;
use App\Models\{Netmail,System};
use App\Traits\PageTemplate;
class PacketPasswordInvalid extends Netmails
{
use PageTemplate;
private const LOGKEY = 'NPP';
private string $packet;
private string $invalidpass;
/**
* Create a new notification instance.
*/
public function __construct(string $invalidpass,string $packet)
{
parent::__construct();
$this->invalidpass = $invalidpass;
$this->packet = $packet;
}
/**
* Get the mail representation of the notification.
*/
public function toNetmail(System $so,object $notifiable): Netmail
{
$o = $this->setupNetmail($so,$notifiable);
$ao = $notifiable->routeNotificationFor(static::via);
Log::info(sprintf('%s:+ Creating netmail to [%s] - system using invalid packet password',self::LOGKEY,$ao->ftn));
$o->subject = $this->invalidpass.':Incorrect Packet Password';
$o->flags = (Message::FLAG_LOCAL|Message::FLAG_PRIVATE|Message::FLAG_PKTPASSWD|Message::FLAG_CRASH);
// Message
$msg = $this->page(TRUE,'badpass');
if ($this->invalidpass)
$msg->addText(
sprintf("Hi there,\r\r".
"You sent me a mail packet (%s) with the incorrect password \"%s\". It wasnt processed.\r\r"
,$this->packet,$this->invalidpass));
else
$msg->addText(
sprintf("Hi there,\r\r".
"You sent me a mail packet (%s) with no password? It wasnt processed.\r\r"
,$this->packet));
$msg->addText("Head over to the website if you dont know what your packet password should be :)\r");
$o->msg = $msg->render();
$o->tagline = 'Safety first, password second.';
$o->save();
return $o;
}
/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
//
];
}
}

View 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;
}
}

View File

@@ -0,0 +1,75 @@
<?php
namespace App\Notifications\Netmails;
use Carbon\Carbon;
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 Reject 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 reject netmail to [%s]',self::LOGKEY,$ao->ftn));
$o->to = $this->mo->user_from;
$o->replyid = $this->mo->msgid;
$o->subject = 'Message Undeliverable - '.$this->mo->msgid;
// Message
$msg = $this->page(FALSE,'Reject');
$msg->addText(
sprintf("Your netmail with ID [%s] to [%s] here was received here on [%s] and it looks like you sent it on [%s].\r\r",
$this->mo->msgid,
$this->mo->user_to,
Carbon::now()->utc()->toDateTimeString(),
$this->mo->date->utc()->toDateTimeString(),
)
);
$msg->addText("This hub is not attended, so no user will be able to read your message (the hub is unattended). You may like to try and contact them another way.\r\r");
$msg->addText($this->message_path($this->mo));
$o->msg = $msg->render();
$o->tagline = 'Do you think it was fate which brought us together? Nah, bad luck :(';
$o->save();
return $o;
}
}

View File

@@ -0,0 +1,50 @@
<?php
namespace App\Notifications\Netmails;
use Illuminate\Support\Facades\Log;
use App\Notifications\Netmails;
use App\Models\{Netmail,System};
use App\Traits\PageTemplate;
class Test extends Netmails
{
use PageTemplate;
private const LOGKEY = 'NNT';
/**
* 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->subject = 'Testing 1, 2, 3...';
// Message
$msg = $this->page(TRUE,'Test');
$msg->addText(
"Hi there,\r\r".
"This is just a test netmail to make sure we can send a message to your system.\r\r".
"There is no need to reply, but if you do, it'll boost my spirits :)\r"
);
$o->msg = $msg->render();
$o->tagline = 'Testing, testing, 1 2 3.';
$o->save();
return $o;
}
}