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.

Merge branch 'next' into feat/deployment-token

Andras Bacsai78f0ac80c139
diff --cc app/Livewire/Notifications/Slack.php
index 0000000000,edd32a071e..06b7643ea9
mode 000000,100644..100644
--- a/app/Livewire/Notifications/Slack.php
+++ b/app/Livewire/Notifications/Slack.php
@@@ -1,0 -1,130 +1,131 @@@
+ <?php
+
+ namespace App\Livewire\Notifications;
+
+ use App\Models\Team;
+ use App\Notifications\Test;
+ use Livewire\Attributes\Validate;
+ use Livewire\Component;
+
+ class Slack extends Component
+ {
+ public Team $team;
+
+ #[Validate(['boolean'])]
+ public bool $slackEnabled = false;
+
+ #[Validate(['url', 'nullable'])]
+ public ?string $slackWebhookUrl = null;
+
+ #[Validate(['boolean'])]
+ public bool $slackNotificationsTest = false;
+
+ #[Validate(['boolean'])]
+ public bool $slackNotificationsDeployments = false;
+
+ #[Validate(['boolean'])]
+ public bool $slackNotificationsStatusChanges = false;
+
+ #[Validate(['boolean'])]
+ public bool $slackNotificationsDatabaseBackups = false;
+
+ #[Validate(['boolean'])]
+ public bool $slackNotificationsScheduledTasks = false;
+
+ #[Validate(['boolean'])]
+ public bool $slackNotificationsServerDiskUsage = false;
+
+ public function mount()
+ {
+ try {
+ $this->team = auth()->user()->currentTeam();
+ $this->syncData();
+ } catch (\Throwable $e) {
+ return handleError($e, $this);
+ }
+ }
+
+ public function syncData(bool $toModel = false)
+ {
+ if ($toModel) {
+ $this->validate();
+ $this->team->slack_enabled = $this->slackEnabled;
+ $this->team->slack_webhook_url = $this->slackWebhookUrl;
+ $this->team->slack_notifications_test = $this->slackNotificationsTest;
+ $this->team->slack_notifications_deployments = $this->slackNotificationsDeployments;
+ $this->team->slack_notifications_status_changes = $this->slackNotificationsStatusChanges;
+ $this->team->slack_notifications_database_backups = $this->slackNotificationsDatabaseBackups;
+ $this->team->slack_notifications_scheduled_tasks = $this->slackNotificationsScheduledTasks;
+ $this->team->slack_notifications_server_disk_usage = $this->slackNotificationsServerDiskUsage;
+ $this->team->save();
+ refreshSession();
+ } else {
+ $this->slackEnabled = $this->team->slack_enabled;
+ $this->slackWebhookUrl = $this->team->slack_webhook_url;
+ $this->slackNotificationsTest = $this->team->slack_notifications_test;
+ $this->slackNotificationsDeployments = $this->team->slack_notifications_deployments;
+ $this->slackNotificationsStatusChanges = $this->team->slack_notifications_status_changes;
+ $this->slackNotificationsDatabaseBackups = $this->team->slack_notifications_database_backups;
+ $this->slackNotificationsScheduledTasks = $this->team->slack_notifications_scheduled_tasks;
+ $this->slackNotificationsServerDiskUsage = $this->team->slack_notifications_server_disk_usage;
+ }
+ }
+
+ public function instantSaveSlackEnabled()
+ {
+ try {
+ $this->validate([
+ 'slackWebhookUrl' => 'required',
+ ], [
+ 'slackWebhookUrl.required' => 'Slack Webhook URL is required.',
+ ]);
+ $this->saveModel();
+ } catch (\Throwable $e) {
+ $this->slackEnabled = false;
++
+ return handleError($e, $this);
+ }
+ }
+
+ public function instantSave()
+ {
+ try {
+ $this->syncData(true);
+ } catch (\Throwable $e) {
+ return handleError($e, $this);
+ }
+ }
+
+ public function submit()
+ {
+ try {
+ $this->resetErrorBag();
+ $this->syncData(true);
+ $this->saveModel();
+ } catch (\Throwable $e) {
+ return handleError($e, $this);
+ }
+ }
+
+ public function saveModel()
+ {
+ $this->syncData(true);
+ refreshSession();
+ $this->dispatch('success', 'Settings saved.');
+ }
+
+ public function sendTestNotification()
+ {
+ try {
+ $this->team->notify(new Test);
+ $this->dispatch('success', 'Test notification sent.');
+ } catch (\Throwable $e) {
+ return handleError($e, $this);
+ }
+ }
+
+ public function render()
+ {
+ return view('livewire.notifications.slack');
+ }
-}
++}
diff --cc app/Notifications/Application/DeploymentFailed.php
index 242980e007,cdcec3261e..7648aaac24
--- a/app/Notifications/Application/DeploymentFailed.php
+++ b/app/Notifications/Application/DeploymentFailed.php
@@@ -133,4 -129,31 +129,31 @@@ class DeploymentFailed extends CustomEm
],
];
}
+
+ public function toSlack(): SlackMessage
+ {
+ if ($this->preview) {
+ $title = "Pull request #{$this->preview->pull_request_id} deployment failed";
+ $description = "Pull request deployment failed for {$this->application_name}";
+ if ($this->preview->fqdn) {
+ $description .= "\nPreview URL: {$this->preview->fqdn}";
+ }
+ } else {
- $title = "Deployment failed";
++ $title = 'Deployment failed';
+ $description = "Deployment failed for {$this->application_name}";
+ if ($this->fqdn) {
+ $description .= "\nApplication URL: {$this->fqdn}";
+ }
+ }
+
- $description .= "\n\n**Project:** " . data_get($this->application, 'environment.project.name');
++ $description .= "\n\n**Project:** ".data_get($this->application, 'environment.project.name');
+ $description .= "\n**Environment:** {$this->environment_name}";
+ $description .= "\n**Deployment Logs:** {$this->deployment_url}";
+
+ return new SlackMessage(
+ title: $title,
+ description: $description,
+ color: SlackMessage::errorColor()
+ );
+ }
}
diff --cc app/Notifications/Application/DeploymentSuccess.php
index 946a622ca5,565bce0a5c..79ae19f66e
--- a/app/Notifications/Application/DeploymentSuccess.php
+++ b/app/Notifications/Application/DeploymentSuccess.php
@@@ -4,18 -4,13 +4,13 @@@ namespace App\Notifications\Application
use App\Models\Application;
use App\Models\ApplicationPreview;
+ use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Notifications\Messages\MailMessage;
+ use App\Notifications\Dto\SlackMessage;
+use Illuminate\Notifications\Messages\MailMessage;
- use Illuminate\Notifications\Notification;
- class DeploymentSuccess extends Notification implements ShouldQueue
+ class DeploymentSuccess extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 1;
-
public Application $application;
public ?ApplicationPreview $preview = null;
@@@ -148,4 -144,32 +144,31 @@@
],
];
}
+
-
+ public function toSlack(): SlackMessage
+ {
+ if ($this->preview) {
+ $title = "Pull request #{$this->preview->pull_request_id} successfully deployed";
+ $description = "New version successfully deployed for {$this->application_name}";
+ if ($this->preview->fqdn) {
+ $description .= "\nPreview URL: {$this->preview->fqdn}";
+ }
+ } else {
- $title = "New version successfully deployed";
++ $title = 'New version successfully deployed';
+ $description = "New version successfully deployed for {$this->application_name}";
+ if ($this->fqdn) {
+ $description .= "\nApplication URL: {$this->fqdn}";
+ }
+ }
+
- $description .= "\n\n**Project:** " . data_get($this->application, 'environment.project.name');
++ $description .= "\n\n**Project:** ".data_get($this->application, 'environment.project.name');
+ $description .= "\n**Environment:** {$this->environment_name}";
+ $description .= "\n**Deployment Logs:** {$this->deployment_url}";
+
+ return new SlackMessage(
+ title: $title,
+ description: $description,
+ color: SlackMessage::successColor()
+ );
+ }
}
diff --cc app/Notifications/Application/StatusChanged.php
index 852c6b5260,18c042ca6c..2167e9f13f
--- a/app/Notifications/Application/StatusChanged.php
+++ b/app/Notifications/Application/StatusChanged.php
@@@ -3,18 -3,13 +3,13 @@@
namespace App\Notifications\Application;
use App\Models\Application;
+ use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Notifications\Messages\MailMessage;
+ use App\Notifications\Dto\SlackMessage;
+use Illuminate\Notifications\Messages\MailMessage;
- use Illuminate\Notifications\Notification;
- class StatusChanged extends Notification implements ShouldQueue
+ class StatusChanged extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 1;
-
public string $resource_name;
public string $project_uuid;
@@@ -80,4 -76,20 +76,20 @@@
],
];
}
+
+ public function toSlack(): SlackMessage
+ {
- $title = "Application stopped";
++ $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->resource, 'environment.project.name');
+ $description .= "\n**Environment:** {$this->environment_name}";
+ $description .= "\n**Application URL:** {$this->resource_url}";
+
+ return new SlackMessage(
+ title: $title,
+ description: $description,
+ color: SlackMessage::errorColor()
+ );
+ }
}
diff --cc app/Notifications/Channels/SendsSlack.php
index 0000000000,417d4adda3..ab2dd6f116
mode 000000,100644..100644
--- a/app/Notifications/Channels/SendsSlack.php
+++ b/app/Notifications/Channels/SendsSlack.php
@@@ -1,0 -1,8 +1,8 @@@
+ <?php
+
+ namespace App\Notifications\Channels;
+
+ interface SendsSlack
+ {
+ public function routeNotificationForSlack();
-}
++}
diff --cc app/Notifications/Container/ContainerRestarted.php
index 182a1f5fc1,e1cf836ff7..f9becd0e80
--- a/app/Notifications/Container/ContainerRestarted.php
+++ b/app/Notifications/Container/ContainerRestarted.php
@@@ -3,19 -3,17 +3,17 @@@
namespace App\Notifications\Container;
use App\Models\Server;
+ use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Notifications\Messages\MailMessage;
+ use App\Notifications\Dto\SlackMessage;
+use Illuminate\Notifications\Messages\MailMessage;
- use Illuminate\Notifications\Notification;
- class ContainerRestarted extends Notification implements ShouldQueue
+ class ContainerRestarted extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 1;
-
- public function __construct(public string $name, public Server $server, public ?string $url = null) {}
+ public function __construct(public string $name, public Server $server, public ?string $url = null)
+ {
+ $this->onQueue('high');
+ }
public function via(object $notifiable): array
{
@@@ -69,4 -67,20 +67,20 @@@
return $payload;
}
+
+ public function toSlack(): SlackMessage
+ {
- $title = "Resource restarted";
++ $title = 'Resource restarted';
+ $description = "A resource ({$this->name}) has been restarted automatically on {$this->server->name}";
+
+ if ($this->url) {
+ $description .= "\n**Resource URL:** {$this->url}";
+ }
+
+ return new SlackMessage(
+ title: $title,
+ description: $description,
+ color: SlackMessage::warningColor()
+ );
+ }
}
diff --cc app/Notifications/Container/ContainerStopped.php
index 33a55c65a2,76c2dae802..eae2cf5523
--- a/app/Notifications/Container/ContainerStopped.php
+++ b/app/Notifications/Container/ContainerStopped.php
@@@ -3,19 -3,17 +3,17 @@@
namespace App\Notifications\Container;
use App\Models\Server;
+ use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Notifications\Messages\MailMessage;
+ use App\Notifications\Dto\SlackMessage;
+use Illuminate\Notifications\Messages\MailMessage;
- use Illuminate\Notifications\Notification;
- class ContainerStopped extends Notification implements ShouldQueue
+ class ContainerStopped extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 1;
-
- public function __construct(public string $name, public Server $server, public ?string $url = null) {}
+ public function __construct(public string $name, public Server $server, public ?string $url = null)
+ {
+ $this->onQueue('high');
+ }
public function via(object $notifiable): array
{
@@@ -69,4 -67,20 +67,20 @@@
return $payload;
}
+
+ public function toSlack(): SlackMessage
+ {
- $title = "Resource stopped";
++ $title = 'Resource stopped';
+ $description = "A resource ({$this->name}) has been stopped unexpectedly on {$this->server->name}";
+
+ if ($this->url) {
+ $description .= "\n**Resource URL:** {$this->url}";
+ }
+
+ return new SlackMessage(
+ title: $title,
+ description: $description,
+ color: SlackMessage::errorColor()
+ );
+ }
}
diff --cc app/Notifications/Database/BackupFailed.php
index 8e2733339d,a1b5c42e5d..2056255d60
--- a/app/Notifications/Database/BackupFailed.php
+++ b/app/Notifications/Database/BackupFailed.php
@@@ -3,20 -3,13 +3,13 @@@
namespace App\Notifications\Database;
use App\Models\ScheduledDatabaseBackup;
+ use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Notifications\Messages\MailMessage;
+ use App\Notifications\Dto\SlackMessage;
+use Illuminate\Notifications\Messages\MailMessage;
- use Illuminate\Notifications\Notification;
- class BackupFailed extends Notification implements ShouldQueue
+ class BackupFailed extends CustomEmailNotification
{
- use Queueable;
-
- public $backoff = 10;
-
- public $tries = 2;
-
public string $name;
public string $frequency;
@@@ -69,4 -63,19 +63,19 @@@
'message' => $message,
];
}
+
+ public function toSlack(): SlackMessage
+ {
- $title = "Database backup failed";
++ $title = 'Database backup failed';
+ $description = "Database backup for {$this->name} (db:{$this->database_name}) has FAILED.";
+
+ $description .= "\n\n**Frequency:** {$this->frequency}";
+ $description .= "\n\n**Error Output:**\n{$this->output}";
+
+ return new SlackMessage(
+ title: $title,
+ description: $description,
+ color: SlackMessage::errorColor()
+ );
+ }
}
diff --cc app/Notifications/Database/BackupSuccess.php
index 5128c8ed66,f2aa247a6f..71866f9fce
--- a/app/Notifications/Database/BackupSuccess.php
+++ b/app/Notifications/Database/BackupSuccess.php
@@@ -3,20 -3,13 +3,13 @@@
namespace App\Notifications\Database;
use App\Models\ScheduledDatabaseBackup;
+ use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Notifications\Messages\MailMessage;
+ use App\Notifications\Dto\SlackMessage;
+use Illuminate\Notifications\Messages\MailMessage;
- use Illuminate\Notifications\Notification;
- class BackupSuccess extends Notification implements ShouldQueue
+ class BackupSuccess extends CustomEmailNotification
{
- use Queueable;
-
- public $backoff = 10;
-
- public $tries = 3;
-
public string $name;
public string $frequency;
@@@ -66,4 -61,18 +61,18 @@@
'message' => $message,
];
}
+
+ public function toSlack(): SlackMessage
+ {
- $title = "Database backup successful";
++ $title = 'Database backup successful';
+ $description = "Database backup for {$this->name} (db:{$this->database_name}) was successful.";
+
+ $description .= "\n\n**Frequency:** {$this->frequency}";
+
+ return new SlackMessage(
+ title: $title,
+ description: $description,
+ color: SlackMessage::successColor()
+ );
+ }
}
diff --cc app/Notifications/Dto/SlackMessage.php
index 0000000000,86532c65bf..879bf65472
mode 000000,100644..100644
--- a/app/Notifications/Dto/SlackMessage.php
+++ b/app/Notifications/Dto/SlackMessage.php
@@@ -1,0 -1,33 +1,32 @@@
+ <?php
+
+ namespace App\Notifications\Dto;
+
+ class SlackMessage
+ {
+ public function __construct(
+ public string $title,
+ public string $description,
+ public string $color = '#0099ff'
- ) {
- }
++ ) {}
+
+ public static function infoColor(): string
+ {
+ return '#0099ff';
+ }
+
+ public static function errorColor(): string
+ {
+ return '#ff0000';
+ }
+
+ public static function successColor(): string
+ {
+ return '#00ff00';
+ }
+
+ public static function warningColor(): string
+ {
+ return '#ffa500';
+ }
-}
++}
diff --cc app/Notifications/Internal/GeneralNotification.php
index 48e7d8340c,699291d16b..347f4a0dd6
--- a/app/Notifications/Internal/GeneralNotification.php
+++ b/app/Notifications/Internal/GeneralNotification.php
@@@ -3,8 -3,10 +3,10 @@@
namespace App\Notifications\Internal;
use App\Notifications\Channels\DiscordChannel;
-use App\Notifications\Channels\TelegramChannel;
+ use App\Notifications\Channels\SlackChannel;
+use App\Notifications\Channels\TelegramChannel;
use App\Notifications\Dto\DiscordMessage;
+ use App\Notifications\Dto\SlackMessage;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
diff --cc app/Notifications/ScheduledTask/TaskFailed.php
index c3501a8eb4,53b7f46a3e..753da7ff0a
--- a/app/Notifications/ScheduledTask/TaskFailed.php
+++ b/app/Notifications/ScheduledTask/TaskFailed.php
@@@ -3,20 -3,13 +3,13 @@@
namespace App\Notifications\ScheduledTask;
use App\Models\ScheduledTask;
+ use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Notifications\Messages\MailMessage;
+ use App\Notifications\Dto\SlackMessage;
+use Illuminate\Notifications\Messages\MailMessage;
- use Illuminate\Notifications\Notification;
- class TaskFailed extends Notification implements ShouldQueue
+ class TaskFailed extends CustomEmailNotification
{
- use Queueable;
-
- public $backoff = 10;
-
- public $tries = 2;
-
public ?string $url = null;
public function __construct(public ScheduledTask $task, public string $output)
@@@ -75,4 -69,24 +69,24 @@@
'message' => $message,
];
}
+
+ public function toSlack(): SlackMessage
+ {
- $title = "Scheduled task failed";
++ $title = 'Scheduled task failed';
+ $description = "Scheduled task ({$this->task->name}) failed.";
+
+ if ($this->output) {
+ $description .= "\n\n**Error Output:**\n{$this->output}";
+ }
+
+ if ($this->url) {
+ $description .= "\n\n**Task URL:** {$this->url}";
+ }
+
+ return new SlackMessage(
+ title: $title,
+ description: $description,
+ color: SlackMessage::errorColor()
+ );
+ }
}
diff --cc app/Notifications/Server/ForceDisabled.php
index a26c803ee6,1939170f6b..143917ddec
--- a/app/Notifications/Server/ForceDisabled.php
+++ b/app/Notifications/Server/ForceDisabled.php
@@@ -5,20 -5,19 +5,19 @@@ namespace App\Notifications\Server
use App\Models\Server;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\EmailChannel;
-use App\Notifications\Channels\TelegramChannel;
+ use App\Notifications\Channels\SlackChannel;
-use App\Notifications\Dto\SlackMessage;
+use App\Notifications\Channels\TelegramChannel;
+ use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
++use App\Notifications\Dto\SlackMessage;
use Illuminate\Notifications\Messages\MailMessage;
- use Illuminate\Notifications\Notification;
- class ForceDisabled extends Notification implements ShouldQueue
+ class ForceDisabled extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 1;
-
- public function __construct(public Server $server) {}
+ public function __construct(public Server $server)
+ {
+ $this->onQueue('high');
+ }
public function via(object $notifiable): array
{
@@@ -70,4 -72,19 +72,18 @@@
'message' => "Coolify: Server ({$this->server->name}) disabled because it is not paid!\n All automations and integrations are stopped.\nPlease update your subscription to enable the server again [here](https://app.coolify.io/subscriptions).",
];
}
+
-
+ public function toSlack(): SlackMessage
+ {
- $title = "Server disabled";
++ $title = 'Server disabled';
+ $description = "Server ({$this->server->name}) disabled because it is not paid!\n";
+ $description .= "All automations and integrations are stopped.\n\n";
- $description .= "Please update your subscription to enable the server again: https://app.coolify.io/subscriptions";
++ $description .= 'Please update your subscription to enable the server again: https://app.coolify.io/subscriptions';
+
+ return new SlackMessage(
+ title: $title,
+ description: $description,
+ color: SlackMessage::errorColor()
+ );
+ }
}
diff --cc app/Notifications/Server/ForceEnabled.php
index 65b65a10c7,4b6181e192..3b83882d8b
--- a/app/Notifications/Server/ForceEnabled.php
+++ b/app/Notifications/Server/ForceEnabled.php
@@@ -5,20 -5,19 +5,19 @@@ namespace App\Notifications\Server
use App\Models\Server;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\EmailChannel;
-use App\Notifications\Channels\TelegramChannel;
+ use App\Notifications\Channels\SlackChannel;
-use App\Notifications\Dto\SlackMessage;
+use App\Notifications\Channels\TelegramChannel;
+ use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
++use App\Notifications\Dto\SlackMessage;
use Illuminate\Notifications\Messages\MailMessage;
- use Illuminate\Notifications\Notification;
- class ForceEnabled extends Notification implements ShouldQueue
+ class ForceEnabled extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 1;
-
- public function __construct(public Server $server) {}
+ public function __construct(public Server $server)
+ {
+ $this->onQueue('high');
+ }
public function via(object $notifiable): array
{
@@@ -66,4 -68,15 +68,13 @@@
'message' => "Coolify: Server ({$this->server->name}) enabled again!",
];
}
+
-
+ public function toSlack(): SlackMessage
+ {
+ return new SlackMessage(
+ title: 'Server enabled',
+ description: "Server '{$this->server->name}' enabled again!",
+ color: SlackMessage::successColor()
+ );
+ }
-
}
diff --cc app/Notifications/Server/HighDiskUsage.php
index e373abc031,40c0e2cb6d..baff495081
--- a/app/Notifications/Server/HighDiskUsage.php
+++ b/app/Notifications/Server/HighDiskUsage.php
@@@ -58,4 -56,22 +56,22 @@@ class HighDiskUsage extends CustomEmail
'message' => "Coolify: Server '{$this->server->name}' high disk usage detected!\nDisk usage: {$this->disk_usage}%. Threshold: {$this->server_disk_usage_notification_threshold}%.\nPlease cleanup your disk to prevent data-loss.\nHere are some tips: https://coolify.io/docs/knowledge-base/server/automated-cleanup.",
];
}
+
+ public function toSlack(): SlackMessage
+ {
+ $description = "Server '{$this->server->name}' high disk usage detected!\n";
+ $description .= "Disk usage: {$this->disk_usage}%\n";
+ $description .= "Threshold: {$this->server_disk_usage_notification_threshold}%\n\n";
+ $description .= "Please cleanup your disk to prevent data-loss.\n";
+ $description .= "Tips for cleanup: https://coolify.io/docs/knowledge-base/server/automated-cleanup\n";
+ $description .= "Change settings:\n";
- $description .= "- Threshold: " . base_url() . "/server/" . $this->server->uuid . "#advanced\n";
- $description .= "- Notifications: " . base_url() . "/notifications/discord";
++ $description .= '- Threshold: '.base_url().'/server/'.$this->server->uuid."#advanced\n";
++ $description .= '- Notifications: '.base_url().'/notifications/discord';
+
+ return new SlackMessage(
+ title: 'High disk usage detected',
+ description: $description,
+ color: SlackMessage::errorColor()
+ );
+ }
}
diff --cc app/Notifications/Server/Reachable.php
index 9b54501d94,a0dfd1cc52..62ece34e8c
--- a/app/Notifications/Server/Reachable.php
+++ b/app/Notifications/Server/Reachable.php
@@@ -5,25 -5,22 +5,22 @@@ namespace App\Notifications\Server
use App\Models\Server;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\EmailChannel;
-use App\Notifications\Channels\TelegramChannel;
+ use App\Notifications\Channels\SlackChannel;
-use App\Notifications\Dto\SlackMessage;
+use App\Notifications\Channels\TelegramChannel;
+ use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
++use App\Notifications\Dto\SlackMessage;
use Illuminate\Notifications\Messages\MailMessage;
- use Illuminate\Notifications\Notification;
- class Reachable extends Notification implements ShouldQueue
+ class Reachable extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 1;
-
protected bool $isRateLimited = false;
public function __construct(public Server $server)
{
+ $this->onQueue('high');
$this->isRateLimited = isEmailRateLimited(
- limiterKey: 'server-reachable:' . $this->server->id,
+ limiterKey: 'server-reachable:'.$this->server->id,
);
}
@@@ -77,4 -77,16 +77,13 @@@
'message' => "Coolify: Server '{$this->server->name}' revived. All automations & integrations are turned on again!",
];
}
+
-
-
-
+ public function toSlack(): SlackMessage
+ {
+ return new SlackMessage(
- title: "Server revived",
++ title: 'Server revived',
+ description: "Server '{$this->server->name}' revived.\nAll automations & integrations are turned on again!",
+ color: SlackMessage::successColor()
+ );
+ }
}
diff --cc app/Notifications/Server/Unreachable.php
index 5bc568e829,0bd44ef3de..2a90d7552d
--- a/app/Notifications/Server/Unreachable.php
+++ b/app/Notifications/Server/Unreachable.php
@@@ -5,25 -5,22 +5,22 @@@ namespace App\Notifications\Server
use App\Models\Server;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\EmailChannel;
-use App\Notifications\Channels\TelegramChannel;
+ use App\Notifications\Channels\SlackChannel;
-use App\Notifications\Dto\SlackMessage;
+use App\Notifications\Channels\TelegramChannel;
+ use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
++use App\Notifications\Dto\SlackMessage;
use Illuminate\Notifications\Messages\MailMessage;
- use Illuminate\Notifications\Notification;
- class Unreachable extends Notification implements ShouldQueue
+ class Unreachable extends CustomEmailNotification
{
- use Queueable;
-
- public $tries = 1;
-
protected bool $isRateLimited = false;
public function __construct(public Server $server)
{
+ $this->onQueue('high');
$this->isRateLimited = isEmailRateLimited(
- limiterKey: 'server-unreachable:' . $this->server->id,
+ limiterKey: 'server-unreachable:'.$this->server->id,
);
}
@@@ -81,4 -82,18 +82,17 @@@
'message' => "Coolify: Your server '{$this->server->name}' is unreachable. All automations & integrations are turned off! Please check your server! IMPORTANT: We automatically try to revive your server and turn on all automations & integrations.",
];
}
+
-
+ public function toSlack(): SlackMessage
+ {
+ $description = "Your server '{$this->server->name}' is unreachable.\n";
+ $description .= "All automations & integrations are turned off!\n\n";
- $description .= "*IMPORTANT:* We automatically try to revive your server and turn on all automations & integrations.";
++ $description .= '*IMPORTANT:* We automatically try to revive your server and turn on all automations & integrations.';
+
+ return new SlackMessage(
+ title: 'Server unreachable',
+ description: $description,
+ color: SlackMessage::errorColor()
+ );
+ }
}
diff --cc app/View/Components/Forms/Checkbox.php
index 8abe96c1bc,0bdebe7e44..e46598e8e9
--- a/app/View/Components/Forms/Checkbox.php
+++ b/app/View/Components/Forms/Checkbox.php
@@@ -15,9 -15,9 +15,10 @@@ class Checkbox extends Componen
public ?string $id = null,
public ?string $name = null,
public ?string $value = null,
+ public ?string $domValue = null,
public ?string $label = null,
public ?string $helper = null,
+ public string|bool|null $checked = false,
public string|bool $instantSave = false,
public bool $disabled = false,
public string $defaultClass = 'dark:border-neutral-700 text-coolgray-400 focus:ring-warning dark:bg-coolgray-100 rounded cursor-pointer dark:disabled:bg-base dark:disabled:cursor-not-allowed',
diff --cc bootstrap/helpers/shared.php
index fb4ae36997,40c5acb217..835ead24c2
--- a/bootstrap/helpers/shared.php
+++ b/bootstrap/helpers/shared.php
@@@ -85,11 -88,34 +88,34 @@@ function backup_dir(): strin
}
function metrics_dir(): string
{
- return base_configuration_dir() . '/metrics';
+ return base_configuration_dir().'/metrics';
}
+ function sanitize_string(?string $input = null): ?string
+ {
+ if (is_null($input)) {
+ return null;
+ }
+ // Remove any HTML/PHP tags
+ $sanitized = strip_tags($input);
+
+ // Convert special characters to HTML entities
+ $sanitized = htmlspecialchars($sanitized, ENT_QUOTES | ENT_HTML5, 'UTF-8');
+
+ // Remove any control characters
+ $sanitized = preg_replace('/[\x00-\x1F\x7F]/u', '', $sanitized);
+
+ // Trim whitespace
+ $sanitized = trim($sanitized);
+
+ return $sanitized;
+ }
+
function generate_readme_file(string $name, string $updated_at): string
{
+ $name = sanitize_string($name);
+ $updated_at = sanitize_string($updated_at);
+
return "Resource name: $name\nLatest Deployment Date: $updated_at";
}
@@@ -113,15 -139,15 +139,15 @@@ function showBoarding(): boo
}
function refreshSession(?Team $team = null): void
{
- if (!$team) {
+ if (! $team) {
- if (auth()->user()?->currentTeam()) {
- $team = Team::find(auth()->user()->currentTeam()->id);
+ if (Auth::user()->currentTeam()) {
+ $team = Team::find(Auth::user()->currentTeam()->id);
} else {
- $team = User::find(auth()->user()->id)->teams->first();
+ $team = User::find(Auth::id())->teams->first();
}
}
- Cache::forget('team:'.auth()->user()->id);
- Cache::remember('team:'.auth()->user()->id, 3600, function () use ($team) {
- Cache::forget('team:' . Auth::id());
- Cache::remember('team:' . Auth::id(), 3600, function () use ($team) {
++ Cache::forget('team:'.Auth::id());
++ Cache::remember('team:'.Auth::id(), 3600, function () use ($team) {
return $team;
});
session(['currentTeam' => $team]);
diff --cc resources/views/livewire/security/api-tokens.blade.php
index 3ff52417f7,1bcd647103..b3ef9241be
--- a/resources/views/livewire/security/api-tokens.blade.php
+++ b/resources/views/livewire/security/api-tokens.blade.php
@@@ -30,15 -34,11 +30,20 @@@
@endif
</div>
</div>
+ @if (in_array('write', $permissions))
+ <div class="font-bold text-warning">Root access, be careful!</div>
+ @endif
<h4>Token Permissions</h4>
<div class="w-64">
- <x-forms.checkbox label="read" wire:model.live="permissions" domValue="read" :checked="in_array('read', $permissions)"></x-forms.checkbox>
- <x-forms.checkbox label="read:sensitive" wire:model.live="permissions" domValue="read:sensitive" helper="Responses will include secrets, logs, passwords, and compose file contents" :checked="in_array('read:sensitive', $permissions)"></x-forms.checkbox>
- <x-forms.checkbox label="write" wire:model.live="permissions" domValue="write" helper="Root access, be careful!" :checked="in_array('write', $permissions)"></x-forms.checkbox>
- <x-forms.checkbox label="deploy" wire:model.live="permissions" domValue="deploy" helper="Can trigger deploy webhooks" :checked="in_array('deploy', $permissions)"></x-forms.checkbox>
- <x-forms.checkbox label="Root Access" wire:model.live="rootAccess"></x-forms.checkbox>
- <x-forms.checkbox label="Read-only" wire:model.live="readOnly"></x-forms.checkbox>
- <x-forms.checkbox label="View Sensitive Data" wire:model.live="viewSensitiveData"></x-forms.checkbox>
++ <x-forms.checkbox label="read" wire:model.live="permissions" value="read"
++ :checked="in_array('read', $permissions)"></x-forms.checkbox>
++ <x-forms.checkbox label="read:sensitive" wire:model.live="permissions" value="read:sensitive"
++ helper="Responses will include secrets, logs, passwords, and compose file contents"
++ :checked="in_array('read:sensitive', $permissions)"></x-forms.checkbox>
++ <x-forms.checkbox label="write" wire:model.live="permissions" value="write"
++ helper="Root access, be careful!" :checked="in_array('write', $permissions)"></x-forms.checkbox>
++ <x-forms.checkbox label="deploy" wire:model.live="permissions" value="deploy"
++ helper="Can trigger deploy webhooks" :checked="in_array('deploy', $permissions)"></x-forms.checkbox>
</div>
</form>
@if (session()->has('token'))
diff --cc routes/web.php
index 6ea3bc8578,d8ba925f2c..f7bec5be5c
--- a/routes/web.php
+++ b/routes/web.php
@@@ -12,8 -12,8 +12,8 @@@ use App\Livewire\Destination\Show as De
use App\Livewire\ForcePasswordReset;
use App\Livewire\Notifications\Discord as NotificationDiscord;
use App\Livewire\Notifications\Email as NotificationEmail;
-use App\Livewire\Notifications\Telegram as NotificationTelegram;
+ use App\Livewire\Notifications\Slack as NotificationSlack;
+use App\Livewire\Notifications\Telegram as NotificationTelegram;
use App\Livewire\Profile\Index as ProfileIndex;
use App\Livewire\Project\Application\Configuration as ApplicationConfiguration;
use App\Livewire\Project\Application\Deployment\Index as DeploymentIndex;