clrghouz/app/Notifications/Netmails/NodesNew.php
Deon George db6c569345
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 29s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m32s
Create Docker Image / Final Docker Image Manifest (push) Successful in 8s
Added New Nodes Report
2024-11-04 12:44:46 +11:00

104 lines
2.8 KiB
PHP

<?php
namespace App\Notifications\Netmails;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Log;
use App\Classes\FTN\Message;
use App\Notifications\Netmails;
use App\Models\{Address,Netmail};
use App\Traits\PageTemplate;
class NodesNew extends Netmails //implements ShouldQueue
{
use Queueable,PageTemplate;
private const LOGKEY = 'NNN';
private Carbon $since;
private Collection $list;
/**
* Create a new notification instance.
*/
public function __construct(Carbon $since,Collection $list)
{
parent::__construct();
$this->list = $list;
$this->since = $since;
}
/**
* Get the mail representation of the notification.
*/
public function toNetmail(object $notifiable): Netmail
{
$o = $this->setupNetmail($notifiable);
$ao = $notifiable->routeNotificationFor(static::via);
Log::info(sprintf('%s:+ Sending a NEW NODE LIST to [%s] at address [%s]',self::LOGKEY,$ao->system->sysop,$ao->ftn));
$o->subject = sprintf('Here is a list of new nodes on clrghouz since %s',$x=$this->since->format('Y-m-d'));
$o->flags = (Message::FLAG_LOCAL|Message::FLAG_PRIVATE|Message::FLAG_CRASH);
// Message
$msg = $this->page(FALSE,'new nodes');
$msg->addText(sprintf("Hi %s,\r\r",$ao->system->sysop))
->addText(sprintf("The following new system have been defined on clrghouz since %s.\r\r",$x));
$this->list->loadMissing(['system']);
$space = str_repeat(' ',$this->list->pluck('ftn4d')->max(fn($item)=>strlen($item))+2);
$c = 0;
foreach ($this->list as $oo) {
if ($c++)
$msg->addText("\r");
$msg->addText(sprintf("* %s - %s from %s.\r",$oo->ftn4D,$oo->system->sysop,$oo->system->location));
if ($oo->system->method) {
switch ($oo->system->method) {
case 23:
$msg->addText(sprintf("%s - BBS is available TELNET [%s:%d]\r",$space,$oo->system->address,$oo->system->port));
break;
case 22:
$msg->addText(sprintf("%s - BBS is available SSH [%s:%d]\r",$space,$oo->system->address,$oo->system->port));
break;
case 519:
$msg->addText(sprintf("%s - BBS is available RLOGIN [%s:%d]\r",$space,$oo->system->address,$oo->system->port));
break;
default:
$msg->addText(sprintf("%s - No Details available for connecting to BBS\r",$space));
}
}
if ($oo->system->mailers->count()) {
$msg->addText("\r");
$msg->addText(sprintf("%s - Mail can be sent using:\r",$space));
foreach ($oo->system->mailers as $mo) {
$msg->addText(sprintf("%s * %s [%s:%d]\r",$space,$mo->name,$oo->system->address,$mo->pivot->port));
}
} else {
$msg->addText(sprintf("%s - No mailer information provided, so will be PRIVATE\r",$space));
}
}
$o->msg = $msg->render();
$o->set_tagline = 'All aboard!';
$o->save();
return $o;
}
}