Skip to content

Commit 0a0d527

Browse files
authored
[Bug] Don't proceed with notifications if absolute threshold disabled (alexjustesen#1277)
1 parent 79ce402 commit 0a0d527

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed

app/Listeners/Database/SendSpeedtestThresholdNotification.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ public function handle(SpeedtestCompleted $event): void
1818
{
1919
$notificationSettings = new NotificationSettings();
2020

21-
$thresholdSettings = new ThresholdSettings();
22-
2321
if (! $notificationSettings->database_enabled) {
2422
return;
2523
}
@@ -28,6 +26,12 @@ public function handle(SpeedtestCompleted $event): void
2826
return;
2927
}
3028

29+
$thresholdSettings = new ThresholdSettings();
30+
31+
if (! $thresholdSettings->absolute_enabled) {
32+
return;
33+
}
34+
3135
if ($thresholdSettings->absolute_download > 0) {
3236
$this->absoluteDownloadThreshold(event: $event, thresholdSettings: $thresholdSettings);
3337
}

app/Listeners/Discord/SendSpeedtestThresholdNotification.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public function handle(SpeedtestCompleted $event): void
3535

3636
$thresholdSettings = new ThresholdSettings();
3737

38+
if (! $thresholdSettings->absolute_enabled) {
39+
return;
40+
}
41+
3842
$failed = [];
3943

4044
if ($thresholdSettings->absolute_download > 0) {
@@ -50,6 +54,8 @@ public function handle(SpeedtestCompleted $event): void
5054
}
5155

5256
if (! count($failed)) {
57+
Log::warning('Failed Discord thresholds not found, won\'t send notification.');
58+
5359
return;
5460
}
5561

app/Listeners/Mail/SendSpeedtestThresholdNotification.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public function handle(SpeedtestCompleted $event): void
3535

3636
$thresholdSettings = new ThresholdSettings();
3737

38+
if (! $thresholdSettings->absolute_enabled) {
39+
return;
40+
}
41+
3842
$failed = [];
3943

4044
if ($thresholdSettings->absolute_download > 0) {
@@ -50,6 +54,8 @@ public function handle(SpeedtestCompleted $event): void
5054
}
5155

5256
if (! count($failed)) {
57+
Log::warning('Failed mail thresholds not found, won\'t send notification.');
58+
5359
return;
5460
}
5561

app/Listeners/Telegram/SendSpeedtestThresholdNotification.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public function handle(SpeedtestCompleted $event): void
3636

3737
$thresholdSettings = new ThresholdSettings();
3838

39+
if (! $thresholdSettings->absolute_enabled) {
40+
return;
41+
}
42+
3943
$failed = [];
4044

4145
if ($thresholdSettings->absolute_download > 0) {
@@ -51,6 +55,8 @@ public function handle(SpeedtestCompleted $event): void
5155
}
5256

5357
if (! count($failed)) {
58+
Log::warning('Failed Telegram thresholds not found, won\'t send notification.');
59+
5460
return;
5561
}
5662

app/Listeners/Webhook/SendSpeedtestThresholdNotification.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ public function handle(SpeedtestCompleted $event): void
3737

3838
$thresholdSettings = new ThresholdSettings();
3939

40+
if (! $thresholdSettings->absolute_enabled) {
41+
return;
42+
}
43+
4044
$failed = [];
4145

4246
if ($thresholdSettings->absolute_download > 0) {
@@ -52,6 +56,8 @@ public function handle(SpeedtestCompleted $event): void
5256
}
5357

5458
if (! count($failed)) {
59+
Log::warning('Failed webhook thresholds not found, won\'t send notification.');
60+
5561
return;
5662
}
5763

0 commit comments

Comments
 (0)