From 98201425b381e048f0cfec1f95fd9d7f641286f5 Mon Sep 17 00:00:00 2001 From: Alex Justesen Date: Wed, 15 Mar 2023 19:27:37 -0400 Subject: [PATCH 1/2] added general settings for site name to listeners --- app/Listeners/SpeedtestCompletedListener.php | 6 ++++++ app/Listeners/Threshold/AbsoluteListener.php | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/app/Listeners/SpeedtestCompletedListener.php b/app/Listeners/SpeedtestCompletedListener.php index e5ab70681..d9a837c28 100644 --- a/app/Listeners/SpeedtestCompletedListener.php +++ b/app/Listeners/SpeedtestCompletedListener.php @@ -4,6 +4,7 @@ use App\Events\ResultCreated; use App\Mail\SpeedtestCompletedMail; +use App\Settings\GeneralSettings; use App\Settings\NotificationSettings; use App\Telegram\TelegramNotification; use Filament\Notifications\Notification; @@ -11,6 +12,8 @@ class SpeedtestCompletedListener { + public $generalSettings; + public $notificationSettings; /** @@ -20,6 +23,8 @@ class SpeedtestCompletedListener */ public function __construct() { + $this->generalSettings = new (GeneralSettings::class); + $this->notificationSettings = new (NotificationSettings::class); } @@ -59,6 +64,7 @@ public function handle(ResultCreated $event) $message = view('telegram.speedtest-completed', [ 'id' => $event->result->id, + 'site_name' => $this->generalSettings->site_name, 'ping' => $ping_value, 'download' => $download_value, 'upload' => $upload_value, diff --git a/app/Listeners/Threshold/AbsoluteListener.php b/app/Listeners/Threshold/AbsoluteListener.php index 259b9bd63..4bf5dd0fb 100644 --- a/app/Listeners/Threshold/AbsoluteListener.php +++ b/app/Listeners/Threshold/AbsoluteListener.php @@ -4,6 +4,7 @@ use App\Events\ResultCreated; use App\Mail\Threshold\AbsoluteMail; +use App\Settings\GeneralSettings; use App\Settings\NotificationSettings; use App\Settings\ThresholdSettings; use App\Telegram\TelegramNotification; @@ -14,6 +15,8 @@ class AbsoluteListener implements ShouldQueue { + public $generalSettings; + public $notificationSettings; public $thresholdSettings; @@ -25,6 +28,8 @@ class AbsoluteListener implements ShouldQueue */ public function __construct() { + $this->generalSettings = new (GeneralSettings::class); + $this->notificationSettings = new (NotificationSettings::class); $this->thresholdSettings = new (ThresholdSettings::class); @@ -205,6 +210,7 @@ protected function telegramChannel(ResultCreated $event) $message = view('telegram.threshold.absolute', [ 'id' => $event->result->id, 'url' => url('/admin/results'), + 'site_name' => $this->generalSettings->site_name, 'metrics' => $failedThresholds, ])->render(); From d6c1e31d8ebb1e703751ed75b2e19b4cde0ae3b8 Mon Sep 17 00:00:00 2001 From: Alex Justesen Date: Wed, 15 Mar 2023 19:27:54 -0400 Subject: [PATCH 2/2] site name and formatting for telegram notifications --- resources/views/telegram/speedtest-completed.blade.php | 5 ++++- resources/views/telegram/threshold/absolute.blade.php | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/resources/views/telegram/speedtest-completed.blade.php b/resources/views/telegram/speedtest-completed.blade.php index 481b35363..d5e0af62e 100644 --- a/resources/views/telegram/speedtest-completed.blade.php +++ b/resources/views/telegram/speedtest-completed.blade.php @@ -1,4 +1,7 @@ -Speedtest #{{ $id }} +{{ $site_name }} - Result *#{{ $id }}* + +*Speedtest Completed* +----- Ping: *{{ $ping }}* Download: *{{ $download }}* Upload: *{{ $upload }}* \ No newline at end of file diff --git a/resources/views/telegram/threshold/absolute.blade.php b/resources/views/telegram/threshold/absolute.blade.php index 8d8e95c56..ecf23e1ab 100644 --- a/resources/views/telegram/threshold/absolute.blade.php +++ b/resources/views/telegram/threshold/absolute.blade.php @@ -1,5 +1,7 @@ -Speedtest Result *#{{ $id }}* -*Absolute Threshold Failed* +{{ $site_name }} - Result *#{{ $id }}* + +*Absolute Threshold(s) Failed* +----- @foreach ($metrics as $item) -Threshold *{{ $item['name'] }}* {{ $item['threshold'] }}: *{{ $item['value'] }}* +Threshold *{{ $item['name'] }}* {{ $item['threshold'] }}: *{{ $item['value'] }}* @endforeach