Multiple enhancements to interactive messages, moved messages to Notifications, send netmail back when invalid packet password
This commit is contained in:
@@ -1,104 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\{ANSI,Fonts\Thin,Page};
|
||||
use App\Classes\Fonts\Thick;
|
||||
use App\Classes\FTN\Message;
|
||||
use App\Models\{Address,Netmail,Setup,User};
|
||||
|
||||
class AddressLink extends Notification //implements ShouldQueue
|
||||
{
|
||||
private const LOGKEY = 'NAL';
|
||||
|
||||
use Queueable;
|
||||
|
||||
private Address $ao;
|
||||
private User $uo;
|
||||
|
||||
/**
|
||||
* Create a netmail to enable a sysop to activate an address.
|
||||
*
|
||||
* @param Address $ao
|
||||
* @param User $uo
|
||||
*/
|
||||
public function __construct(Address $ao,User $uo)
|
||||
{
|
||||
$this->queue = 'netmail';
|
||||
$this->ao = $ao;
|
||||
$this->uo = $uo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['netmail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return Netmail
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function toNetmail($notifiable): Netmail
|
||||
{
|
||||
Log::info(sprintf('%s:Sending a link code for address [%s]',self::LOGKEY,$this->ao->ftn));
|
||||
|
||||
$so = Setup::findOrFail(config('app.id'))->system;
|
||||
|
||||
$o = new Netmail;
|
||||
$o->to = $this->ao->system->sysop;
|
||||
$o->from = Setup::PRODUCT_NAME;
|
||||
$o->subject = 'Address Link Code';
|
||||
$o->datetime = Carbon::now();
|
||||
$o->tzoffset = $o->datetime->utcOffset();
|
||||
|
||||
$o->fftn_id = $so->match($this->ao->zone)->first()->id;
|
||||
$o->tftn_id = $this->ao->id;
|
||||
$o->flags = Message::FLAG_LOCAL|Message::FLAG_PRIVATE|Message::FLAG_CRASH;
|
||||
$o->cost = 0;
|
||||
|
||||
$o->tagline = 'Address Linking...';
|
||||
$o->tearline = sprintf('%s (%04X)',Setup::PRODUCT_NAME,Setup::PRODUCT_ID);
|
||||
|
||||
// Message
|
||||
$msg = new Page;
|
||||
$msg->addLogo(new ANSI(base_path('public/logo/netmail.bin')));
|
||||
|
||||
$header = new Thick;
|
||||
$header->addText(ANSI::ansi_code([1,37]).'Clearing Houz');
|
||||
$msg->addHeader($header,'FTN Mailer and Tosser',TRUE,0xc4);
|
||||
|
||||
$lbc = new Thin;
|
||||
$lbc->addText('#link');
|
||||
$msg->addLeftBoxContent($lbc);
|
||||
|
||||
$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",
|
||||
$this->ao->system->sysop,
|
||||
$this->ao->ftn3d,
|
||||
url('/link'),
|
||||
$this->ao->set_activation($this->uo)
|
||||
));
|
||||
|
||||
$o->msg = $msg->render();
|
||||
$o->save();
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
47
app/Notifications/Channels/EchomailChannel.php
Normal file
47
app/Notifications/Channels/EchomailChannel.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications\Channels;
|
||||
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Models\Echomail;
|
||||
use App\Models\Setup;
|
||||
|
||||
class EchomailChannel
|
||||
{
|
||||
private const LOGKEY = 'CN-';
|
||||
|
||||
/**
|
||||
* @var Echomail
|
||||
*/
|
||||
protected Echomail $echomail;
|
||||
|
||||
/**
|
||||
* Create a new Netmail channel instance.
|
||||
*
|
||||
* @param Echomail $o
|
||||
*/
|
||||
public function __construct(Echomail $o)
|
||||
{
|
||||
$this->echomail = $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @param \Illuminate\Notifications\Notification $notification
|
||||
* @return \Psr\Http\Message\ResponseInterface|void
|
||||
*/
|
||||
public function send($notifiable,Notification $notification)
|
||||
{
|
||||
if (! $echoarea = $notifiable->routeNotificationFor('echomail',$notification))
|
||||
return;
|
||||
|
||||
$so = Setup::findOrFail(config('app.id'))->system;
|
||||
$o = $notification->toEchomail($so,$notifiable);
|
||||
|
||||
Log::info(sprintf('%s:= Posted echomail [%s] to [%s]',self::LOGKEY,$o->msgid,$echoarea));
|
||||
}
|
||||
}
|
@@ -5,22 +5,21 @@ namespace App\Notifications\Channels;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Models\Netmail;
|
||||
use App\Jobs\AddressPoll as Job;
|
||||
use App\Models\Netmail;
|
||||
use App\Models\Setup;
|
||||
|
||||
class NetmailChannel
|
||||
{
|
||||
private const LOGKEY = 'CN-';
|
||||
|
||||
/**
|
||||
* The HTTP client instance.
|
||||
*
|
||||
* @var Netmail
|
||||
*/
|
||||
protected Netmail $netmail;
|
||||
|
||||
/**
|
||||
* Create a new Slack channel instance.
|
||||
* Create a new Netmail channel instance.
|
||||
*
|
||||
* @param Netmail $o
|
||||
*/
|
||||
@@ -41,9 +40,10 @@ class NetmailChannel
|
||||
if (! $ao = $notifiable->routeNotificationFor('netmail',$notification))
|
||||
return;
|
||||
|
||||
$o = $notification->toNetmail($notifiable);
|
||||
$so = Setup::findOrFail(config('app.id'))->system;
|
||||
$o = $notification->toNetmail($so,$notifiable);
|
||||
|
||||
Job::dispatch($ao);
|
||||
Log::info(sprintf('%s:Sent netmail [%s] via [%s]',self::LOGKEY,$o->msgid,$ao->ftn));
|
||||
Log::info(sprintf('%s:= Sent netmail [%s] to [%s]',self::LOGKEY,$o->msgid,$ao->ftn));
|
||||
}
|
||||
}
|
73
app/Notifications/Echomails.php
Normal file
73
app/Notifications/Echomails.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
use App\Classes\FTN\Message;
|
||||
use App\Models\{Echoarea, Echomail, Setup, System};
|
||||
|
||||
abstract class Echomails extends Notification //implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
protected const via = 'echomail';
|
||||
|
||||
private const LOGKEY = 'NN-';
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->queue = 'echomail';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return [ self::via ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param System $so
|
||||
* @param mixed $notifiable
|
||||
* @return Echomail
|
||||
* @throws \Exception
|
||||
*/
|
||||
abstract public function toEchomail(System $so,object $notifiable): Echomail;
|
||||
|
||||
protected function setupEchomail(Message $mo,System $so,object $notifiable): Echomail
|
||||
{
|
||||
$echoarea = $notifiable->routeNotificationFor(static::via);
|
||||
$eo = Echoarea::where('name',$echoarea)->singleOrFail();
|
||||
|
||||
$o = new Echomail;
|
||||
$o->init();
|
||||
$o->from = Setup::PRODUCT_NAME;
|
||||
$o->replyid = $mo->msgid;
|
||||
$o->echoarea_id = $eo->id;
|
||||
|
||||
$o->datetime = Carbon::now();
|
||||
$o->tzoffset = $o->datetime->utcOffset();
|
||||
|
||||
$o->fftn_id = ($x=$so->match($mo->fftn_o->zone)->first())->id;
|
||||
$o->flags = (Message::FLAG_LOCAL);
|
||||
|
||||
$o->tearline = sprintf('%s (%04X)',Setup::PRODUCT_NAME,Setup::PRODUCT_ID);
|
||||
$o->origin = sprintf('%s (%s)',Setup::PRODUCT_NAME,$x->ftn4d);
|
||||
$o->kludges = collect(['chrs'=>$mo->kludge->get('chrs') ?: 'CP437 2']);
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
80
app/Notifications/Echomails/Test.php
Normal file
80
app/Notifications/Echomails/Test.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
@@ -1,97 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\{ANSI,Fonts\Thin,Fonts\Thick,Page};
|
||||
use App\Classes\FTN\Message;
|
||||
use App\Models\{Address,Netmail,Setup,User};
|
||||
|
||||
class NetmailTest extends Notification //implements ShouldQueue
|
||||
{
|
||||
private const LOGKEY = 'NNT';
|
||||
|
||||
use Queueable;
|
||||
|
||||
private Address $ao;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @param Address $ao
|
||||
* @param User $uo
|
||||
*/
|
||||
public function __construct(Address $ao)
|
||||
{
|
||||
$this->queue = 'netmail';
|
||||
$this->ao = $ao;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['netmail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return Netmail
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function toNetmail($notifiable): Netmail
|
||||
{
|
||||
Log::info(sprintf('%s:Creating test netmail to [%s]',self::LOGKEY,$this->ao->ftn));
|
||||
|
||||
$so = Setup::findOrFail(config('app.id'))->system;
|
||||
|
||||
$o = new Netmail;
|
||||
$o->to = $this->ao->system->sysop;
|
||||
$o->from = Setup::PRODUCT_NAME;
|
||||
$o->subject = 'Testing 1, 2, 3...';
|
||||
$o->datetime = Carbon::now();
|
||||
$o->tzoffset = $o->datetime->utcOffset();
|
||||
|
||||
$o->fftn_id = $so->match($this->ao->zone)->first()->id;
|
||||
$o->tftn_id = $this->ao->id;
|
||||
$o->flags = Message::FLAG_LOCAL|Message::FLAG_PRIVATE;
|
||||
$o->cost = 0;
|
||||
|
||||
$o->tagline = 'Testing, testing, 1 2 3.';
|
||||
$o->tearline = sprintf('%s (%04X)',Setup::PRODUCT_NAME,Setup::PRODUCT_ID);
|
||||
|
||||
// Message
|
||||
$msg = new Page;
|
||||
$msg->addLogo(new ANSI('public/logo/netmail.bin'));
|
||||
|
||||
$header = new Thick;
|
||||
$header->addText(ANSI::ansi_code([1,37]).'Clearing Houz');
|
||||
$msg->addHeader($header,'FTN Mailer and Tosser',TRUE,0xc4);
|
||||
|
||||
$lbc = new Thin;
|
||||
$lbc->addText('Test');
|
||||
$msg->addLeftBoxContent($lbc);
|
||||
|
||||
$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->save();
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
70
app/Notifications/Netmails.php
Normal file
70
app/Notifications/Netmails.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
use App\Classes\FTN\Message;
|
||||
use App\Models\{Netmail,Setup,System};
|
||||
|
||||
abstract class Netmails extends Notification //implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
protected const via = 'netmail';
|
||||
|
||||
private const LOGKEY = 'NN-';
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->queue = 'netmail';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return [ self::via ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param System $so
|
||||
* @param mixed $notifiable
|
||||
* @return Netmail
|
||||
* @throws \Exception
|
||||
*/
|
||||
abstract public function toNetmail(System $so,object $notifiable): Netmail;
|
||||
|
||||
protected function setupNetmail(System $so,object $notifiable): Netmail
|
||||
{
|
||||
$ao = $notifiable->routeNotificationFor(static::via);
|
||||
|
||||
$o = new Netmail;
|
||||
$o->to = $ao->system->sysop;
|
||||
$o->from = Setup::PRODUCT_NAME;
|
||||
|
||||
$o->datetime = Carbon::now();
|
||||
$o->tzoffset = $o->datetime->utcOffset();
|
||||
|
||||
$o->fftn_id = $so->match($ao->zone)->first()->id;
|
||||
$o->tftn_id = $ao->id;
|
||||
$o->flags = (Message::FLAG_LOCAL|Message::FLAG_PRIVATE);
|
||||
$o->cost = 0;
|
||||
|
||||
$o->tearline = sprintf('%s (%04X)',Setup::PRODUCT_NAME,Setup::PRODUCT_ID);
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
69
app/Notifications/Netmails/AddressLink.php
Normal file
69
app/Notifications/Netmails/AddressLink.php
Normal 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;
|
||||
}
|
||||
}
|
80
app/Notifications/Netmails/PacketPasswordInvalid.php
Normal file
80
app/Notifications/Netmails/PacketPasswordInvalid.php
Normal 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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
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;
|
||||
}
|
||||
}
|
75
app/Notifications/Netmails/Reject.php
Normal file
75
app/Notifications/Netmails/Reject.php
Normal 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;
|
||||
}
|
||||
}
|
50
app/Notifications/Netmails/Test.php
Normal file
50
app/Notifications/Netmails/Test.php
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user