Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fancier notifications

Andras Bacsaif0d563995647
diff --git a/app/Console/Commands/Emails.php b/app/Console/Commands/Emails.php
index 36722564c5..ded729114a 100644
--- a/app/Console/Commands/Emails.php
+++ b/app/Console/Commands/Emails.php
@@ -15,7 +15,6 @@ use App\Notifications\Application\DeploymentSuccess;
use App\Notifications\Application\StatusChanged;
use App\Notifications\Database\BackupFailed;
use App\Notifications\Database\BackupSuccess;
-use App\Notifications\Database\DailyBackup;
use App\Notifications\Test;
use Exception;
use Illuminate\Console\Command;
@@ -121,23 +120,6 @@ class Emails extends Command
$this->mail = (new Test)->toMail();
$this->sendEmail();
break;
- case 'database-backup-statuses-daily':
- $scheduled_backups = ScheduledDatabaseBackup::all();
- $databases = collect();
- foreach ($scheduled_backups as $scheduled_backup) {
- $last_days_backups = $scheduled_backup->get_last_days_backup_status();
- if ($last_days_backups->isEmpty()) {
- continue;
- }
- $failed = $last_days_backups->where('status', 'failed');
- $database = $scheduled_backup->database;
- $databases->put($database->name, [
- 'failed_count' => $failed->count(),
- ]);
- }
- $this->mail = (new DailyBackup($databases))->toMail();
- $this->sendEmail();
- break;
case 'application-deployment-success-daily':
$applications = Application::all();
foreach ($applications as $application) {
diff --git a/app/Models/InstanceSettings.php b/app/Models/InstanceSettings.php
index 8ac6e892a8..339daed2ae 100644
--- a/app/Models/InstanceSettings.php
+++ b/app/Models/InstanceSettings.php
@@ -101,4 +101,17 @@ class InstanceSettings extends Model implements SendsEmail
return "[{$instanceName}]";
}
+
+ // public function helperVersion(): Attribute
+ // {
+ // return Attribute::make(
+ // get: function ($value) {
+ // if (isDev()) {
+ // return 'latest';
+ // }
+
+ // return $value;
+ // }
+ // );
+ // }
}
diff --git a/app/Notifications/Application/DeploymentFailed.php b/app/Notifications/Application/DeploymentFailed.php
index b255cc667a..242980e007 100644
--- a/app/Notifications/Application/DeploymentFailed.php
+++ b/app/Notifications/Application/DeploymentFailed.php
@@ -77,22 +77,38 @@ class DeploymentFailed extends Notification implements ShouldQueue
{
if ($this->preview) {
$message = new DiscordMessage(
- title: 'Coolify: Deployment failed of pull request #'.$this->preview->pull_request_id.' of '.$this->application_name,
- description: 'Check in the link below',
+ title: ':cross_mark: Deployment failed',
+ description: 'Pull request: '.$this->preview->pull_request_id,
color: DiscordMessage::errorColor(),
isCritical: true,
);
- $message->addField('Deployment Logs', '[Here]('.$this->deployment_url.')');
+ $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.')');
+ if ($this->fqdn) {
+ $message->addField('Domain', $this->fqdn, true);
+ }
} else {
+ if ($this->fqdn) {
+ $description = '[Open application]('.$this->fqdn.')';
+ } else {
+ $description = '';
+ }
$message = new DiscordMessage(
- title: 'Coolify: Deployment failed of '.$this->application_name,
- description: 'Check in the link below',
+ title: ':cross_mark: Deployment failed',
+ description: $description,
color: DiscordMessage::errorColor(),
isCritical: true,
);
- $message->addField('Deployment Logs', '[Here]('.$this->deployment_url.')');
+ $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.')');
}
return $message;
diff --git a/app/Notifications/Application/DeploymentSuccess.php b/app/Notifications/Application/DeploymentSuccess.php
index 96ec2ce82b..a2674ad76b 100644
--- a/app/Notifications/Application/DeploymentSuccess.php
+++ b/app/Notifications/Application/DeploymentSuccess.php
@@ -83,28 +83,35 @@ class DeploymentSuccess extends Notification implements ShouldQueue
{
if ($this->preview) {
$message = new DiscordMessage(
- title: "Coolify: New PR{$this->preview->pull_request_id} version successfully deployed of {$this->application_name}",
- description: 'Check in the links below.',
+ title: ':white_check_mark: Preview deployment successful',
+ description: 'Pull request: '.$this->preview->pull_request_id,
color: DiscordMessage::successColor(),
);
if ($this->preview->fqdn) {
- $message->addField('Open Application', '[Here]('.$this->preview->fqdn.')');
+ $message->addField('Application', '[Link]('.$this->preview->fqdn.')');
}
- $message->addField('Deployment logs', '[Here]('.$this->deployment_url.')');
+ $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.')');
} else {
+ if ($this->fqdn) {
+ $description = '[Open application]('.$this->fqdn.')';
+ } else {
+ $description = '';
+ }
$message = new DiscordMessage(
- title: "Coolify: New version successfully deployed of {$this->application_name}",
- description: 'Check in the links below.',
+ title: ':white_check_mark: New version successfully deployed',
+ description: $description,
color: DiscordMessage::successColor(),
);
+ $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);
- if ($this->fqdn) {
- $message->addField('Open Application', '[Here]('.$this->fqdn.')');
- }
-
- $message->addField('Deployment logs', '[Here]('.$this->deployment_url.')');
+ $message->addField('Deployment logs', '[Link]('.$this->deployment_url.')');
}
return $message;
diff --git a/app/Notifications/Application/StatusChanged.php b/app/Notifications/Application/StatusChanged.php
index abc93a3a4a..a080fcabef 100644
--- a/app/Notifications/Application/StatusChanged.php
+++ b/app/Notifications/Application/StatusChanged.php
@@ -59,14 +59,12 @@ class StatusChanged extends Notification implements ShouldQueue
public function toDiscord(): DiscordMessage
{
$message = new DiscordMessage(
- title: "Coolify: {$this->resource_name} has been stopped",
- description: 'Check the application in Coolify',
+ title: ':cross_mark: Application stopped',
+ description: '[Open Application in Coolify]('.$this->resource_url.')',
color: DiscordMessage::errorColor(),
isCritical: true,
);
- $message->addField('Link', '[Open Application in Coolify]('.$this->resource_url.')');
-
return $message;
}
diff --git a/app/Notifications/Container/ContainerRestarted.php b/app/Notifications/Container/ContainerRestarted.php
index 49c2cecf0c..182a1f5fc1 100644
--- a/app/Notifications/Container/ContainerRestarted.php
+++ b/app/Notifications/Container/ContainerRestarted.php
@@ -38,11 +38,15 @@ class ContainerRestarted extends Notification implements ShouldQueue
public function toDiscord(): DiscordMessage
{
$message = new DiscordMessage(
- title: "Coolify: A resource ({$this->name}) has been restarted automatically on {$this->server->name}",
- description: 'Please check the output below for more information.',
+ 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.')');
+ }
+
return $message;
}
diff --git a/app/Notifications/Container/ContainerStopped.php b/app/Notifications/Container/ContainerStopped.php
index d8ed2316b0..33a55c65a2 100644
--- a/app/Notifications/Container/ContainerStopped.php
+++ b/app/Notifications/Container/ContainerStopped.php
@@ -37,11 +37,17 @@ class ContainerStopped extends Notification implements ShouldQueue
public function toDiscord(): DiscordMessage
{
- return new DiscordMessage(
- title: "Coolify: A resource ($this->name) has been stopped unexpectedly on {$this->server->name}",
- description: 'Please check the output below for more information.',
+ $message = 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.')');
+ }
+
+ return $message;
}
public function toTelegram(): array
diff --git a/app/Notifications/Database/BackupFailed.php b/app/Notifications/Database/BackupFailed.php
index ef6128c5f8..8e2733339d 100644
--- a/app/Notifications/Database/BackupFailed.php
+++ b/app/Notifications/Database/BackupFailed.php
@@ -49,13 +49,13 @@ class BackupFailed extends Notification implements ShouldQueue
public function toDiscord(): DiscordMessage
{
$message = new DiscordMessage(
- title: "Coolify: Database backup for {$this->name} (db:{$this->database_name}) has FAILED.",
- description: 'Please check the output below for more information.',
+ 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);
+ $message->addField('Frequency', $this->frequency, true);
$message->addField('Output', $this->output);
return $message;
diff --git a/app/Notifications/Database/BackupSuccess.php b/app/Notifications/Database/BackupSuccess.php
index fa9eb616c8..4bd6b97b82 100644
--- a/app/Notifications/Database/BackupSuccess.php
+++ b/app/Notifications/Database/BackupSuccess.php
@@ -48,12 +48,12 @@ class BackupSuccess extends Notification implements ShouldQueue
public function toDiscord(): DiscordMessage
{
$message = new DiscordMessage(
- title: "Coolify: Database backup for {$this->name} (db:{$this->database_name}) was successful.",
- description: 'Please check the output below for more information.',
+ 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);
+ $message->addField('Frequency', $this->frequency, true);
return $message;
}
diff --git a/app/Notifications/Database/DailyBackup.php b/app/Notifications/Database/DailyBackup.php
deleted file mode 100644
index b53a56903c..0000000000
--- a/app/Notifications/Database/DailyBackup.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-
-namespace App\Notifications\Database;
-
-use App\Notifications\Channels\DiscordChannel;
-use App\Notifications\Channels\TelegramChannel;
-use App\Notifications\Dto\DiscordMessage;
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Notifications\Channels\MailChannel;
-use Illuminate\Notifications\Messages\MailMessage;
-use Illuminate\Notifications\Notification;
-
-class DailyBackup extends Notification implements ShouldQueue
-{
- use Queueable;
-
- public $tries = 1;
-
- public function __construct(public $databases) {}
-
- public function via(object $notifiable): array
- {
- return [DiscordChannel::class, TelegramChannel::class, MailChannel::class];
- }
-
- public function toMail(): MailMessage
- {
- $mail = new MailMessage;
- $mail->subject('Coolify: Daily backup statuses');
- $mail->view('emails.daily-backup', [
- 'databases' => $this->databases,
- ]);
-
- return $mail;
- }
-
- public function toDiscord(): DiscordMessage
- {
- return new DiscordMessage(
- title: 'Coolify: Daily backup statuses',
- description: 'Nothing to report.',
- color: DiscordMessage::infoColor(),
- ); // todo: is this necessary notification? what is the purpose of this notification?
- }
-
- public function toTelegram(): array
- {
- $message = 'Coolify: Daily backup statuses';
-
- return [
- 'message' => $message,
- ];
- }
-}
diff --git a/app/Notifications/Dto/DiscordMessage.php b/app/Notifications/Dto/DiscordMessage.php
index 0d0028f56c..856753dcae 100644
--- a/app/Notifications/Dto/DiscordMessage.php
+++ b/app/Notifications/Dto/DiscordMessage.php
@@ -33,11 +33,12 @@ class DiscordMessage
return hexdec('4f545c');
}
- public function addField(string $name, string $value): self
+ public function addField(string $name, string $value, bool $inline = false): self
{
$this->fields[] = [
'name' => $name,
'value' => $value,
+ 'inline' => $inline,
];
return $this;
@@ -45,6 +46,10 @@ class DiscordMessage
public function toPayload(): array
{
+ $footerText = 'Coolify v'.config('version');
+ if (isCloud()) {
+ $footerText = 'Coolify Cloud';
+ }
$payload = [
'embeds' => [
[
@@ -52,10 +57,12 @@ class DiscordMessage
'description' => $this->description,
'color' => $this->color,
'fields' => $this->addTimestampToFields($this->fields),
+ 'footer' => [
+ 'text' => $footerText,
+ ],
],
],
];
-
if ($this->isCritical) {
$payload['content'] = '@here';
}
@@ -68,6 +75,7 @@ class DiscordMessage
$fields[] = [
'name' => 'Time',
'value' => '<t:'.now()->timestamp.':R>',
+ 'inline' => true,
];
return $fields;
diff --git a/app/Notifications/ScheduledTask/TaskFailed.php b/app/Notifications/ScheduledTask/TaskFailed.php
index aac665fb64..2cc33f2ba3 100644
--- a/app/Notifications/ScheduledTask/TaskFailed.php
+++ b/app/Notifications/ScheduledTask/TaskFailed.php
@@ -50,12 +50,14 @@ class TaskFailed extends Notification implements ShouldQueue
public function toDiscord(): DiscordMessage
{
$message = new DiscordMessage(
- title: "Coolify: Scheduled task ({$this->task->name}) failed.",
- description: "Output: {$this->output}",
+ title: ':cross_mark: Scheduled task failed',
+ description: "Scheduled task ({$this->task->name}) failed.",
color: DiscordMessage::errorColor(),
);
- $message->addField('Link', '[Open task in Coolify]('.$this->url.')');
+ if ($this->url) {
+ $message->addField('Scheduled task', '[Link]('.$this->url.')');
+ }
return $message;
}
diff --git a/app/Notifications/Server/DockerCleanup.php b/app/Notifications/Server/DockerCleanup.php
index 68d35b15ed..7ea1b84c2f 100644
--- a/app/Notifications/Server/DockerCleanup.php
+++ b/app/Notifications/Server/DockerCleanup.php
@@ -53,7 +53,7 @@ class DockerCleanup extends Notification implements ShouldQueue
public function toDiscord(): DiscordMessage
{
return new DiscordMessage(
- title: "Coolify: Server '{$this->server->name}' cleanup job done!",
+ title: ':white_check_mark: Server cleanup job done',
description: $this->message,
color: DiscordMessage::successColor(),
);
diff --git a/app/Notifications/Server/ForceDisabled.php b/app/Notifications/Server/ForceDisabled.php
index a02228dc37..a26c803ee6 100644
--- a/app/Notifications/Server/ForceDisabled.php
+++ b/app/Notifications/Server/ForceDisabled.php
@@ -54,12 +54,12 @@ class ForceDisabled extends Notification implements ShouldQueue
public function toDiscord(): DiscordMessage
{
$message = new DiscordMessage(
- title: "Coolify: Server ({$this->server->name}) disabled because it is not paid!",
- description: 'All automations and integrations are stopped.',
+ title: ':cross_mark: Server disabled',
+ description: "Server ({$this->server->name}) disabled because it is not paid!",
color: DiscordMessage::errorColor(),
);
- $message->addField('Link', 'Please update your subscription to enable the server again [here](https://app.coolify.io/subscriptions).');
+ $message->addField('Please update your subscription to enable the server again!', '[Link](https://app.coolify.io/subscriptions)');
return $message;
}
diff --git a/app/Notifications/Server/ForceEnabled.php b/app/Notifications/Server/ForceEnabled.php
index c5c3e42b3e..65b65a10c7 100644
--- a/app/Notifications/Server/ForceEnabled.php
+++ b/app/Notifications/Server/ForceEnabled.php
@@ -54,8 +54,8 @@ class ForceEnabled extends Notification implements ShouldQueue
public function toDiscord(): DiscordMessage
{
return new DiscordMessage(
- title: "Coolify: Server '{$this->server->name}' enabled again!",
- description: 'All automations and integrations are started.',
+ title: ':white_check_mark: Server enabled',
+ description: "Server '{$this->server->name}' enabled again!",
color: DiscordMessage::successColor(),
);
}
diff --git a/app/Notifications/Server/HighDiskUsage.php b/app/Notifications/Server/HighDiskUsage.php
index c91b8c2668..54fd7b1607 100644
--- a/app/Notifications/Server/HighDiskUsage.php
+++ b/app/Notifications/Server/HighDiskUsage.php
@@ -56,14 +56,14 @@ class HighDiskUsage extends Notification implements ShouldQueue
public function toDiscord(): DiscordMessage
{
$message = new DiscordMessage(
- title: "Coolify: Server '{$this->server->name}' high disk usage detected!",
- description: 'Please cleanup your disk to prevent data-loss.',
+ title: ':cross_mark: High disk usage detected',
+ description: "Server '{$this->server->name}' high disk usage detected!",
color: DiscordMessage::errorColor(),
);
$message->addField('Disk usage', "{$this->disk_usage}%");
$message->addField('Threshold', "{$this->docker_cleanup_threshold}%");
- $message->addField('Link', 'Here are some tips: https://coolify.io/docs/knowledge-base/server/automated-cleanup.');
+ $message->addField('Tips', '[Link](https://coolify.io/docs/knowledge-base/server/automated-cleanup)');
return $message;
}
diff --git a/app/Notifications/Server/Revived.php b/app/Notifications/Server/Revived.php
index c3a3f389ae..8d1ceeaef0 100644
--- a/app/Notifications/Server/Revived.php
+++ b/app/Notifications/Server/Revived.php
@@ -76,7 +76,7 @@ class Revived extends Notification implements ShouldQueue
public function toDiscord(): DiscordMessage
{
return new DiscordMessage(
- title: "Coolify: Server '{$this->server->name}' revived.",
+ title: ":white_check_mark: Server '{$this->server->name}' revived",
description: 'All automations & integrations are turned on again!',
color: DiscordMessage::successColor(),
);
diff --git a/app/Notifications/Server/Unreachable.php b/app/Notifications/Server/Unreachable.php
index 7e56123e4f..65ea6a2ffb 100644
--- a/app/Notifications/Server/Unreachable.php
+++ b/app/Notifications/Server/Unreachable.php
@@ -67,8 +67,8 @@ class Unreachable extends Notification implements ShouldQueue
public function toDiscord(): DiscordMessage
{
$message = new DiscordMessage(
- title: "Coolify: Your server '{$this->server->name}' is unreachable.",
- description: 'All automations & integrations are turned off! Please check your server!',
+ title: ':cross_mark: Server unreachable',
+ description: "Your server '{$this->server->name}' is unreachable.",
color: DiscordMessage::errorColor(),
);
diff --git a/app/Notifications/Test.php b/app/Notifications/Test.php
index 641a99fdb9..0446f8e52f 100644
--- a/app/Notifications/Test.php
+++ b/app/Notifications/Test.php
@@ -33,12 +33,12 @@ class Test extends Notification implements ShouldQueue
public function toDiscord(): DiscordMessage
{
$message = new DiscordMessage(
- title: 'Coolify: This is a test Discord notification from Coolify.',
- description: 'This is a test Discord notification from Coolify.',
+ 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('Link', '[Go to your dashboard]('.base_url().')');
+ $message->addField(name: 'Dashboard', value: '[Link]('.base_url().')', inline: true);
return $message;
}