Respond to filefix commands with Filefix/CommandsProcessed

This commit is contained in:
Deon George 2024-11-26 22:24:19 +11:00
parent ca7ca7e60a
commit 38cfcc8c3e
3 changed files with 69 additions and 2 deletions

View File

@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Log;
use App\Classes\FTN\Process\Netmail\Robot; use App\Classes\FTN\Process\Netmail\Robot;
use App\Models\{Echomail,Netmail}; use App\Models\{Echomail,Netmail};
use App\Notifications\Netmails\Areafix\CommandsProcessed; use App\Notifications\Netmails\Filefix\CommandsProcessed;
/** /**
* Process messages to Ping * Process messages to Ping

View File

@ -16,7 +16,7 @@ class CommandsProcessed extends Netmails
private const LOGKEY = 'ACU'; private const LOGKEY = 'ACU';
/** /**
* Reply to a areafix, commands unknown. * Reply to a areafix commands.
* *
* @param Netmail $mo * @param Netmail $mo
* @param Collection $commands * @param Collection $commands

View File

@ -0,0 +1,67 @@
<?php
namespace App\Notifications\Netmails\Filefix;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use App\Notifications\Netmails;
use App\Models\Netmail;
use App\Traits\{MessagePath,PageTemplate};
class CommandsProcessed extends Netmails
{
use MessagePath,PageTemplate;
private const LOGKEY = 'ACU';
/**
* Reply to a files commands.
*
* @param Netmail $mo
* @param Collection $commands
*/
public function __construct(private Netmail $mo,private Collection $commands)
{
parent::__construct();
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return Netmail
* @throws \Exception
*/
public function toNetmail(object $notifiable): Netmail
{
$o = $this->setupNetmail($notifiable);
$ao = $notifiable->routeNotificationFor(static::via);
Log::info(sprintf('%s:+ Responding to filefix for a node [%s] COMMANDS PROCESSED',self::LOGKEY,$ao->ftn));
$o->to = $this->mo->from;
$o->replyid = $this->mo->msgid;
$o->subject = 'Filefix - Result';
// Message
$msg = $this->page(FALSE,'Filefix');
$msg->addText("Your filefix request has been received, here is the result:\r\r");
foreach ($this->commands as $command) {
$msg->addText("$command\r");
}
$msg->addText("\r");
$msg->addText($this->message_path($this->mo));
$o->msg = $msg->render();
$o->set_tagline = 'Why did the robot cross the road? The chicken programmed it.';
$o->save();
return $o;
}
}