From 133c88316cf0e83ca18f629c26a26aefbc22d6f7 Mon Sep 17 00:00:00 2001 From: Calum Towers Date: Thu, 9 Jan 2025 19:21:15 +0000 Subject: [PATCH] wip --- .../External/VatsimNet/ProcessVatsimNetWebhook.php | 3 ++- .../VatsimNet/Webhooks/MemberChangedAction.php | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/External/VatsimNet/ProcessVatsimNetWebhook.php b/app/Http/Controllers/External/VatsimNet/ProcessVatsimNetWebhook.php index 061627b1a..a9743a7c5 100644 --- a/app/Http/Controllers/External/VatsimNet/ProcessVatsimNetWebhook.php +++ b/app/Http/Controllers/External/VatsimNet/ProcessVatsimNetWebhook.php @@ -15,7 +15,8 @@ public function __invoke() } foreach (request()->json('actions') as $action) { - if (class_exists($class = config("services.vatsim-net.webhook.jobs.{$action['action']}"))) { + $class = config("services.vatsim-net.webhook.jobs.{$action['action']}"); + if ($class && class_exists($class)) { dispatch(new $class(request()->json('resource'), $action)); // ->afterResponse(); } diff --git a/app/Jobs/ExternalServices/VatsimNet/Webhooks/MemberChangedAction.php b/app/Jobs/ExternalServices/VatsimNet/Webhooks/MemberChangedAction.php index ba60941c6..557e5e85d 100644 --- a/app/Jobs/ExternalServices/VatsimNet/Webhooks/MemberChangedAction.php +++ b/app/Jobs/ExternalServices/VatsimNet/Webhooks/MemberChangedAction.php @@ -30,7 +30,7 @@ public function handle() 'id', 'name_first', 'name_last', 'email', 'reg_date' => $this->processAccountChange($delta['field'], $delta['after']), 'rating' => $this->processAtcRatingChange($delta['after']), 'pilotrating' => $this->processPilotRatingChange($delta['after']), - 'division_id', 'region_id' => $this->processStateChange($delta['after']), + 'division_id', 'region_id' => $this->processStateChange(), default => null }; } @@ -53,10 +53,9 @@ private function processPilotRatingChange(mixed $value): void Account::firstWhere('id', $this->memberId)->updateVatsimRatings(pilotRating: $value); } - private function processStateChange(mixed $value): void + private function processStateChange(): void { - // if both a division and region is changed in the deltas - // this will run twice, which is not ideal + dump('processing state change'); $account = Account::with('states')->firstWhere('id', $this->memberId);