Added system polling

This commit is contained in:
2023-07-26 19:44:07 +10:00
parent c23b5ebfc2
commit 4e44e2e266
19 changed files with 733 additions and 88 deletions

View File

@@ -5,7 +5,6 @@ namespace App\Notifications\Channels;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Log;
use App\Jobs\AddressPoll as Job;
use App\Models\Netmail;
use App\Models\Setup;
@@ -43,7 +42,6 @@ class NetmailChannel
$so = Setup::findOrFail(config('app.id'))->system;
$o = $notification->toNetmail($so,$notifiable);
Job::dispatch($ao);
Log::info(sprintf('%s:= Sent netmail [%s] to [%s]',self::LOGKEY,$o->msgid,$ao->ftn));
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace App\Notifications\Netmails;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use App\Classes\FTN\Message;
use App\Notifications\Netmails;
use App\Models\{Netmail,System};
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 System $so
* @param mixed $notifiable
* @return Netmail
* @throws \Exception
*/
public function toNetmail(System $so,object $notifiable): Netmail
{
$o = $this->setupNetmail($so,$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;
}
}