Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

feat: add WebhookChannel placeholder implementation

Andras Bacsai729c891542df
diff --git a/app/Notifications/Channels/SendsWebhook.php b/app/Notifications/Channels/SendsWebhook.php
new file mode 100644
index 0000000000..9301a4ff0c
--- /dev/null
+++ b/app/Notifications/Channels/SendsWebhook.php
@@ -0,0 +1,8 @@
+<?php
+
+namespace App\Notifications\Channels;
+
+interface SendsWebhook
+{
+ public function routeNotificationForWebhook();
+}
diff --git a/app/Notifications/Channels/WebhookChannel.php b/app/Notifications/Channels/WebhookChannel.php
new file mode 100644
index 0000000000..53524e4f54
--- /dev/null
+++ b/app/Notifications/Channels/WebhookChannel.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace App\Notifications\Channels;
+
+use Illuminate\Notifications\Notification;
+use Illuminate\Support\Facades\Log;
+
+class WebhookChannel
+{
+ /**
+ * Send the given notification.
+ */
+ public function send(SendsWebhook $notifiable, Notification $notification): void
+ {
+ $webhookSettings = $notifiable->webhookNotificationSettings;
+
+ if (! $webhookSettings || ! $webhookSettings->isEnabled() || ! $webhookSettings->webhook_url) {
+ 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
+
+ Log::info('Webhook notification would be sent', [
+ 'url' => $webhookSettings->webhook_url,
+ 'notification' => get_class($notification),
+ ]);
+ }
+}
diff --git a/app/Notifications/Test.php b/app/Notifications/Test.php
index 430eb7b48e..5a635a601d 100644
--- a/app/Notifications/Test.php
+++ b/app/Notifications/Test.php
@@ -7,6 +7,7 @@ use App\Notifications\Channels\EmailChannel;
use App\Notifications\Channels\PushoverChannel;
use App\Notifications\Channels\SlackChannel;
use App\Notifications\Channels\TelegramChannel;
+use App\Notifications\Channels\WebhookChannel;
use App\Notifications\Dto\DiscordMessage;
use App\Notifications\Dto\PushoverMessage;
use App\Notifications\Dto\SlackMessage;
@@ -36,7 +37,7 @@ class Test extends Notification implements ShouldQueue
'telegram' => [TelegramChannel::class],
'slack' => [SlackChannel::class],
'pushover' => [PushoverChannel::class],
- 'webhook' => [], // WebhookChannel will be implemented later
+ 'webhook' => [WebhookChannel::class],
default => [],
};
} else {
@@ -111,4 +112,13 @@ class Test extends Notification implements ShouldQueue
description: 'This is a test Slack notification from Coolify.'
);
}
+
+ public function toWebhook(): array
+ {
+ return [
+ 'event' => 'test',
+ 'message' => 'This is a test webhook notification from Coolify.',
+ 'url' => base_url(),
+ ];
+ }
}
diff --git a/app/Traits/HasNotificationSettings.php b/app/Traits/HasNotificationSettings.php
index d101223865..297b44a06e 100644
--- a/app/Traits/HasNotificationSettings.php
+++ b/app/Traits/HasNotificationSettings.php
@@ -7,6 +7,7 @@ use App\Notifications\Channels\EmailChannel;
use App\Notifications\Channels\PushoverChannel;
use App\Notifications\Channels\SlackChannel;
use App\Notifications\Channels\TelegramChannel;
+use App\Notifications\Channels\WebhookChannel;
use Illuminate\Database\Eloquent\Model;
trait HasNotificationSettings
@@ -78,6 +79,7 @@ trait HasNotificationSettings
'telegram' => TelegramChannel::class,
'slack' => SlackChannel::class,
'pushover' => PushoverChannel::class,
+ 'webhook' => WebhookChannel::class,
];
if ($event === 'general') {