clrghouz/app/Notifications/Netmails/Areafix/CommandsProcessed.php
Deon George 1128bddcee
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 33s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m34s
Create Docker Image / Final Docker Image Manifest (push) Successful in 8s
Added areafix %HELP
2024-10-31 23:53:43 +11:00

67 lines
1.5 KiB
PHP

<?php
namespace App\Notifications\Netmails\Areafix;
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 areafix, commands unknown.
*
* @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 areafix for a node [%s] commands processed',self::LOGKEY,$ao->ftn));
$o->to = $this->mo->from;
$o->replyid = $this->mo->msgid;
$o->subject = 'Areafix - Result';
// Message
$msg = $this->page(FALSE,'Areafix');
$msg->addText("Your areafix 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;
}
}