feat: Docker cleanup success and failure notification files
This commit is contained in:
60
app/Notifications/Server/DockerCleanupSuccess.php
Normal file
60
app/Notifications/Server/DockerCleanupSuccess.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications\Server;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Notifications\CustomEmailNotification;
|
||||
use App\Notifications\Dto\DiscordMessage;
|
||||
use App\Notifications\Dto\SlackMessage;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class DockerCleanupSuccess extends CustomEmailNotification
|
||||
{
|
||||
public function __construct(public Server $server, public string $message)
|
||||
{
|
||||
$this->onQueue('high');
|
||||
}
|
||||
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return $notifiable->getEnabledChannels('docker_cleanup_success');
|
||||
}
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mail->subject("Coolify: Docker cleanup job succeeded on {$this->server->name}");
|
||||
$mail->view('emails.docker-cleanup-success', [
|
||||
'serverName' => $this->server->name,
|
||||
'message' => $this->message,
|
||||
]);
|
||||
|
||||
return $mail;
|
||||
}
|
||||
|
||||
|
||||
public function toDiscord(): DiscordMessage
|
||||
{
|
||||
return new DiscordMessage(
|
||||
title: ':white_check_mark: Coolify: Docker cleanup job succeeded on '.$this->server->name,
|
||||
description: $this->message,
|
||||
color: DiscordMessage::successColor(),
|
||||
);
|
||||
}
|
||||
|
||||
public function toTelegram(): array
|
||||
{
|
||||
return [
|
||||
'message' => "Coolify: Docker cleanup job succeeded on {$this->server->name}!\n\n{$this->message}",
|
||||
];
|
||||
}
|
||||
|
||||
public function toSlack(): SlackMessage
|
||||
{
|
||||
return new SlackMessage(
|
||||
title: 'Coolify: Docker cleanup job succeeded',
|
||||
description: "Docker cleanup job succeeded on '{$this->server->name}'!\n\n{$this->message}",
|
||||
color: SlackMessage::successColor()
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user