diff --git a/app/Http/Controllers/External/VatsimNet/ProcessVatsimNetWebhook.php b/app/Http/Controllers/External/VatsimNet/ProcessVatsimNetWebhook.php index 63b1dd243..a48439077 100644 --- a/app/Http/Controllers/External/VatsimNet/ProcessVatsimNetWebhook.php +++ b/app/Http/Controllers/External/VatsimNet/ProcessVatsimNetWebhook.php @@ -3,6 +3,9 @@ namespace App\Http\Controllers\External\VatsimNet; use App\Http\Controllers\BaseController; +use App\Jobs\ExternalServices\VatsimNet\Webhooks\MemberChangedAction; +use App\Jobs\ExternalServices\VatsimNet\Webhooks\MemberCreatedAction; +use Illuminate\Support\Facades\Log; class ProcessVatsimNetWebhook extends BaseController { @@ -15,10 +18,19 @@ public function __invoke() } foreach (request()->json('actions') as $action) { - $class = config("services.vatsim-net.webhook.jobs.{$action['action']}"); - if ($class && class_exists($class)) { - dispatch(new $class(request()->json('resource'), $action))->afterResponse(); + $class = match ($action['action']) { + 'member_created_action' => MemberCreatedAction::class, + 'member_changed_action' => MemberChangedAction::class, + default => null, + }; + + if (! $class) { + Log::error("Unhandled webhook from VATSIM.net: {$action['action']}"); + + continue; } + + dispatch(new $class(request()->json('resource'), $action))->afterResponse(); } return response()->json([ diff --git a/config/services.php b/config/services.php index f27e404d9..04bce23fc 100644 --- a/config/services.php +++ b/config/services.php @@ -1,8 +1,5 @@ [ 'webhook' => [ 'key' => env('VATSIM_NET_WEBHOOK_KEY'), - 'jobs' => [ - 'member_created_action' => MemberCreatedAction::class, - 'member_changed_action' => MemberChangedAction::class, - ], ], 'api' => [ 'base' => env('VATSIM_API_BASE', 'https://api.vatsim.net/api/'),