68 lines
1.6 KiB
PHP
68 lines
1.6 KiB
PHP
<?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 Scan extends Netmails
|
|
{
|
|
use MessagePath,PageTemplate;
|
|
|
|
private const LOGKEY = 'FCS';
|
|
|
|
/**
|
|
* Notification on a (re)scan request.
|
|
*
|
|
* @param Collection $result
|
|
*/
|
|
public function __construct(private Collection $result)
|
|
{
|
|
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] SCAN processed',self::LOGKEY,$ao->ftn));
|
|
|
|
$o->subject = 'Filefix - Scan Results';
|
|
|
|
// Message
|
|
$msg = $this->page(FALSE,'Filefix');
|
|
|
|
$msg->addText("A filefix (re)Scan has completed:\r\r");
|
|
|
|
$msg->addText(sprintf("Area: %s, Queued: %d, Skipped: %d\r\r",
|
|
$this->result->get('area'),
|
|
$this->result->get('queued'),
|
|
$this->result->get('skipped'),
|
|
));
|
|
|
|
if ($x=$this->result->get('earliest'))
|
|
$msg->addText(sprintf("The earliest file being sent: %s.\r",$x));
|
|
|
|
if (($x=$this->result->get('latest')) && ($this->result->get('earliest') !== $x))
|
|
$msg->addText(sprintf("The latest file being sent: %s.\r",$x));
|
|
|
|
$o->msg = $msg->render();
|
|
$o->set_tagline = 'Why did the chicken cross the road? The robot programmed it.';
|
|
|
|
$o->save();
|
|
|
|
return $o;
|
|
}
|
|
} |