onQueue('high'); } /** * Execute the job. */ public function handle(): void { $validator = Validator::make( ['webhook_url' => $this->webhookUrl], ['webhook_url' => ['required', 'url', new SafeWebhookUrl]] ); if ($validator->fails()) { Log::warning('SendWebhookJob: blocked unsafe webhook URL', [ 'url' => SafeWebhookUrl::redactedUrlForLog($this->webhookUrl), 'errors' => $validator->errors()->all(), ]); return; } try { $httpOptions = SafeWebhookUrl::httpClientOptions($this->webhookUrl); } catch (\RuntimeException $e) { Log::warning('SendWebhookJob: blocked unsafe webhook URL at send time', [ 'url' => SafeWebhookUrl::redactedUrlForLog($this->webhookUrl), 'error' => $e->getMessage(), ]); return; } $response = $this->sendNotificationRequest('Webhook', $this->webhookUrl, fn () => Http::withOptions($httpOptions)->post($this->webhookUrl, $this->payload)); // 401/403: the endpoint rejects us, 404/410: the endpoint does not exist anymore. $this->handleNotificationResponse($response, 'Webhook', in_array($response->status(), [401, 403, 404, 410], true)); } }