coolify/app/Notifications/Internal/GeneralNotification.php
Ousama Ben Younes f9f53f2fea fix(notifications): implement toWebhook() for always-send notifications
WebhookChannel::send() calls toWebhook() unconditionally, but the five
notifications reachable through alwaysSendEvents did not implement it, so
enabling the webhook channel turned those events into fatal queued jobs.
2026-08-27 04:45:39 +00:00

71 lines
1.6 KiB
PHP

<?php
namespace App\Notifications\Internal;
use App\Notifications\Dto\DiscordMessage;
use App\Notifications\Dto\PushoverMessage;
use App\Notifications\Dto\SlackMessage;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
class GeneralNotification extends Notification implements ShouldQueue
{
use Queueable;
public $tries = 1;
public function __construct(public string $message)
{
$this->onQueue('high');
}
public function via(object $notifiable): array
{
return $notifiable->getEnabledChannels('general');
}
public function toDiscord(): DiscordMessage
{
return new DiscordMessage(
title: 'Coolify: General Notification',
description: $this->message,
color: DiscordMessage::infoColor(),
);
}
public function toTelegram(): array
{
return [
'message' => $this->message,
];
}
public function toPushover(): PushoverMessage
{
return new PushoverMessage(
title: 'General Notification',
level: 'info',
message: $this->message,
);
}
public function toSlack(): SlackMessage
{
return new SlackMessage(
title: 'Coolify: General Notification',
description: $this->message,
color: SlackMessage::infoColor(),
);
}
public function toWebhook(): array
{
return [
'success' => true,
'message' => $this->message,
'event' => 'general',
'url' => base_url(),
];
}
}