Respond to areafix netmails
This commit is contained in:
parent
2e7aecff57
commit
22c8b3df74
36
app/Classes/FTN/Process/Netmail/Areafix.php
Normal file
36
app/Classes/FTN/Process/Netmail/Areafix.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\FTN\Process\Netmail;
|
||||
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\FTN\{Message,Process};
|
||||
use App\Notifications\Netmails\Areafix as AreafixNotification;
|
||||
use App\Notifications\Netmails\Areafix\NotConfiguredHere as AreafixNotConfiguredHereNotification;
|
||||
|
||||
/**
|
||||
* Process messages to Ping
|
||||
*
|
||||
* @package App\Classes\FTN\Process
|
||||
*/
|
||||
final class Areafix extends Process
|
||||
{
|
||||
private const LOGKEY = 'RP-';
|
||||
|
||||
public static function handle(Message $msg): bool
|
||||
{
|
||||
if (strtolower($msg->user_to) !== 'areafix')
|
||||
return FALSE;
|
||||
|
||||
Log::info(sprintf('%s:- Processing AREAFIX message from (%s) [%s]',self::LOGKEY,$msg->user_from,$msg->fftn));
|
||||
|
||||
// If this is not a node we manage, then respond with a sorry can help you
|
||||
if ($msg->fftn_o->system->sessions->count())
|
||||
Notification::route('netmail',$msg->fftn_o)->notify(new AreafixNotification($msg));
|
||||
else
|
||||
Notification::route('netmail',$msg->fftn_o)->notify(new AreafixNotConfiguredHereNotification($msg));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
66
app/Notifications/Netmails/Areafix.php
Normal file
66
app/Notifications/Netmails/Areafix.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
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\Traits\{MessagePath,PageTemplate};
|
||||
|
||||
class Areafix extends Netmails
|
||||
{
|
||||
use MessagePath,PageTemplate;
|
||||
|
||||
private const LOGKEY = 'NAF';
|
||||
|
||||
private Message $mo;
|
||||
|
||||
/**
|
||||
* Reply to an areafix 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:+ Responding to areafix with 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,'Areafix');
|
||||
|
||||
$msg->addText("Your areafix request has been received, but unfortunately I do not know how to handle areafix messages yet.\r\r");
|
||||
$msg->addText(sprintf("Until then, you may be able to achieve what you want via the web UI. Head over to %s. Feel free to netmail if you need help.\r\r",config('app.url')));
|
||||
|
||||
$msg->addText($this->message_path($this->mo));
|
||||
|
||||
$o->msg = $msg->render();
|
||||
$o->tagline = 'Why did the robot cross the road? The chicken programmed it.';
|
||||
|
||||
$o->save();
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
66
app/Notifications/Netmails/Areafix/NotConfiguredHere.php
Normal file
66
app/Notifications/Netmails/Areafix/NotConfiguredHere.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
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\Traits\{MessagePath,PageTemplate};
|
||||
|
||||
class NotConfiguredHere extends Netmails
|
||||
{
|
||||
use MessagePath,PageTemplate;
|
||||
|
||||
private const LOGKEY = 'NCH';
|
||||
|
||||
private Message $mo;
|
||||
|
||||
/**
|
||||
* Reply to a areafix, but the system isnt configured here.
|
||||
*
|
||||
* @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:+ Responding to areafix for a node [%s] not configured here',self::LOGKEY,$ao->ftn));
|
||||
|
||||
$o->to = $this->mo->user_from;
|
||||
$o->replyid = $this->mo->msgid;
|
||||
$o->subject = 'Ping Reply';
|
||||
|
||||
// Message
|
||||
$msg = $this->page(FALSE,'Areafix');
|
||||
|
||||
$msg->addText("Your areafix request has been received, but unfortunately you are not configured here.\r\r");
|
||||
$msg->addText(sprintf("If you want to receive mail from this system, please register/link your BBS via the web UI. Head over to %s. Feel free to netmail if you need help.\r\r",config('app.url')));
|
||||
|
||||
$msg->addText($this->message_path($this->mo));
|
||||
|
||||
$o->msg = $msg->render();
|
||||
$o->tagline = 'Why did the robot cross the road? The chicken programmed it.';
|
||||
|
||||
$o->save();
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
@ -42,7 +42,7 @@ trait MessagePath
|
||||
$reply .= "No path information? This would be normal if this message came directly to the hub\r";
|
||||
}
|
||||
|
||||
$reply .= "+--[ END MESSAGE ]------------------------------------+\r";
|
||||
$reply .= "+--[ END MESSAGE ]------------------------------------+\r\r";
|
||||
|
||||
return $reply;
|
||||
}
|
||||
|
@ -9,5 +9,6 @@ return [
|
||||
// Netmail
|
||||
'robots' => [
|
||||
\App\Classes\FTN\Process\Netmail\Ping::class,
|
||||
\App\Classes\FTN\Process\Netmail\Areafix::class,
|
||||
],
|
||||
];
|
Loading…
Reference in New Issue
Block a user