More complete rework of packet parsing and packet generation with 29710c

This commit is contained in:
2024-05-19 23:28:45 +10:00
parent 46f52dd56d
commit f279d85b08
43 changed files with 412 additions and 291 deletions

View File

@@ -41,6 +41,6 @@ class EchomailChannel
$o = $notification->toEchomail($notifiable);
Log::info(sprintf('%s:= Posted echomail (%d) [%s] to [%s]',self::LOGKEY,$o->id,$o->msgid,$echoarea));
Log::info(sprintf('%s:= Posted echomail (%d) [%s] to [%s]',self::LOGKEY,$o->id,$o->msgid,$echoarea->name));
}
}

View File

@@ -8,7 +8,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
use App\Classes\FTN\Message;
use App\Models\{Echoarea, Echomail, Setup, System};
use App\Models\{Echoarea,Echomail,Setup};
abstract class Echomails extends Notification //implements ShouldQueue
{
@@ -46,26 +46,24 @@ abstract class Echomails extends Notification //implements ShouldQueue
*/
abstract public function toEchomail(object $notifiable): Echomail;
protected function setupEchomail(Message $mo,object $notifiable): Echomail
protected function setupEchomail(Echomail $mo,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->echoarea_id = $echoarea->id;
$o->datetime = Carbon::now();
$o->tzoffset = $o->datetime->utcOffset();
$o->fftn_id = ($x=our_address($mo->fboss_o))->id;
$o->fftn_id = ($x=our_address($mo->fftn))->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']);
$o->kludges->put('CHRS:',$mo->kludges->get('chrs') ?: 'CP437 2');
return $o;
}

View File

@@ -6,8 +6,8 @@ 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\Classes\{Fonts\Thick,Fonts\Thin,Page};
use App\Models\Echomail;
use App\Notifications\Echomails;
use App\Traits\MessagePath;
@@ -17,14 +17,14 @@ class Test extends Echomails
private const LOGKEY = 'NNP';
private Message $mo;
private Echomail $mo;
/**
* Reply to a netmail ping request.
*
* @param Message $mo
* @param Echomail $mo
*/
public function __construct(Message $mo)
public function __construct(Echomail $mo)
{
parent::__construct();
@@ -43,9 +43,9 @@ class Test extends Echomails
$o = $this->setupEchomail($this->mo,$notifiable);
$echoarea = $notifiable->routeNotificationFor(static::via);
Log::info(sprintf('%s:+ Creating test echomail to [%s]',self::LOGKEY,$echoarea));
Log::info(sprintf('%s:+ Creating TEST echomail in [%s]',self::LOGKEY,$echoarea->name));
$o->to = $this->mo->user_from;
$o->to = $this->mo->from;
$o->subject = 'Test Reply';
// Message

View File

@@ -52,14 +52,13 @@ abstract class Netmails extends Notification //implements ShouldQueue
$ao = $notifiable->routeNotificationFor(static::via);
$o = new Netmail;
$o->set_sender = our_address($ao);
$o->to = $ao->system->sysop;
$o->from = Setup::PRODUCT_NAME;
$o->datetime = Carbon::now();
$o->tzoffset = $o->datetime->utcOffset();
$o->fftn_id = $o->set->get('set_sender')->id;
$o->fftn_id = our_address($ao)->id;
$o->tftn_id = $ao->id;
$o->flags = (Message::FLAG_LOCAL|Message::FLAG_PRIVATE);
$o->cost = 0;

View File

@@ -6,7 +6,7 @@ use Illuminate\Support\Facades\Log;
use App\Classes\FTN\Message;
use App\Notifications\Netmails;
use App\Models\{Netmail,System,User};
use App\Models\{Netmail,User};
use App\Traits\PageTemplate;
class AddressLink extends Netmails

View File

@@ -4,9 +4,8 @@ namespace App\Notifications\Netmails;
use Illuminate\Support\Facades\Log;
use App\Classes\FTN\Message;
use App\Notifications\Netmails;
use App\Models\{Netmail,System};
use App\Models\Netmail;
use App\Traits\{MessagePath,PageTemplate};
class Areafix extends Netmails
@@ -15,14 +14,14 @@ class Areafix extends Netmails
private const LOGKEY = 'NAF';
private Message $mo;
private Netmail $mo;
/**
* Reply to an areafix request.
*
* @param Message $mo
* @param Netmail $mo
*/
public function __construct(Message $mo)
public function __construct(Netmail $mo)
{
parent::__construct();
@@ -43,7 +42,7 @@ class Areafix extends Netmails
Log::info(sprintf('%s:+ Responding to areafix with netmail to [%s]',self::LOGKEY,$ao->ftn));
$o->to = $this->mo->user_from;
$o->to = $this->mo->from;
$o->replyid = $this->mo->msgid;
$o->subject = 'Areafix Reply';

View File

@@ -4,9 +4,8 @@ namespace App\Notifications\Netmails\Areafix;
use Illuminate\Support\Facades\Log;
use App\Classes\FTN\Message;
use App\Notifications\Netmails;
use App\Models\{Netmail,System};
use App\Models\Netmail;
use App\Traits\{MessagePath,PageTemplate};
class NotConfiguredHere extends Netmails
@@ -15,14 +14,14 @@ class NotConfiguredHere extends Netmails
private const LOGKEY = 'NCH';
private Message $mo;
private Netmail $mo;
/**
* Reply to a areafix, but the system isnt configured here.
*
* @param Message $mo
* @param Netmail $mo
*/
public function __construct(Message $mo)
public function __construct(Netmail $mo)
{
parent::__construct();
@@ -43,7 +42,7 @@ class NotConfiguredHere extends Netmails
Log::info(sprintf('%s:+ Responding to areafix for a node [%s] not configured here',self::LOGKEY,$ao->ftn));
$o->to = $this->mo->user_from;
$o->to = $this->mo->from;
$o->replyid = $this->mo->msgid;
$o->subject = 'Areafix - Not Configured Here';

View File

@@ -5,9 +5,8 @@ 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\Models\{Echomail,Netmail};
use App\Traits\{MessagePath,PageTemplate};
class EchoareaNoWrite extends Netmails
@@ -16,14 +15,14 @@ class EchoareaNoWrite extends Netmails
private const LOGKEY = 'NNW';
private Message $mo;
private Echomail $mo;
/**
* Send a sysop a message if they attempt to write to an area that they dont have permission.
*
* @param Message $mo
* @param Echomail $mo
*/
public function __construct(Message $mo)
public function __construct(Echomail $mo)
{
parent::__construct();
@@ -42,9 +41,9 @@ class EchoareaNoWrite extends Netmails
$o = $this->setupNetmail($notifiable);
$ao = $notifiable->routeNotificationFor(static::via);
Log::info(sprintf('%s:+ Creating ECHOMAIL NO WRITE netmail to [%s]',self::LOGKEY,$ao->ftn));
Log::info(sprintf('%s:+ Creating ECHOAREA NO WRITE netmail to [%s]',self::LOGKEY,$ao->ftn));
$o->subject = 'Echomail rejected - '.$this->mo->msgid;
$o->subject = sprintf('Echomail #%s rejected to %s',$this->mo->msgid,$this->mo->echoarea->name);
// Message
$msg = $this->page(FALSE,'nowrite');
@@ -52,13 +51,13 @@ class EchoareaNoWrite extends Netmails
$msg->addText(
sprintf("Your echomail 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,
$this->mo->to,
Carbon::now()->utc()->toDateTimeString(),
$this->mo->date->utc()->toDateTimeString(),
)
);
$msg->addText(sprintf("It appears that you do not have permission to post in this echoarea using the address [%s], so the message from your system was rejected.\r\r",$ao->ftn));
$msg->addText(sprintf("It appears that you do not have permission to post in [%s] using the address [%s], so the message from your system was rejected.\r\r",$this->mo->echoarea->name,$ao->ftn));
$msg->addText("Please contact the ZC if you think this is a mistake.\r\r");
$msg->addText($this->message_path($this->mo));

View File

@@ -42,7 +42,7 @@ class EchoareaNotExist extends Netmails
$o = $this->setupNetmail($notifiable);
$ao = $notifiable->routeNotificationFor(static::via);
Log::info(sprintf('%s:+ Creating ECHOMAIL NOT EXIST netmail to [%s]',self::LOGKEY,$ao->ftn));
Log::info(sprintf('%s:+ Creating ECHOAREA NOT EXIST netmail to [%s]',self::LOGKEY,$ao->ftn));
$o->subject = 'Echoarea doesnt exist - '.$this->mo->set->get('set_echoarea');
@@ -58,7 +58,7 @@ class EchoareaNotExist extends Netmails
)
);
$msg->addText("It appears that the echoarea that this message is for doesnt exist, so the message from your system was rejected.\r\r");
$msg->addText(sprintf("It appears that the echoarea [%s] that this message is for doesnt exist, so the message from your system was rejected.\r\r",$this->mo->set->get('set_echoarea')));
$msg->addText("Please contact the ZC if you think this is a mistake.\r\r");
$msg->addText($this->message_path($this->mo));

View File

@@ -5,9 +5,8 @@ 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\Models\{Echomail,Netmail};
use App\Traits\{MessagePath,PageTemplate};
class EchoareaNotSubscribed extends Netmails
@@ -16,14 +15,14 @@ class EchoareaNotSubscribed extends Netmails
private const LOGKEY = 'NNW';
private Message $mo;
private Echomail $mo;
/**
* Send a sysop a message if they write to an area that they hadnt previously subscribed to.
*
* @param Message $mo
* @param Echomail $mo
*/
public function __construct(Message $mo)
public function __construct(Echomail $mo)
{
parent::__construct();
@@ -42,17 +41,17 @@ class EchoareaNotSubscribed extends Netmails
$o = $this->setupNetmail($notifiable);
$ao = $notifiable->routeNotificationFor(static::via);
Log::info(sprintf('%s:+ Creating ECHOMAIL NOT SUBSCRIBED netmail to [%s]',self::LOGKEY,$ao->ftn));
Log::info(sprintf('%s:+ Creating ECHOAREA NOT SUBSCRIBED netmail to [%s]',self::LOGKEY,$ao->ftn));
$o->subject = 'Echoarea not subscribed - '.$this->mo->echoarea;
$o->subject = 'Echoarea not subscribed - '.$this->mo->echoarea->name;
// Message
$msg = $this->page(FALSE,'nothere');
$msg = $this->page(FALSE,'nosub');
$msg->addText(
sprintf("Your echomail 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,
$this->mo->to,
Carbon::now()->utc()->toDateTimeString(),
$this->mo->date->utc()->toDateTimeString(),
)

View File

@@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Log;
use App\Classes\FTN\Message;
use App\Notifications\Netmails;
use App\Models\{Netmail,System};
use App\Models\Netmail;
use App\Traits\{MessagePath,PageTemplate};
class EchomailBadAddress extends Netmails
@@ -52,7 +52,7 @@ class EchomailBadAddress extends Netmails
$msg->addText(
sprintf("Your echomail 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,
$this->mo->to,
Carbon::now()->utc()->toDateTimeString(),
$this->mo->date->utc()->toDateTimeString(),
)

View File

@@ -4,9 +4,8 @@ namespace App\Notifications\Netmails;
use Illuminate\Support\Facades\Log;
use App\Classes\FTN\Message;
use App\Notifications\Netmails;
use App\Models\{Address,Netmail,System};
use App\Models\{Address,Netmail};
use App\Traits\{MessagePath,PageTemplate};
class NetmailForward extends Netmails
@@ -16,15 +15,15 @@ class NetmailForward extends Netmails
private const LOGKEY = 'NNP';
private Address $ao;
private Message $mo;
private Netmail $mo;
/**
* Reply to a netmail ping request.
*
* @param Message $mo
* @param Netmail $mo
* @param Address $ao
*/
public function __construct(Message $mo,Address $ao)
public function __construct(Netmail $mo,Address $ao)
{
parent::__construct();
@@ -44,9 +43,9 @@ class NetmailForward extends Netmails
$o = $this->setupNetmail($notifiable);
$ao = $notifiable->routeNotificationFor(static::via);
Log::info(sprintf('%s:+ Advising [%s@%s] that netmail to [%s] will be forwarded to [%s].',self::LOGKEY,$this->mo->user_from,$ao->ftn,$this->mo->user_to,$this->ao->ftn));
Log::info(sprintf('%s:+ Advising [%s@%s] that netmail to [%s] will be forwarded to [%s].',self::LOGKEY,$this->mo->from,$ao->ftn,$this->mo->to,$this->ao->ftn));
$o->to = $this->mo->user_from;
$o->to = $this->mo->from;
$o->replyid = $this->mo->msgid;
$o->subject = sprintf('Your netmail is being forwarded to %s',$this->ao->ftn3d);
@@ -56,10 +55,10 @@ class NetmailForward extends Netmails
$msg->addText("Howdy, Clrghouz is not a BBS, so users cannot login to collect netmail.\r\r\r");
$msg->addText(sprintf("Never fear, your msg [%s] to [%s] has been forwarded, to [%s].\r\r",
$this->mo->msgid,
$this->mo->user_to,
$this->mo->to,
$this->ao->ftn3d,
));
$msg->addText(sprintf("To avoid receiving this netmail, send messages to [%s] to [%s].\r\r",$this->mo->user_to,$this->ao->ftn3d));
$msg->addText(sprintf("To avoid receiving this netmail, send messages to [%s] to [%s].\r\r",$this->mo->to,$this->ao->ftn3d));
$o->msg = $msg->render();
$o->tagline = 'Thank you so much for your mail. I love it already.';

View File

@@ -5,25 +5,24 @@ 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\Models\Netmail;
use App\Traits\{MessagePath,PageTemplate};
class Reject extends Netmails
class NetmailHubNoUser extends Netmails
{
use MessagePath,PageTemplate;
private const LOGKEY = 'NNP';
private Message $mo;
private Netmail $mo;
/**
* Reply to a netmail ping request.
*
* @param Message $mo
* @param Netmail $mo
*/
public function __construct(Message $mo)
public function __construct(Netmail $mo)
{
parent::__construct();
@@ -42,9 +41,9 @@ class Reject extends Netmails
$o = $this->setupNetmail($notifiable);
$ao = $notifiable->routeNotificationFor(static::via);
Log::info(sprintf('%s:+ Creating reject netmail to [%s]',self::LOGKEY,$ao->ftn));
Log::info(sprintf('%s:+ Creating HUB NO USER netmail to [%s]',self::LOGKEY,$ao->ftn));
$o->to = $this->mo->user_from;
$o->to = $this->mo->from;
$o->replyid = $this->mo->msgid;
$o->subject = 'Message Undeliverable - '.$this->mo->msgid;
@@ -54,7 +53,7 @@ class Reject extends Netmails
$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,
$this->mo->to,
Carbon::now()->utc()->toDateTimeString(),
$this->mo->date->utc()->toDateTimeString(),
)

View File

@@ -6,7 +6,7 @@ use Illuminate\Support\Facades\Log;
use App\Notifications\Netmails;
use App\Classes\FTN\Message;
use App\Models\{Netmail,System};
use App\Models\Netmail;
use App\Traits\PageTemplate;
class PacketPasswordInvalid extends Netmails

View File

@@ -8,7 +8,7 @@ use Illuminate\Support\Facades\Log;
use App\Classes\FTN\Message;
use App\Notifications\Netmails;
use App\Models\{Netmail,System};
use App\Models\Netmail;
use App\Traits\{MessagePath,PageTemplate};
class Ping extends Netmails
@@ -17,14 +17,14 @@ class Ping extends Netmails
private const LOGKEY = 'NNP';
private Message $mo;
private Netmail $mo;
/**
* Reply to a netmail ping request.
*
* @param Message $mo
*/
public function __construct(Message $mo)
public function __construct(Netmail $mo)
{
parent::__construct();
@@ -45,7 +45,7 @@ class Ping extends Netmails
Log::info(sprintf('%s:+ Creating PING netmail to [%s]',self::LOGKEY,$ao->ftn));
$o->to = $this->mo->user_from;
$o->to = $this->mo->from;
$o->replyid = $this->mo->msgid;
$o->subject = 'Ping Reply';

View File

@@ -5,9 +5,8 @@ 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\Models\Netmail;
use App\Traits\{MessagePath,PageTemplate};
class PollingFailed extends Netmails

View File

@@ -5,7 +5,7 @@ namespace App\Notifications\Netmails;
use Illuminate\Support\Facades\Log;
use App\Notifications\Netmails;
use App\Models\{Netmail,System};
use App\Models\Netmail;
use App\Traits\PageTemplate;
class Test extends Netmails