fix(notifications): add missing toWebhook methods to notifications (#11528)

This commit is contained in:
🏔️ Peak
2026-09-05 12:35:36 +02:00
committed by GitHub
9 changed files with 188 additions and 26 deletions
@@ -100,4 +100,16 @@ class ApiTokenExpiringNotification extends CustomEmailNotification
color: SlackMessage::warningColor(),
);
}
public function toWebhook(): array
{
return [
'success' => false,
'message' => "API token '{$this->tokenName}' expires on {$this->expiresAt}. Rotate this token before it expires to avoid API outages.",
'event' => 'api_token_expiring',
'token_name' => $this->tokenName,
'expires_at' => $this->expiresAt,
'url' => $this->manageUrl,
];
}
}
@@ -58,4 +58,14 @@ class GeneralNotification extends Notification implements ShouldQueue
color: SlackMessage::infoColor(),
);
}
public function toWebhook(): array
{
return [
'success' => true,
'message' => $this->message,
'event' => 'general',
'url' => base_url(),
];
}
}
-22
View File
@@ -1,22 +0,0 @@
<?php
namespace Illuminate\Notifications;
use App\Notifications\Channels\SendsEmail;
use App\Notifications\Dto\DiscordMessage;
use App\Notifications\Dto\PushoverMessage;
use App\Notifications\Dto\SlackMessage;
use Illuminate\Notifications\Messages\MailMessage;
interface Notification
{
public function toMail(SendsEmail $notifiable): MailMessage;
public function toPushover(): PushoverMessage;
public function toDiscord(): DiscordMessage;
public function toSlack(): SlackMessage;
public function toTelegram();
}
@@ -74,4 +74,16 @@ class ForceDisabled extends CustomEmailNotification
color: SlackMessage::errorColor()
);
}
public function toWebhook(): array
{
return [
'success' => false,
'message' => "Server ({$this->server->name}) disabled because it is not paid! All automations and integrations are stopped.",
'event' => 'server_force_disabled',
'server_name' => $this->server->name,
'server_uuid' => $this->server->uuid,
'url' => base_url().'/server/'.$this->server->uuid,
];
}
}
+12
View File
@@ -65,4 +65,16 @@ class ForceEnabled extends CustomEmailNotification
color: SlackMessage::successColor()
);
}
public function toWebhook(): array
{
return [
'success' => true,
'message' => "Server ({$this->server->name}) enabled again!",
'event' => 'server_force_enabled',
'server_name' => $this->server->name,
'server_uuid' => $this->server->uuid,
'url' => base_url().'/server/'.$this->server->uuid,
];
}
}
@@ -17,8 +17,7 @@ class HetznerDeletionFailed extends CustomEmailNotification
public function via(object $notifiable): array
{
return $notifiable->getEnabledChannels('hetzner_deletion_failed');
return $notifiable->getEnabledChannels('hetzner_deletion_failure');
}
public function toMail(): MailMessage
@@ -66,4 +65,16 @@ class HetznerDeletionFailed extends CustomEmailNotification
color: SlackMessage::errorColor()
);
}
public function toWebhook(): array
{
return [
'success' => false,
'message' => "[ACTION REQUIRED] Failed to delete Hetzner server #{$this->hetznerServerId} from Hetzner Cloud. The server has been removed from Coolify, but may still exist in your Hetzner Cloud account.",
'event' => 'hetzner_deletion_failed',
'hetzner_server_id' => $this->hetznerServerId,
'error' => $this->errorMessage,
'url' => base_url().'/servers',
];
}
}
@@ -117,4 +117,18 @@ class SslExpirationNotification extends CustomEmailNotification
color: SlackMessage::warningColor()
);
}
public function toWebhook(): array
{
$resourceNames = $this->resources->pluck('name');
return [
'success' => false,
'message' => "SSL certificates have been renewed for: {$resourceNames->join(', ')}. These resources need to be redeployed manually for the new SSL certificates to take effect.",
'event' => 'ssl_certificate_renewal',
'resources' => $resourceNames->values()->all(),
'urls' => $this->urls,
'url' => base_url(),
];
}
}