rector: arrrrr
This commit is contained in:
@@ -30,12 +30,12 @@ class DeploymentFailed extends CustomEmailNotification
|
||||
|
||||
public ?string $fqdn = null;
|
||||
|
||||
public function __construct(Application $application, string $deployment_uuid, ?ApplicationPreview $preview = null)
|
||||
public function __construct(Application $application, string $deployment_uuid, ?ApplicationPreview $applicationPreview = null)
|
||||
{
|
||||
$this->onQueue('high');
|
||||
$this->application = $application;
|
||||
$this->deployment_uuid = $deployment_uuid;
|
||||
$this->preview = $preview;
|
||||
$this->preview = $applicationPreview;
|
||||
$this->application_name = data_get($application, 'name');
|
||||
$this->project_uuid = data_get($application, 'environment.project.uuid');
|
||||
$this->environment_uuid = data_get($application, 'environment.uuid');
|
||||
@@ -54,28 +54,28 @@ class DeploymentFailed extends CustomEmailNotification
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mailMessage = new MailMessage;
|
||||
$pull_request_id = data_get($this->preview, 'pull_request_id', 0);
|
||||
$fqdn = $this->fqdn;
|
||||
if ($pull_request_id === 0) {
|
||||
$mail->subject('Coolify: Deployment failed of '.$this->application_name.'.');
|
||||
$mailMessage->subject('Coolify: Deployment failed of '.$this->application_name.'.');
|
||||
} else {
|
||||
$fqdn = $this->preview->fqdn;
|
||||
$mail->subject('Coolify: Deployment failed of pull request #'.$this->preview->pull_request_id.' of '.$this->application_name.'.');
|
||||
$mailMessage->subject('Coolify: Deployment failed of pull request #'.$this->preview->pull_request_id.' of '.$this->application_name.'.');
|
||||
}
|
||||
$mail->view('emails.application-deployment-failed', [
|
||||
$mailMessage->view('emails.application-deployment-failed', [
|
||||
'name' => $this->application_name,
|
||||
'fqdn' => $fqdn,
|
||||
'deployment_url' => $this->deployment_url,
|
||||
'pull_request_id' => data_get($this->preview, 'pull_request_id', 0),
|
||||
]);
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
|
||||
public function toDiscord(): DiscordMessage
|
||||
{
|
||||
if ($this->preview) {
|
||||
if ($this->preview instanceof ApplicationPreview) {
|
||||
$message = new DiscordMessage(
|
||||
title: ':cross_mark: Deployment failed',
|
||||
description: 'Pull request: '.$this->preview->pull_request_id,
|
||||
@@ -92,22 +92,16 @@ class DeploymentFailed extends CustomEmailNotification
|
||||
$message->addField('Domain', $this->fqdn, true);
|
||||
}
|
||||
} else {
|
||||
if ($this->fqdn) {
|
||||
$description = '[Open application]('.$this->fqdn.')';
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
$description = $this->fqdn ? '[Open application]('.$this->fqdn.')' : '';
|
||||
$message = new DiscordMessage(
|
||||
title: ':cross_mark: Deployment failed',
|
||||
description: $description,
|
||||
color: DiscordMessage::errorColor(),
|
||||
isCritical: true,
|
||||
);
|
||||
|
||||
$message->addField('Project', data_get($this->application, 'environment.project.name'), true);
|
||||
$message->addField('Environment', $this->environment_name, true);
|
||||
$message->addField('Name', $this->application_name, true);
|
||||
|
||||
$message->addField('Deployment Logs', '[Link]('.$this->deployment_url.')');
|
||||
}
|
||||
|
||||
@@ -116,7 +110,7 @@ class DeploymentFailed extends CustomEmailNotification
|
||||
|
||||
public function toTelegram(): array
|
||||
{
|
||||
if ($this->preview) {
|
||||
if ($this->preview instanceof ApplicationPreview) {
|
||||
$message = 'Coolify: Pull request #'.$this->preview->pull_request_id.' of '.$this->application_name.' ('.$this->preview->fqdn.') deployment failed: ';
|
||||
} else {
|
||||
$message = 'Coolify: Deployment failed of '.$this->application_name.' ('.$this->fqdn.'): ';
|
||||
@@ -136,7 +130,7 @@ class DeploymentFailed extends CustomEmailNotification
|
||||
|
||||
public function toPushover(): PushoverMessage
|
||||
{
|
||||
if ($this->preview) {
|
||||
if ($this->preview instanceof ApplicationPreview) {
|
||||
$title = "Pull request #{$this->preview->pull_request_id} deployment failed";
|
||||
$message = "Pull request deployment failed for {$this->application_name}";
|
||||
} else {
|
||||
@@ -161,7 +155,7 @@ class DeploymentFailed extends CustomEmailNotification
|
||||
|
||||
public function toSlack(): SlackMessage
|
||||
{
|
||||
if ($this->preview) {
|
||||
if ($this->preview instanceof ApplicationPreview) {
|
||||
$title = "Pull request #{$this->preview->pull_request_id} deployment failed";
|
||||
$description = "Pull request deployment failed for {$this->application_name}";
|
||||
if ($this->preview->fqdn) {
|
||||
|
||||
@@ -30,12 +30,12 @@ class DeploymentSuccess extends CustomEmailNotification
|
||||
|
||||
public ?string $fqdn;
|
||||
|
||||
public function __construct(Application $application, string $deployment_uuid, ?ApplicationPreview $preview = null)
|
||||
public function __construct(Application $application, string $deployment_uuid, ?ApplicationPreview $applicationPreview = null)
|
||||
{
|
||||
$this->onQueue('high');
|
||||
$this->application = $application;
|
||||
$this->deployment_uuid = $deployment_uuid;
|
||||
$this->preview = $preview;
|
||||
$this->preview = $applicationPreview;
|
||||
$this->application_name = data_get($application, 'name');
|
||||
$this->project_uuid = data_get($application, 'environment.project.uuid');
|
||||
$this->environment_uuid = data_get($application, 'environment.uuid');
|
||||
@@ -54,28 +54,28 @@ class DeploymentSuccess extends CustomEmailNotification
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mailMessage = new MailMessage;
|
||||
$pull_request_id = data_get($this->preview, 'pull_request_id', 0);
|
||||
$fqdn = $this->fqdn;
|
||||
if ($pull_request_id === 0) {
|
||||
$mail->subject("Coolify: New version is deployed of {$this->application_name}");
|
||||
$mailMessage->subject("Coolify: New version is deployed of {$this->application_name}");
|
||||
} else {
|
||||
$fqdn = $this->preview->fqdn;
|
||||
$mail->subject("Coolify: Pull request #{$pull_request_id} of {$this->application_name} deployed successfully");
|
||||
$mailMessage->subject("Coolify: Pull request #{$pull_request_id} of {$this->application_name} deployed successfully");
|
||||
}
|
||||
$mail->view('emails.application-deployment-success', [
|
||||
$mailMessage->view('emails.application-deployment-success', [
|
||||
'name' => $this->application_name,
|
||||
'fqdn' => $fqdn,
|
||||
'deployment_url' => $this->deployment_url,
|
||||
'pull_request_id' => $pull_request_id,
|
||||
]);
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
|
||||
public function toDiscord(): DiscordMessage
|
||||
{
|
||||
if ($this->preview) {
|
||||
if ($this->preview instanceof ApplicationPreview) {
|
||||
$message = new DiscordMessage(
|
||||
title: ':white_check_mark: Preview deployment successful',
|
||||
description: 'Pull request: '.$this->preview->pull_request_id,
|
||||
@@ -91,11 +91,7 @@ class DeploymentSuccess extends CustomEmailNotification
|
||||
$message->addField('Name', $this->application_name, true);
|
||||
$message->addField('Deployment logs', '[Link]('.$this->deployment_url.')');
|
||||
} else {
|
||||
if ($this->fqdn) {
|
||||
$description = '[Open application]('.$this->fqdn.')';
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
$description = $this->fqdn ? '[Open application]('.$this->fqdn.')' : '';
|
||||
$message = new DiscordMessage(
|
||||
title: ':white_check_mark: New version successfully deployed',
|
||||
description: $description,
|
||||
@@ -104,7 +100,6 @@ class DeploymentSuccess extends CustomEmailNotification
|
||||
$message->addField('Project', data_get($this->application, 'environment.project.name'), true);
|
||||
$message->addField('Environment', $this->environment_name, true);
|
||||
$message->addField('Name', $this->application_name, true);
|
||||
|
||||
$message->addField('Deployment logs', '[Link]('.$this->deployment_url.')');
|
||||
}
|
||||
|
||||
@@ -113,7 +108,7 @@ class DeploymentSuccess extends CustomEmailNotification
|
||||
|
||||
public function toTelegram(): array
|
||||
{
|
||||
if ($this->preview) {
|
||||
if ($this->preview instanceof ApplicationPreview) {
|
||||
$message = 'Coolify: New PR'.$this->preview->pull_request_id.' version successfully deployed of '.$this->application_name.'';
|
||||
if ($this->preview->fqdn) {
|
||||
$buttons[] = [
|
||||
@@ -145,7 +140,7 @@ class DeploymentSuccess extends CustomEmailNotification
|
||||
|
||||
public function toPushover(): PushoverMessage
|
||||
{
|
||||
if ($this->preview) {
|
||||
if ($this->preview instanceof ApplicationPreview) {
|
||||
$title = "Pull request #{$this->preview->pull_request_id} successfully deployed";
|
||||
$message = 'New PR'.$this->preview->pull_request_id.' version successfully deployed of '.$this->application_name.'';
|
||||
if ($this->preview->fqdn) {
|
||||
@@ -181,7 +176,7 @@ class DeploymentSuccess extends CustomEmailNotification
|
||||
|
||||
public function toSlack(): SlackMessage
|
||||
{
|
||||
if ($this->preview) {
|
||||
if ($this->preview instanceof ApplicationPreview) {
|
||||
$title = "Pull request #{$this->preview->pull_request_id} successfully deployed";
|
||||
$description = "New version successfully deployed for {$this->application_name}";
|
||||
if ($this->preview->fqdn) {
|
||||
|
||||
@@ -23,18 +23,18 @@ class StatusChanged extends CustomEmailNotification
|
||||
|
||||
public ?string $fqdn;
|
||||
|
||||
public function __construct(public Application $resource)
|
||||
public function __construct(public Application $application)
|
||||
{
|
||||
$this->onQueue('high');
|
||||
$this->resource_name = data_get($resource, 'name');
|
||||
$this->project_uuid = data_get($resource, 'environment.project.uuid');
|
||||
$this->environment_uuid = data_get($resource, 'environment.uuid');
|
||||
$this->environment_name = data_get($resource, 'environment.name');
|
||||
$this->fqdn = data_get($resource, 'fqdn', null);
|
||||
$this->resource_name = data_get($application, 'name');
|
||||
$this->project_uuid = data_get($application, 'environment.project.uuid');
|
||||
$this->environment_uuid = data_get($application, 'environment.uuid');
|
||||
$this->environment_name = data_get($application, 'environment.name');
|
||||
$this->fqdn = data_get($application, 'fqdn', null);
|
||||
if (str($this->fqdn)->explode(',')->count() > 1) {
|
||||
$this->fqdn = str($this->fqdn)->explode(',')->first();
|
||||
}
|
||||
$this->resource_url = base_url()."/project/{$this->project_uuid}/environments/{$this->environment_uuid}/application/{$this->resource->uuid}";
|
||||
$this->resource_url = base_url()."/project/{$this->project_uuid}/environments/{$this->environment_uuid}/application/{$this->application->uuid}";
|
||||
}
|
||||
|
||||
public function via(object $notifiable): array
|
||||
@@ -44,16 +44,16 @@ class StatusChanged extends CustomEmailNotification
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mailMessage = new MailMessage;
|
||||
$fqdn = $this->fqdn;
|
||||
$mail->subject("Coolify: {$this->resource_name} has been stopped");
|
||||
$mail->view('emails.application-status-changes', [
|
||||
$mailMessage->subject("Coolify: {$this->resource_name} has been stopped");
|
||||
$mailMessage->view('emails.application-status-changes', [
|
||||
'name' => $this->resource_name,
|
||||
'fqdn' => $fqdn,
|
||||
'resource_url' => $this->resource_url,
|
||||
]);
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
|
||||
public function toDiscord(): DiscordMessage
|
||||
@@ -103,7 +103,7 @@ class StatusChanged extends CustomEmailNotification
|
||||
$title = 'Application stopped';
|
||||
$description = "{$this->resource_name} has been stopped";
|
||||
|
||||
$description .= "\n\n**Project:** ".data_get($this->resource, 'environment.project.name');
|
||||
$description .= "\n\n**Project:** ".data_get($this->application, 'environment.project.name');
|
||||
$description .= "\n**Environment:** {$this->environment_name}";
|
||||
$description .= "\n**Application URL:** {$this->resource_url}";
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ class DiscordChannel
|
||||
/**
|
||||
* Send the given notification.
|
||||
*/
|
||||
public function send(SendsDiscord $notifiable, Notification $notification): void
|
||||
public function send(SendsDiscord $sendsDiscord, Notification $notification): void
|
||||
{
|
||||
$message = $notification->toDiscord();
|
||||
|
||||
$discordSettings = $notifiable->discordNotificationSettings;
|
||||
$discordSettings = $sendsDiscord->discordNotificationSettings;
|
||||
|
||||
if (! $discordSettings || ! $discordSettings->isEnabled() || ! $discordSettings->discord_webhook_url) {
|
||||
return;
|
||||
|
||||
@@ -9,16 +9,16 @@ use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class EmailChannel
|
||||
{
|
||||
public function send(SendsEmail $notifiable, Notification $notification): void
|
||||
public function send(SendsEmail $sendsEmail, Notification $notification): void
|
||||
{
|
||||
try {
|
||||
$this->bootConfigs($notifiable);
|
||||
$recipients = $notifiable->getRecipients($notification);
|
||||
$this->bootConfigs($sendsEmail);
|
||||
$recipients = $sendsEmail->getRecipients($notification);
|
||||
if (count($recipients) === 0) {
|
||||
throw new Exception('No email recipients found');
|
||||
}
|
||||
|
||||
$mailMessage = $notification->toMail($notifiable);
|
||||
$mailMessage = $notification->toMail($sendsEmail);
|
||||
Mail::send(
|
||||
[],
|
||||
[],
|
||||
|
||||
@@ -7,10 +7,10 @@ use Illuminate\Notifications\Notification;
|
||||
|
||||
class PushoverChannel
|
||||
{
|
||||
public function send(SendsPushover $notifiable, Notification $notification): void
|
||||
public function send(SendsPushover $sendsPushover, Notification $notification): void
|
||||
{
|
||||
$message = $notification->toPushover();
|
||||
$pushoverSettings = $notifiable->pushoverNotificationSettings;
|
||||
$pushoverSettings = $sendsPushover->pushoverNotificationSettings;
|
||||
|
||||
if (! $pushoverSettings || ! $pushoverSettings->isEnabled() || ! $pushoverSettings->pushover_user_key || ! $pushoverSettings->pushover_api_token) {
|
||||
return;
|
||||
|
||||
@@ -10,10 +10,10 @@ class SlackChannel
|
||||
/**
|
||||
* Send the given notification.
|
||||
*/
|
||||
public function send(SendsSlack $notifiable, Notification $notification): void
|
||||
public function send(SendsSlack $sendsSlack, Notification $notification): void
|
||||
{
|
||||
$message = $notification->toSlack();
|
||||
$slackSettings = $notifiable->slackNotificationSettings;
|
||||
$slackSettings = $sendsSlack->slackNotificationSettings;
|
||||
|
||||
if (! $slackSettings || ! $slackSettings->isEnabled() || ! $slackSettings->slack_webhook_url) {
|
||||
return;
|
||||
|
||||
@@ -3,6 +3,20 @@
|
||||
namespace App\Notifications\Channels;
|
||||
|
||||
use App\Jobs\SendMessageToTelegramJob;
|
||||
use App\Notifications\Application\DeploymentFailed;
|
||||
use App\Notifications\Application\DeploymentSuccess;
|
||||
use App\Notifications\Application\StatusChanged;
|
||||
use App\Notifications\Container\ContainerRestarted;
|
||||
use App\Notifications\Container\ContainerStopped;
|
||||
use App\Notifications\Database\BackupFailed;
|
||||
use App\Notifications\Database\BackupSuccess;
|
||||
use App\Notifications\ScheduledTask\TaskFailed;
|
||||
use App\Notifications\ScheduledTask\TaskSuccess;
|
||||
use App\Notifications\Server\DockerCleanupFailed;
|
||||
use App\Notifications\Server\DockerCleanupSuccess;
|
||||
use App\Notifications\Server\HighDiskUsage;
|
||||
use App\Notifications\Server\Reachable;
|
||||
use App\Notifications\Server\Unreachable;
|
||||
|
||||
class TelegramChannel
|
||||
{
|
||||
@@ -17,23 +31,23 @@ class TelegramChannel
|
||||
$chatId = $settings->telegram_chat_id;
|
||||
|
||||
$threadId = match (get_class($notification)) {
|
||||
\App\Notifications\Application\DeploymentSuccess::class => $settings->telegram_notifications_deployment_success_thread_id,
|
||||
\App\Notifications\Application\DeploymentFailed::class => $settings->telegram_notifications_deployment_failure_thread_id,
|
||||
\App\Notifications\Application\StatusChanged::class,
|
||||
\App\Notifications\Container\ContainerRestarted::class,
|
||||
\App\Notifications\Container\ContainerStopped::class => $settings->telegram_notifications_status_change_thread_id,
|
||||
DeploymentSuccess::class => $settings->telegram_notifications_deployment_success_thread_id,
|
||||
DeploymentFailed::class => $settings->telegram_notifications_deployment_failure_thread_id,
|
||||
StatusChanged::class,
|
||||
ContainerRestarted::class,
|
||||
ContainerStopped::class => $settings->telegram_notifications_status_change_thread_id,
|
||||
|
||||
\App\Notifications\Database\BackupSuccess::class => $settings->telegram_notifications_backup_success_thread_id,
|
||||
\App\Notifications\Database\BackupFailed::class => $settings->telegram_notifications_backup_failure_thread_id,
|
||||
BackupSuccess::class => $settings->telegram_notifications_backup_success_thread_id,
|
||||
BackupFailed::class => $settings->telegram_notifications_backup_failure_thread_id,
|
||||
|
||||
\App\Notifications\ScheduledTask\TaskSuccess::class => $settings->telegram_notifications_scheduled_task_success_thread_id,
|
||||
\App\Notifications\ScheduledTask\TaskFailed::class => $settings->telegram_notifications_scheduled_task_failure_thread_id,
|
||||
TaskSuccess::class => $settings->telegram_notifications_scheduled_task_success_thread_id,
|
||||
TaskFailed::class => $settings->telegram_notifications_scheduled_task_failure_thread_id,
|
||||
|
||||
\App\Notifications\Server\DockerCleanupSuccess::class => $settings->telegram_notifications_docker_cleanup_success_thread_id,
|
||||
\App\Notifications\Server\DockerCleanupFailed::class => $settings->telegram_notifications_docker_cleanup_failure_thread_id,
|
||||
\App\Notifications\Server\HighDiskUsage::class => $settings->telegram_notifications_server_disk_usage_thread_id,
|
||||
\App\Notifications\Server\Unreachable::class => $settings->telegram_notifications_server_unreachable_thread_id,
|
||||
\App\Notifications\Server\Reachable::class => $settings->telegram_notifications_server_reachable_thread_id,
|
||||
DockerCleanupSuccess::class => $settings->telegram_notifications_docker_cleanup_success_thread_id,
|
||||
DockerCleanupFailed::class => $settings->telegram_notifications_docker_cleanup_failure_thread_id,
|
||||
HighDiskUsage::class => $settings->telegram_notifications_server_disk_usage_thread_id,
|
||||
Unreachable::class => $settings->telegram_notifications_server_unreachable_thread_id,
|
||||
Reachable::class => $settings->telegram_notifications_server_reachable_thread_id,
|
||||
|
||||
default => null,
|
||||
};
|
||||
|
||||
@@ -10,18 +10,18 @@ use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class TransactionalEmailChannel
|
||||
{
|
||||
public function send(User $notifiable, Notification $notification): void
|
||||
public function send(User $user, Notification $notification): void
|
||||
{
|
||||
$settings = instanceSettings();
|
||||
if (! data_get($settings, 'smtp_enabled') && ! data_get($settings, 'resend_enabled')) {
|
||||
return;
|
||||
}
|
||||
$email = $notifiable->email;
|
||||
$email = $user->email;
|
||||
if (! $email) {
|
||||
return;
|
||||
}
|
||||
$this->bootConfigs();
|
||||
$mailMessage = $notification->toMail($notifiable);
|
||||
$mailMessage = $notification->toMail($user);
|
||||
Mail::send(
|
||||
[],
|
||||
[],
|
||||
|
||||
@@ -23,30 +23,30 @@ class ContainerRestarted extends CustomEmailNotification
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mail->subject("Coolify: A resource ({$this->name}) has been restarted automatically on {$this->server->name}");
|
||||
$mail->view('emails.container-restarted', [
|
||||
$mailMessage = new MailMessage;
|
||||
$mailMessage->subject("Coolify: A resource ({$this->name}) has been restarted automatically on {$this->server->name}");
|
||||
$mailMessage->view('emails.container-restarted', [
|
||||
'containerName' => $this->name,
|
||||
'serverName' => $this->server->name,
|
||||
'url' => $this->url,
|
||||
]);
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
|
||||
public function toDiscord(): DiscordMessage
|
||||
{
|
||||
$message = new DiscordMessage(
|
||||
$discordMessage = new DiscordMessage(
|
||||
title: ':warning: Resource restarted',
|
||||
description: "{$this->name} has been restarted automatically on {$this->server->name}.",
|
||||
color: DiscordMessage::infoColor(),
|
||||
);
|
||||
|
||||
if ($this->url) {
|
||||
$message->addField('Resource', '[Link]('.$this->url.')');
|
||||
$discordMessage->addField('Resource', '[Link]('.$this->url.')');
|
||||
}
|
||||
|
||||
return $message;
|
||||
return $discordMessage;
|
||||
}
|
||||
|
||||
public function toTelegram(): array
|
||||
|
||||
@@ -23,30 +23,30 @@ class ContainerStopped extends CustomEmailNotification
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mail->subject("Coolify: A resource has been stopped unexpectedly on {$this->server->name}");
|
||||
$mail->view('emails.container-stopped', [
|
||||
$mailMessage = new MailMessage;
|
||||
$mailMessage->subject("Coolify: A resource has been stopped unexpectedly on {$this->server->name}");
|
||||
$mailMessage->view('emails.container-stopped', [
|
||||
'containerName' => $this->name,
|
||||
'serverName' => $this->server->name,
|
||||
'url' => $this->url,
|
||||
]);
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
|
||||
public function toDiscord(): DiscordMessage
|
||||
{
|
||||
$message = new DiscordMessage(
|
||||
$discordMessage = new DiscordMessage(
|
||||
title: ':cross_mark: Resource stopped',
|
||||
description: "{$this->name} has been stopped unexpectedly on {$this->server->name}.",
|
||||
color: DiscordMessage::errorColor(),
|
||||
);
|
||||
|
||||
if ($this->url) {
|
||||
$message->addField('Resource', '[Link]('.$this->url.')');
|
||||
$discordMessage->addField('Resource', '[Link]('.$this->url.')');
|
||||
}
|
||||
|
||||
return $message;
|
||||
return $discordMessage;
|
||||
}
|
||||
|
||||
public function toTelegram(): array
|
||||
@@ -87,7 +87,6 @@ class ContainerStopped extends CustomEmailNotification
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function toSlack(): SlackMessage
|
||||
{
|
||||
$title = 'Resource stopped';
|
||||
|
||||
@@ -15,11 +15,11 @@ class BackupFailed extends CustomEmailNotification
|
||||
|
||||
public string $frequency;
|
||||
|
||||
public function __construct(ScheduledDatabaseBackup $backup, public $database, public $output, public $database_name)
|
||||
public function __construct(ScheduledDatabaseBackup $scheduledDatabaseBackup, public $database, public $output, public $database_name)
|
||||
{
|
||||
$this->onQueue('high');
|
||||
$this->name = $database->name;
|
||||
$this->frequency = $backup->frequency;
|
||||
$this->frequency = $scheduledDatabaseBackup->frequency;
|
||||
}
|
||||
|
||||
public function via(object $notifiable): array
|
||||
@@ -29,31 +29,31 @@ class BackupFailed extends CustomEmailNotification
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mail->subject("Coolify: [ACTION REQUIRED] Database Backup FAILED for {$this->database->name}");
|
||||
$mail->view('emails.backup-failed', [
|
||||
$mailMessage = new MailMessage;
|
||||
$mailMessage->subject("Coolify: [ACTION REQUIRED] Database Backup FAILED for {$this->database->name}");
|
||||
$mailMessage->view('emails.backup-failed', [
|
||||
'name' => $this->name,
|
||||
'database_name' => $this->database_name,
|
||||
'frequency' => $this->frequency,
|
||||
'output' => $this->output,
|
||||
]);
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
|
||||
public function toDiscord(): DiscordMessage
|
||||
{
|
||||
$message = new DiscordMessage(
|
||||
$discordMessage = new DiscordMessage(
|
||||
title: ':cross_mark: Database backup failed',
|
||||
description: "Database backup for {$this->name} (db:{$this->database_name}) has FAILED.",
|
||||
color: DiscordMessage::errorColor(),
|
||||
isCritical: true,
|
||||
);
|
||||
|
||||
$message->addField('Frequency', $this->frequency, true);
|
||||
$message->addField('Output', $this->output);
|
||||
$discordMessage->addField('Frequency', $this->frequency, true);
|
||||
$discordMessage->addField('Output', $this->output);
|
||||
|
||||
return $message;
|
||||
return $discordMessage;
|
||||
}
|
||||
|
||||
public function toTelegram(): array
|
||||
|
||||
@@ -15,12 +15,12 @@ class BackupSuccess extends CustomEmailNotification
|
||||
|
||||
public string $frequency;
|
||||
|
||||
public function __construct(ScheduledDatabaseBackup $backup, public $database, public $database_name)
|
||||
public function __construct(ScheduledDatabaseBackup $scheduledDatabaseBackup, public $database, public $database_name)
|
||||
{
|
||||
$this->onQueue('high');
|
||||
|
||||
$this->name = $database->name;
|
||||
$this->frequency = $backup->frequency;
|
||||
$this->frequency = $scheduledDatabaseBackup->frequency;
|
||||
}
|
||||
|
||||
public function via(object $notifiable): array
|
||||
@@ -30,28 +30,28 @@ class BackupSuccess extends CustomEmailNotification
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mail->subject("Coolify: Backup successfully done for {$this->database->name}");
|
||||
$mail->view('emails.backup-success', [
|
||||
$mailMessage = new MailMessage;
|
||||
$mailMessage->subject("Coolify: Backup successfully done for {$this->database->name}");
|
||||
$mailMessage->view('emails.backup-success', [
|
||||
'name' => $this->name,
|
||||
'database_name' => $this->database_name,
|
||||
'frequency' => $this->frequency,
|
||||
]);
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
|
||||
public function toDiscord(): DiscordMessage
|
||||
{
|
||||
$message = new DiscordMessage(
|
||||
$discordMessage = new DiscordMessage(
|
||||
title: ':white_check_mark: Database backup successful',
|
||||
description: "Database backup for {$this->name} (db:{$this->database_name}) was successful.",
|
||||
color: DiscordMessage::successColor(),
|
||||
);
|
||||
|
||||
$message->addField('Frequency', $this->frequency, true);
|
||||
$discordMessage->addField('Frequency', $this->frequency, true);
|
||||
|
||||
return $message;
|
||||
return $discordMessage;
|
||||
}
|
||||
|
||||
public function toTelegram(): array
|
||||
@@ -63,7 +63,6 @@ class BackupSuccess extends CustomEmailNotification
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function toPushover(): PushoverMessage
|
||||
{
|
||||
return new PushoverMessage(
|
||||
@@ -73,7 +72,6 @@ class BackupSuccess extends CustomEmailNotification
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function toSlack(): SlackMessage
|
||||
{
|
||||
$title = 'Database backup successful';
|
||||
|
||||
@@ -13,13 +13,13 @@ class TaskFailed extends CustomEmailNotification
|
||||
{
|
||||
public ?string $url = null;
|
||||
|
||||
public function __construct(public ScheduledTask $task, public string $output)
|
||||
public function __construct(public ScheduledTask $scheduledTask, public string $output)
|
||||
{
|
||||
$this->onQueue('high');
|
||||
if ($task->application) {
|
||||
$this->url = $task->application->taskLink($task->uuid);
|
||||
} elseif ($task->service) {
|
||||
$this->url = $task->service->taskLink($task->uuid);
|
||||
if ($scheduledTask->application) {
|
||||
$this->url = $scheduledTask->application->taskLink($scheduledTask->uuid);
|
||||
} elseif ($scheduledTask->service) {
|
||||
$this->url = $scheduledTask->service->taskLink($scheduledTask->uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,39 +30,39 @@ class TaskFailed extends CustomEmailNotification
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mail->subject("Coolify: [ACTION REQUIRED] Scheduled task ({$this->task->name}) failed.");
|
||||
$mail->view('emails.scheduled-task-failed', [
|
||||
'task' => $this->task,
|
||||
$mailMessage = new MailMessage;
|
||||
$mailMessage->subject("Coolify: [ACTION REQUIRED] Scheduled task ({$this->scheduledTask->name}) failed.");
|
||||
$mailMessage->view('emails.scheduled-task-failed', [
|
||||
'task' => $this->scheduledTask,
|
||||
'url' => $this->url,
|
||||
'output' => $this->output,
|
||||
]);
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
|
||||
public function toDiscord(): DiscordMessage
|
||||
{
|
||||
$message = new DiscordMessage(
|
||||
$discordMessage = new DiscordMessage(
|
||||
title: ':cross_mark: Scheduled task failed',
|
||||
description: "Scheduled task ({$this->task->name}) failed.",
|
||||
description: "Scheduled task ({$this->scheduledTask->name}) failed.",
|
||||
color: DiscordMessage::errorColor(),
|
||||
);
|
||||
|
||||
if ($this->url) {
|
||||
$message->addField('Scheduled task', '[Link]('.$this->url.')');
|
||||
$discordMessage->addField('Scheduled task', '[Link]('.$this->url.')');
|
||||
}
|
||||
|
||||
return $message;
|
||||
return $discordMessage;
|
||||
}
|
||||
|
||||
public function toTelegram(): array
|
||||
{
|
||||
$message = "Coolify: Scheduled task ({$this->task->name}) failed with output: {$this->output}";
|
||||
$message = "Coolify: Scheduled task ({$this->scheduledTask->name}) failed with output: {$this->output}";
|
||||
if ($this->url) {
|
||||
$buttons[] = [
|
||||
'text' => 'Open task in Coolify',
|
||||
'url' => (string) $this->url,
|
||||
'url' => $this->url,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -73,9 +73,9 @@ class TaskFailed extends CustomEmailNotification
|
||||
|
||||
public function toPushover(): PushoverMessage
|
||||
{
|
||||
$message = "Scheduled task ({$this->task->name}) failed<br/>";
|
||||
$message = "Scheduled task ({$this->scheduledTask->name}) failed<br/>";
|
||||
|
||||
if ($this->output) {
|
||||
if ($this->output !== '' && $this->output !== '0') {
|
||||
$message .= "<br/><b>Error Output:</b>{$this->output}";
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ class TaskFailed extends CustomEmailNotification
|
||||
if ($this->url) {
|
||||
$buttons[] = [
|
||||
'text' => 'Open task in Coolify',
|
||||
'url' => (string) $this->url,
|
||||
'url' => $this->url,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -98,9 +98,9 @@ class TaskFailed extends CustomEmailNotification
|
||||
public function toSlack(): SlackMessage
|
||||
{
|
||||
$title = 'Scheduled task failed';
|
||||
$description = "Scheduled task ({$this->task->name}) failed.";
|
||||
$description = "Scheduled task ({$this->scheduledTask->name}) failed.";
|
||||
|
||||
if ($this->output) {
|
||||
if ($this->output !== '' && $this->output !== '0') {
|
||||
$description .= "\n\n**Error Output:**\n{$this->output}";
|
||||
}
|
||||
|
||||
|
||||
@@ -13,13 +13,13 @@ class TaskSuccess extends CustomEmailNotification
|
||||
{
|
||||
public ?string $url = null;
|
||||
|
||||
public function __construct(public ScheduledTask $task, public string $output)
|
||||
public function __construct(public ScheduledTask $scheduledTask, public string $output)
|
||||
{
|
||||
$this->onQueue('high');
|
||||
if ($task->application) {
|
||||
$this->url = $task->application->taskLink($task->uuid);
|
||||
} elseif ($task->service) {
|
||||
$this->url = $task->service->taskLink($task->uuid);
|
||||
if ($scheduledTask->application) {
|
||||
$this->url = $scheduledTask->application->taskLink($scheduledTask->uuid);
|
||||
} elseif ($scheduledTask->service) {
|
||||
$this->url = $scheduledTask->service->taskLink($scheduledTask->uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,39 +30,39 @@ class TaskSuccess extends CustomEmailNotification
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mail->subject("Coolify: Scheduled task ({$this->task->name}) succeeded.");
|
||||
$mail->view('emails.scheduled-task-success', [
|
||||
'task' => $this->task,
|
||||
$mailMessage = new MailMessage;
|
||||
$mailMessage->subject("Coolify: Scheduled task ({$this->scheduledTask->name}) succeeded.");
|
||||
$mailMessage->view('emails.scheduled-task-success', [
|
||||
'task' => $this->scheduledTask,
|
||||
'url' => $this->url,
|
||||
'output' => $this->output,
|
||||
]);
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
|
||||
public function toDiscord(): DiscordMessage
|
||||
{
|
||||
$message = new DiscordMessage(
|
||||
$discordMessage = new DiscordMessage(
|
||||
title: ':white_check_mark: Scheduled task succeeded',
|
||||
description: "Scheduled task ({$this->task->name}) succeeded.",
|
||||
description: "Scheduled task ({$this->scheduledTask->name}) succeeded.",
|
||||
color: DiscordMessage::successColor(),
|
||||
);
|
||||
|
||||
if ($this->url) {
|
||||
$message->addField('Scheduled task', '[Link]('.$this->url.')');
|
||||
$discordMessage->addField('Scheduled task', '[Link]('.$this->url.')');
|
||||
}
|
||||
|
||||
return $message;
|
||||
return $discordMessage;
|
||||
}
|
||||
|
||||
public function toTelegram(): array
|
||||
{
|
||||
$message = "Coolify: Scheduled task ({$this->task->name}) succeeded.";
|
||||
$message = "Coolify: Scheduled task ({$this->scheduledTask->name}) succeeded.";
|
||||
if ($this->url) {
|
||||
$buttons[] = [
|
||||
'text' => 'Open task in Coolify',
|
||||
'url' => (string) $this->url,
|
||||
'url' => $this->url,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -73,12 +73,12 @@ class TaskSuccess extends CustomEmailNotification
|
||||
|
||||
public function toPushover(): PushoverMessage
|
||||
{
|
||||
$message = "Coolify: Scheduled task ({$this->task->name}) succeeded.";
|
||||
$message = "Coolify: Scheduled task ({$this->scheduledTask->name}) succeeded.";
|
||||
$buttons = [];
|
||||
if ($this->url) {
|
||||
$buttons[] = [
|
||||
'text' => 'Open task in Coolify',
|
||||
'url' => (string) $this->url,
|
||||
'url' => $this->url,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class TaskSuccess extends CustomEmailNotification
|
||||
public function toSlack(): SlackMessage
|
||||
{
|
||||
$title = 'Scheduled task succeeded';
|
||||
$description = "Scheduled task ({$this->task->name}) succeeded.";
|
||||
$description = "Scheduled task ({$this->scheduledTask->name}) succeeded.";
|
||||
|
||||
if ($this->url) {
|
||||
$description .= "\n\n**Task URL:** {$this->url}";
|
||||
|
||||
@@ -23,14 +23,14 @@ class DockerCleanupFailed extends CustomEmailNotification
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mail->subject("Coolify: [ACTION REQUIRED] Docker cleanup job failed on {$this->server->name}");
|
||||
$mail->view('emails.docker-cleanup-failed', [
|
||||
$mailMessage = new MailMessage;
|
||||
$mailMessage->subject("Coolify: [ACTION REQUIRED] Docker cleanup job failed on {$this->server->name}");
|
||||
$mailMessage->view('emails.docker-cleanup-failed', [
|
||||
'name' => $this->server->name,
|
||||
'text' => $this->message,
|
||||
]);
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
|
||||
public function toDiscord(): DiscordMessage
|
||||
|
||||
@@ -23,14 +23,14 @@ class DockerCleanupSuccess extends CustomEmailNotification
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mail->subject("Coolify: Docker cleanup job succeeded on {$this->server->name}");
|
||||
$mail->view('emails.docker-cleanup-success', [
|
||||
$mailMessage = new MailMessage;
|
||||
$mailMessage->subject("Coolify: Docker cleanup job succeeded on {$this->server->name}");
|
||||
$mailMessage->view('emails.docker-cleanup-success', [
|
||||
'name' => $this->server->name,
|
||||
'text' => $this->message,
|
||||
]);
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
|
||||
public function toDiscord(): DiscordMessage
|
||||
|
||||
@@ -23,26 +23,26 @@ class ForceDisabled extends CustomEmailNotification
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mail->subject("Coolify: Server ({$this->server->name}) disabled because it is not paid!");
|
||||
$mail->view('emails.server-force-disabled', [
|
||||
$mailMessage = new MailMessage;
|
||||
$mailMessage->subject("Coolify: Server ({$this->server->name}) disabled because it is not paid!");
|
||||
$mailMessage->view('emails.server-force-disabled', [
|
||||
'name' => $this->server->name,
|
||||
]);
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
|
||||
public function toDiscord(): DiscordMessage
|
||||
{
|
||||
$message = new DiscordMessage(
|
||||
$discordMessage = new DiscordMessage(
|
||||
title: ':cross_mark: Server disabled',
|
||||
description: "Server ({$this->server->name}) disabled because it is not paid!",
|
||||
color: DiscordMessage::errorColor(),
|
||||
);
|
||||
|
||||
$message->addField('Please update your subscription to enable the server again!', '[Link](https://app.coolify.io/subscriptions)');
|
||||
$discordMessage->addField('Please update your subscription to enable the server again!', '[Link](https://app.coolify.io/subscriptions)');
|
||||
|
||||
return $message;
|
||||
return $discordMessage;
|
||||
}
|
||||
|
||||
public function toTelegram(): array
|
||||
|
||||
@@ -23,13 +23,13 @@ class ForceEnabled extends CustomEmailNotification
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mail->subject("Coolify: Server ({$this->server->name}) enabled again!");
|
||||
$mail->view('emails.server-force-enabled', [
|
||||
$mailMessage = new MailMessage;
|
||||
$mailMessage->subject("Coolify: Server ({$this->server->name}) enabled again!");
|
||||
$mailMessage->view('emails.server-force-enabled', [
|
||||
'name' => $this->server->name,
|
||||
]);
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
|
||||
public function toDiscord(): DiscordMessage
|
||||
|
||||
@@ -23,32 +23,32 @@ class HighDiskUsage extends CustomEmailNotification
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mail->subject("Coolify: Server ({$this->server->name}) high disk usage detected!");
|
||||
$mail->view('emails.high-disk-usage', [
|
||||
$mailMessage = new MailMessage;
|
||||
$mailMessage->subject("Coolify: Server ({$this->server->name}) high disk usage detected!");
|
||||
$mailMessage->view('emails.high-disk-usage', [
|
||||
'name' => $this->server->name,
|
||||
'disk_usage' => $this->disk_usage,
|
||||
'threshold' => $this->server_disk_usage_notification_threshold,
|
||||
]);
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
|
||||
public function toDiscord(): DiscordMessage
|
||||
{
|
||||
$message = new DiscordMessage(
|
||||
$discordMessage = new DiscordMessage(
|
||||
title: ':cross_mark: High disk usage detected',
|
||||
description: "Server '{$this->server->name}' high disk usage detected!",
|
||||
color: DiscordMessage::errorColor(),
|
||||
isCritical: true,
|
||||
);
|
||||
|
||||
$message->addField('Disk usage', "{$this->disk_usage}%", true);
|
||||
$message->addField('Threshold', "{$this->server_disk_usage_notification_threshold}%", true);
|
||||
$message->addField('What to do?', '[Link](https://coolify.io/docs/knowledge-base/server/automated-cleanup)', true);
|
||||
$message->addField('Change Settings', '[Threshold]('.base_url().'/server/'.$this->server->uuid.'#advanced) | [Notification]('.base_url().'/notifications/discord)');
|
||||
$discordMessage->addField('Disk usage', "{$this->disk_usage}%", true);
|
||||
$discordMessage->addField('Threshold', "{$this->server_disk_usage_notification_threshold}%", true);
|
||||
$discordMessage->addField('What to do?', '[Link](https://coolify.io/docs/knowledge-base/server/automated-cleanup)', true);
|
||||
$discordMessage->addField('Change Settings', '[Threshold]('.base_url().'/server/'.$this->server->uuid.'#advanced) | [Notification]('.base_url().'/notifications/discord)');
|
||||
|
||||
return $message;
|
||||
return $discordMessage;
|
||||
}
|
||||
|
||||
public function toTelegram(): array
|
||||
@@ -65,8 +65,8 @@ class HighDiskUsage extends CustomEmailNotification
|
||||
level: 'warning',
|
||||
message: "Server '{$this->server->name}' high disk usage detected!<br/><br/><b>Disk usage:</b> {$this->disk_usage}%.<br/><b>Threshold:</b> {$this->server_disk_usage_notification_threshold}%.<br/>Please cleanup your disk to prevent data-loss.",
|
||||
buttons: [
|
||||
'Change settings' => base_url().'/server/'.$this->server->uuid."#advanced",
|
||||
'Tips for cleanup' => "https://coolify.io/docs/knowledge-base/server/automated-cleanup",
|
||||
'Change settings' => base_url().'/server/'.$this->server->uuid.'#advanced',
|
||||
'Tips for cleanup' => 'https://coolify.io/docs/knowledge-base/server/automated-cleanup',
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -32,13 +32,13 @@ class Reachable extends CustomEmailNotification
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mail->subject("Coolify: Server ({$this->server->name}) revived.");
|
||||
$mail->view('emails.server-revived', [
|
||||
$mailMessage = new MailMessage;
|
||||
$mailMessage->subject("Coolify: Server ({$this->server->name}) revived.");
|
||||
$mailMessage->view('emails.server-revived', [
|
||||
'name' => $this->server->name,
|
||||
]);
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
|
||||
public function toDiscord(): DiscordMessage
|
||||
|
||||
@@ -32,26 +32,26 @@ class Unreachable extends CustomEmailNotification
|
||||
|
||||
public function toMail(): ?MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mail->subject("Coolify: Your server ({$this->server->name}) is unreachable.");
|
||||
$mail->view('emails.server-lost-connection', [
|
||||
$mailMessage = new MailMessage;
|
||||
$mailMessage->subject("Coolify: Your server ({$this->server->name}) is unreachable.");
|
||||
$mailMessage->view('emails.server-lost-connection', [
|
||||
'name' => $this->server->name,
|
||||
]);
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
|
||||
public function toDiscord(): ?DiscordMessage
|
||||
{
|
||||
$message = new DiscordMessage(
|
||||
$discordMessage = new DiscordMessage(
|
||||
title: ':cross_mark: Server unreachable',
|
||||
description: "Your server '{$this->server->name}' is unreachable.",
|
||||
color: DiscordMessage::errorColor(),
|
||||
);
|
||||
|
||||
$message->addField('IMPORTANT', 'We automatically try to revive your server and turn on all automations & integrations.');
|
||||
$discordMessage->addField('IMPORTANT', 'We automatically try to revive your server and turn on all automations & integrations.');
|
||||
|
||||
return $message;
|
||||
return $discordMessage;
|
||||
}
|
||||
|
||||
public function toTelegram(): ?array
|
||||
|
||||
@@ -4,9 +4,9 @@ namespace App\Notifications;
|
||||
|
||||
use App\Notifications\Channels\DiscordChannel;
|
||||
use App\Notifications\Channels\EmailChannel;
|
||||
use App\Notifications\Channels\PushoverChannel;
|
||||
use App\Notifications\Channels\SlackChannel;
|
||||
use App\Notifications\Channels\TelegramChannel;
|
||||
use App\Notifications\Channels\PushoverChannel;
|
||||
use App\Notifications\Dto\DiscordMessage;
|
||||
use App\Notifications\Dto\PushoverMessage;
|
||||
use App\Notifications\Dto\SlackMessage;
|
||||
@@ -30,7 +30,7 @@ class Test extends Notification implements ShouldQueue
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
if ($this->channel) {
|
||||
$channels = match ($this->channel) {
|
||||
return match ($this->channel) {
|
||||
'email' => [EmailChannel::class],
|
||||
'discord' => [DiscordChannel::class],
|
||||
'telegram' => [TelegramChannel::class],
|
||||
@@ -38,11 +38,9 @@ class Test extends Notification implements ShouldQueue
|
||||
'pushover' => [PushoverChannel::class],
|
||||
default => [],
|
||||
};
|
||||
} else {
|
||||
$channels = $notifiable->getEnabledChannels('test');
|
||||
}
|
||||
|
||||
return $channels;
|
||||
return $notifiable->getEnabledChannels('test');
|
||||
}
|
||||
|
||||
public function middleware(object $notifiable, string $channel)
|
||||
@@ -55,24 +53,24 @@ class Test extends Notification implements ShouldQueue
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mail->subject('Coolify: Test Email');
|
||||
$mail->view('emails.test');
|
||||
$mailMessage = new MailMessage;
|
||||
$mailMessage->subject('Coolify: Test Email');
|
||||
$mailMessage->view('emails.test');
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
|
||||
public function toDiscord(): DiscordMessage
|
||||
{
|
||||
$message = new DiscordMessage(
|
||||
$discordMessage = new DiscordMessage(
|
||||
title: ':white_check_mark: Test Success',
|
||||
description: 'This is a test Discord notification from Coolify. :cross_mark: :warning: :information_source:',
|
||||
color: DiscordMessage::successColor(),
|
||||
);
|
||||
|
||||
$message->addField(name: 'Dashboard', value: '[Link]('.base_url().')', inline: true);
|
||||
$discordMessage->addField(name: 'Dashboard', value: '[Link]('.base_url().')', inline: true);
|
||||
|
||||
return $message;
|
||||
return $discordMessage;
|
||||
}
|
||||
|
||||
public function toTelegram(): array
|
||||
|
||||
@@ -24,16 +24,16 @@ class InvitationLink extends CustomEmailNotification
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$invitation = TeamInvitation::whereEmail($this->user->email)->first();
|
||||
$invitation_team = Team::find($invitation->team->id);
|
||||
$invitation_team = Team::query()->find($invitation->team->id);
|
||||
|
||||
$mail = new MailMessage;
|
||||
$mail->subject('Coolify: Invitation for '.$invitation_team->name);
|
||||
$mail->view('emails.invitation-link', [
|
||||
$mailMessage = new MailMessage;
|
||||
$mailMessage->subject('Coolify: Invitation for '.$invitation_team->name);
|
||||
$mailMessage->view('emails.invitation-link', [
|
||||
'team' => $invitation_team->name,
|
||||
'email' => $this->user->email,
|
||||
'invitation_link' => $invitation->link,
|
||||
]);
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Notifications\TransactionalEmails;
|
||||
|
||||
use App\Models\InstanceSettings;
|
||||
use Exception;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
@@ -36,7 +37,7 @@ class ResetPassword extends Notification
|
||||
{
|
||||
$type = set_transanctional_email_settings();
|
||||
if (! $type) {
|
||||
throw new \Exception('No email settings found.');
|
||||
throw new Exception('No email settings found.');
|
||||
}
|
||||
|
||||
return ['mail'];
|
||||
@@ -53,11 +54,11 @@ class ResetPassword extends Notification
|
||||
|
||||
protected function buildMailMessage($url)
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mail->subject('Coolify: Reset Password');
|
||||
$mail->view('emails.reset-password', ['url' => $url, 'count' => config('auth.passwords.'.config('auth.defaults.passwords').'.expire')]);
|
||||
$mailMessage = new MailMessage;
|
||||
$mailMessage->subject('Coolify: Reset Password');
|
||||
$mailMessage->view('emails.reset-password', ['url' => $url, 'count' => config('auth.passwords.'.config('auth.defaults.passwords').'.expire')]);
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
|
||||
protected function resetUrl($notifiable)
|
||||
|
||||
@@ -20,10 +20,10 @@ class Test extends CustomEmailNotification
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mail->subject('Coolify: Test Email');
|
||||
$mail->view('emails.test');
|
||||
$mailMessage = new MailMessage;
|
||||
$mailMessage->subject('Coolify: Test Email');
|
||||
$mailMessage->view('emails.test');
|
||||
|
||||
return $mail;
|
||||
return $mailMessage;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user