Skip to content

Commit 5955e6d

Browse files
authored
[Feature] more details in telegram notifications (alexjustesen#494)
1 parent a7f3374 commit 5955e6d

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

app/Listeners/SpeedtestCompletedListener.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44

55
use App\Events\ResultCreated;
66
use App\Mail\SpeedtestCompletedMail;
7+
use App\Settings\GeneralSettings;
78
use App\Settings\NotificationSettings;
89
use App\Telegram\TelegramNotification;
910
use Filament\Notifications\Notification;
1011
use Illuminate\Support\Facades\Mail;
1112

1213
class SpeedtestCompletedListener
1314
{
15+
public $generalSettings;
16+
1417
public $notificationSettings;
1518

1619
/**
@@ -20,6 +23,8 @@ class SpeedtestCompletedListener
2023
*/
2124
public function __construct()
2225
{
26+
$this->generalSettings = new (GeneralSettings::class);
27+
2328
$this->notificationSettings = new (NotificationSettings::class);
2429
}
2530

@@ -59,6 +64,7 @@ public function handle(ResultCreated $event)
5964

6065
$message = view('telegram.speedtest-completed', [
6166
'id' => $event->result->id,
67+
'site_name' => $this->generalSettings->site_name,
6268
'ping' => $ping_value,
6369
'download' => $download_value,
6470
'upload' => $upload_value,

app/Listeners/Threshold/AbsoluteListener.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Events\ResultCreated;
66
use App\Mail\Threshold\AbsoluteMail;
7+
use App\Settings\GeneralSettings;
78
use App\Settings\NotificationSettings;
89
use App\Settings\ThresholdSettings;
910
use App\Telegram\TelegramNotification;
@@ -14,6 +15,8 @@
1415

1516
class AbsoluteListener implements ShouldQueue
1617
{
18+
public $generalSettings;
19+
1720
public $notificationSettings;
1821

1922
public $thresholdSettings;
@@ -25,6 +28,8 @@ class AbsoluteListener implements ShouldQueue
2528
*/
2629
public function __construct()
2730
{
31+
$this->generalSettings = new (GeneralSettings::class);
32+
2833
$this->notificationSettings = new (NotificationSettings::class);
2934

3035
$this->thresholdSettings = new (ThresholdSettings::class);
@@ -205,6 +210,7 @@ protected function telegramChannel(ResultCreated $event)
205210
$message = view('telegram.threshold.absolute', [
206211
'id' => $event->result->id,
207212
'url' => url('/admin/results'),
213+
'site_name' => $this->generalSettings->site_name,
208214
'metrics' => $failedThresholds,
209215
])->render();
210216

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
Speedtest #{{ $id }}
1+
{{ $site_name }} - Result *#{{ $id }}*
2+
3+
*Speedtest Completed*
4+
-----
25
Ping: *{{ $ping }}*
36
Download: *{{ $download }}*
47
Upload: *{{ $upload }}*
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
Speedtest Result *#{{ $id }}*
2-
*Absolute Threshold Failed*
1+
{{ $site_name }} - Result *#{{ $id }}*
2+
3+
*Absolute Threshold(s) Failed*
4+
-----
35
@foreach ($metrics as $item)
4-
Threshold *{{ $item['name'] }}* {{ $item['threshold'] }}: *{{ $item['value'] }}*
6+
Threshold *{{ $item['name'] }}* {{ $item['threshold'] }}: *{{ $item['value'] }}*
57
@endforeach

0 commit comments

Comments
 (0)