clrghouz/app/Notifications/Netmails/PollingFailed.php

56 lines
1.5 KiB
PHP

<?php
namespace App\Notifications\Netmails;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use App\Notifications\Netmails;
use App\Models\Netmail;
use App\Traits\{MessagePath,PageTemplate};
class PollingFailed extends Netmails
{
use MessagePath,PageTemplate;
private const LOGKEY = 'NPF';
private Carbon $attempt;
/**
* 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:+ Creating auto hold netmail to [%s]',self::LOGKEY,$ao->ftn));
$o->subject = 'Failed polling - your system is on AUTO HOLD';
// Message
$msg = $this->page(FALSE,'hold');
$msg->addText("Hi, I've been trying to poll your system without success.\r\r");
$msg->addText("Your system was automatically placed on hold, which means I no longer attempted to poll you.\r\r");
$msg->addText(
'Since you collected this message, I automatically removed the auto hold status, but if future attempts to poll you fail '.
"you'll be automatically placed back on auto hold until you poll me. You'll also get this annoying message each time :(\r\r");
$msg->addText("To fix this, update your details that I use in the web interface, or change your system to HOLD while you are there.\r\r");
$o->msg = $msg->render();
$o->tagline = 'Painful? We can make that painless :)';
$o->save();
return $o;
}
}