|
4 | 4 |
|
5 | 5 | use App\Actions\GetExternalIpAddress; |
6 | 6 | use App\Enums\ResultStatus; |
| 7 | +use App\Events\SpeedtestFailed; |
7 | 8 | use App\Events\SpeedtestSkipped; |
8 | 9 | use App\Helpers\Network; |
9 | 10 | use App\Models\Result; |
@@ -47,8 +48,23 @@ public function handle(): void |
47 | 48 |
|
48 | 49 | $externalIp = GetExternalIpAddress::run(); |
49 | 50 |
|
| 51 | + if ($externalIp['ok'] === false) { |
| 52 | + $this->result->update([ |
| 53 | + 'data->type' => 'log', |
| 54 | + 'data->level' => 'error', |
| 55 | + 'data->message' => $externalIp['body'], |
| 56 | + 'status' => ResultStatus::Failed, |
| 57 | + ]); |
| 58 | + |
| 59 | + SpeedtestFailed::dispatch($this->result); |
| 60 | + |
| 61 | + $this->batch()->cancel(); |
| 62 | + |
| 63 | + return; |
| 64 | + } |
| 65 | + |
50 | 66 | $shouldSkip = $this->shouldSkip( |
51 | | - externalIp: $externalIp, |
| 67 | + externalIp: $externalIp['body'], |
52 | 68 | ); |
53 | 69 |
|
54 | 70 | if ($shouldSkip === false) { |
@@ -76,11 +92,11 @@ private function shouldSkip(string $externalIp): bool|string |
76 | 92 | $skipIPs = array_filter( |
77 | 93 | array_map( |
78 | 94 | 'trim', |
79 | | - explode(',', config('speedtest.skip_ips')), |
| 95 | + explode(',', config('speedtest.preflight.skip_ips')), |
80 | 96 | ), |
81 | 97 | ); |
82 | 98 |
|
83 | | - if (count($skipIPs) < 1) { |
| 99 | + if (empty($skipIPs)) { |
84 | 100 | return false; |
85 | 101 | } |
86 | 102 |
|
|
0 commit comments