feat: add WebhookChannel placeholder implementation

Add basic WebhookChannel infrastructure:
- Create SendsWebhook interface
- Create WebhookChannel with placeholder implementation (logs instead of sending)
- Update Test notification to support webhook channel
- Add WebhookChannel to HasNotificationSettings trait
- Add toWebhook() method to Test notification

This provides a working foundation that won't break test notifications.
The actual HTTP webhook delivery will be implemented in a follow-up.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai 2025-10-10 17:57:10 +02:00
parent 22153c419d
commit 729c891542
4 changed files with 54 additions and 1 deletions

View file

@ -0,0 +1,8 @@
<?php
namespace App\Notifications\Channels;
interface SendsWebhook
{
public function routeNotificationForWebhook();
}

View file

@ -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),
]);
}
}

View file

@ -7,6 +7,7 @@
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 @@ public function via(object $notifiable): array
'telegram' => [TelegramChannel::class],
'slack' => [SlackChannel::class],
'pushover' => [PushoverChannel::class],
'webhook' => [], // WebhookChannel will be implemented later
'webhook' => [WebhookChannel::class],
default => [],
};
} else {
@ -111,4 +112,13 @@ public function toSlack(): SlackMessage
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(),
];
}
}

View file

@ -7,6 +7,7 @@
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 @@ public function getEnabledChannels(string $event): array
'telegram' => TelegramChannel::class,
'slack' => SlackChannel::class,
'pushover' => PushoverChannel::class,
'webhook' => WebhookChannel::class,
];
if ($event === 'general') {