clrghouz/app/Notifications/Netmails/PollingFailed.php

56 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2023-07-26 09:44:07 +00:00
<?php
namespace App\Notifications\Netmails;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use App\Notifications\Netmails;
use App\Models\Netmail;
2023-07-26 09:44:07 +00:00
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
2023-07-26 09:44:07 +00:00
{
$o = $this->setupNetmail($notifiable);
2023-07-26 09:44:07 +00:00
$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();
2024-06-03 09:08:40 +00:00
$o->set_tagline = 'Painful? We can make that painless :)';
2023-07-26 09:44:07 +00:00
$o->save();
return $o;
}
}