From 5571aa4530d4e3e6107f1ebf878e12bb9479a51a Mon Sep 17 00:00:00 2001 From: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Date: Mon, 16 Dec 2024 14:06:16 +0100 Subject: [PATCH] feat: use new ServerReachabilityChanged event instead of isDirty --- app/Console/Commands/CloudCleanupSubscriptions.php | 3 +++ app/Livewire/Server/Show.php | 2 ++ app/Models/ServerSetting.php | 3 --- app/Models/Team.php | 2 ++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/CloudCleanupSubscriptions.php b/app/Console/Commands/CloudCleanupSubscriptions.php index 9198b003e..9dc6e24f5 100644 --- a/app/Console/Commands/CloudCleanupSubscriptions.php +++ b/app/Console/Commands/CloudCleanupSubscriptions.php @@ -2,6 +2,7 @@ namespace App\Console\Commands; +use App\Events\ServerReachabilityChanged; use App\Models\Team; use Illuminate\Console\Command; @@ -92,6 +93,8 @@ class CloudCleanupSubscriptions extends Command $server->update([ 'ip' => '1.2.3.4', ]); + + ServerReachabilityChanged::dispatch($server); } } } diff --git a/app/Livewire/Server/Show.php b/app/Livewire/Server/Show.php index ac5211c1b..6d267b9c8 100644 --- a/app/Livewire/Server/Show.php +++ b/app/Livewire/Server/Show.php @@ -4,6 +4,7 @@ namespace App\Livewire\Server; use App\Actions\Server\StartSentinel; use App\Actions\Server\StopSentinel; +use App\Events\ServerReachabilityChanged; use App\Models\Server; use Livewire\Attributes\Computed; use Livewire\Attributes\Validate; @@ -202,6 +203,7 @@ class Show extends Component $this->server->settings->is_reachable = $this->isReachable = true; $this->server->settings->is_usable = $this->isUsable = true; $this->server->settings->save(); + ServerReachabilityChanged::dispatch($this->server); $this->dispatch('proxyStatusUpdated'); } else { $this->dispatch('error', 'Server is not reachable.', 'Please validate your configuration and connection.

Check this documentation for further help.

Error: '.$error); diff --git a/app/Models/ServerSetting.php b/app/Models/ServerSetting.php index e078372e2..f4b776cca 100644 --- a/app/Models/ServerSetting.php +++ b/app/Models/ServerSetting.php @@ -85,9 +85,6 @@ class ServerSetting extends Model ) { $settings->server->restartSentinel(); } - if ($settings->isDirty('is_reachable')) { - $settings->server->isReachableChanged(); - } }); } diff --git a/app/Models/Team.php b/app/Models/Team.php index e55cb0d19..33847a3c8 100644 --- a/app/Models/Team.php +++ b/app/Models/Team.php @@ -2,6 +2,7 @@ namespace App\Models; +use App\Events\ServerReachabilityChanged; use App\Notifications\Channels\SendsDiscord; use App\Notifications\Channels\SendsEmail; use App\Notifications\Channels\SendsPushover; @@ -202,6 +203,7 @@ class Team extends Model implements SendsDiscord, SendsEmail, SendsPushover, Sen 'is_usable' => false, 'is_reachable' => false, ]); + ServerReachabilityChanged::dispatch($server); } }