diff --git a/app/Jobs/SendWebhookJob.php b/app/Jobs/SendWebhookJob.php new file mode 100644 index 000000000..865dd9493 --- /dev/null +++ b/app/Jobs/SendWebhookJob.php @@ -0,0 +1,45 @@ +onQueue('high'); + } + + /** + * Execute the job. + */ + public function handle(): void + { + Http::post($this->webhookUrl, $this->payload); + } +} diff --git a/app/Notifications/Channels/WebhookChannel.php b/app/Notifications/Channels/WebhookChannel.php index 53524e4f5..757e5e934 100644 --- a/app/Notifications/Channels/WebhookChannel.php +++ b/app/Notifications/Channels/WebhookChannel.php @@ -2,8 +2,8 @@ namespace App\Notifications\Channels; +use App\Jobs\SendWebhookJob; use Illuminate\Notifications\Notification; -use Illuminate\Support\Facades\Log; class WebhookChannel { @@ -18,16 +18,8 @@ public function send(SendsWebhook $notifiable, Notification $notification): void return; } - // TODO: Implement actual webhook delivery - // This is a placeholder implementation - // You'll need to: - // 1. Get the webhook payload from $notification->toWebhook() - // 2. Create a job to send the HTTP POST request to $webhookSettings->webhook_url - // 3. Handle retries and errors appropriately + $payload = $notification->toWebhook(); - Log::info('Webhook notification would be sent', [ - 'url' => $webhookSettings->webhook_url, - 'notification' => get_class($notification), - ]); + SendWebhookJob::dispatch($payload, $webhookSettings->webhook_url); } } diff --git a/app/Notifications/Test.php b/app/Notifications/Test.php index 5a635a601..60bc8a0ee 100644 --- a/app/Notifications/Test.php +++ b/app/Notifications/Test.php @@ -116,8 +116,9 @@ public function toSlack(): SlackMessage public function toWebhook(): array { return [ - 'event' => 'test', + 'success' => true, 'message' => 'This is a test webhook notification from Coolify.', + 'event' => 'test', 'url' => base_url(), ]; }