Fix styling

This commit is contained in:
Thijmen
2024-06-10 20:43:34 +00:00
committed by github-actions[bot]
parent 41fb6a1fc9
commit d86274cc37
429 changed files with 5307 additions and 2831 deletions

View File

@@ -15,15 +15,21 @@ class DeploymentFailed extends Notification implements ShouldQueue
use Queueable;
public $tries = 1;
public Application $application;
public ?ApplicationPreview $preview = null;
public string $deployment_uuid;
public string $application_name;
public string $project_uuid;
public string $environment_name;
public ?string $deployment_url = null;
public ?string $fqdn = null;
public function __construct(Application $application, string $deployment_uuid, ?ApplicationPreview $preview = null)
@@ -38,7 +44,7 @@ class DeploymentFailed extends Notification implements ShouldQueue
if (Str::of($this->fqdn)->explode(',')->count() > 1) {
$this->fqdn = Str::of($this->fqdn)->explode(',')->first();
}
$this->deployment_url = base_url() . "/project/{$this->project_uuid}/" . urlencode($this->environment_name) . "/application/{$this->application->uuid}/deployment/{$this->deployment_uuid}";
$this->deployment_url = base_url()."/project/{$this->project_uuid}/".urlencode($this->environment_name)."/application/{$this->application->uuid}/deployment/{$this->deployment_uuid}";
}
public function via(object $notifiable): array
@@ -52,10 +58,10 @@ class DeploymentFailed extends Notification implements ShouldQueue
$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 . '.');
$mail->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 . '.');
$mail->subject('Coolify: Deployment failed of pull request #'.$this->preview->pull_request_id.' of '.$this->application_name.'.');
}
$mail->view('emails.application-deployment-failed', [
'name' => $this->application_name,
@@ -63,35 +69,39 @@ class DeploymentFailed extends Notification implements ShouldQueue
'deployment_url' => $this->deployment_url,
'pull_request_id' => data_get($this->preview, 'pull_request_id', 0),
]);
return $mail;
}
public function toDiscord(): string
{
if ($this->preview) {
$message = 'Coolify: Pull request #' . $this->preview->pull_request_id . ' of ' . $this->application_name . ' (' . $this->preview->fqdn . ') deployment failed: ';
$message .= '[View Deployment Logs](' . $this->deployment_url . ')';
$message = 'Coolify: Pull request #'.$this->preview->pull_request_id.' of '.$this->application_name.' ('.$this->preview->fqdn.') deployment failed: ';
$message .= '[View Deployment Logs]('.$this->deployment_url.')';
} else {
$message = 'Coolify: Deployment failed of ' . $this->application_name . ' (' . $this->fqdn . '): ';
$message .= '[View Deployment Logs](' . $this->deployment_url . ')';
$message = 'Coolify: Deployment failed of '.$this->application_name.' ('.$this->fqdn.'): ';
$message .= '[View Deployment Logs]('.$this->deployment_url.')';
}
return $message;
}
public function toTelegram(): array
{
if ($this->preview) {
$message = 'Coolify: Pull request #' . $this->preview->pull_request_id . ' of ' . $this->application_name . ' (' . $this->preview->fqdn . ') deployment failed: ';
$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 . '): ';
$message = 'Coolify: Deployment failed of '.$this->application_name.' ('.$this->fqdn.'): ';
}
$buttons[] = [
"text" => "Deployment logs",
"url" => $this->deployment_url
'text' => 'Deployment logs',
'url' => $this->deployment_url,
];
return [
"message" => $message,
"buttons" => [
...$buttons
'message' => $message,
'buttons' => [
...$buttons,
],
];
}

View File

@@ -15,18 +15,24 @@ class DeploymentSuccess extends Notification implements ShouldQueue
use Queueable;
public $tries = 1;
public Application $application;
public ApplicationPreview|null $preview = null;
public ?ApplicationPreview $preview = null;
public string $deployment_uuid;
public string $application_name;
public string $project_uuid;
public string $environment_name;
public ?string $deployment_url = null;
public ?string $fqdn;
public function __construct(Application $application, string $deployment_uuid, ApplicationPreview|null $preview = null)
public function __construct(Application $application, string $deployment_uuid, ?ApplicationPreview $preview = null)
{
$this->application = $application;
$this->deployment_uuid = $deployment_uuid;
@@ -38,7 +44,7 @@ class DeploymentSuccess extends Notification implements ShouldQueue
if (Str::of($this->fqdn)->explode(',')->count() > 1) {
$this->fqdn = Str::of($this->fqdn)->explode(',')->first();
}
$this->deployment_url = base_url() . "/project/{$this->project_uuid}/" . urlencode($this->environment_name) . "/application/{$this->application->uuid}/deployment/{$this->deployment_uuid}";
$this->deployment_url = base_url()."/project/{$this->project_uuid}/".urlencode($this->environment_name)."/application/{$this->application->uuid}/deployment/{$this->deployment_uuid}";
}
public function via(object $notifiable): array
@@ -48,8 +54,10 @@ class DeploymentSuccess extends Notification implements ShouldQueue
// TODO: Make batch notifications work with email
$channels = array_diff($channels, ['App\Notifications\Channels\EmailChannel']);
}
return $channels;
}
public function toMail(): MailMessage
{
$mail = new MailMessage();
@@ -67,57 +75,61 @@ class DeploymentSuccess extends Notification implements ShouldQueue
'deployment_url' => $this->deployment_url,
'pull_request_id' => $pull_request_id,
]);
return $mail;
}
public function toDiscord(): string
{
if ($this->preview) {
$message = 'Coolify: New PR' . $this->preview->pull_request_id . ' version successfully deployed of ' . $this->application_name . '
$message = 'Coolify: New PR'.$this->preview->pull_request_id.' version successfully deployed of '.$this->application_name.'
';
if ($this->preview->fqdn) {
$message .= '[Open Application](' . $this->preview->fqdn . ') | ';
$message .= '[Open Application]('.$this->preview->fqdn.') | ';
}
$message .= '[Deployment logs](' . $this->deployment_url . ')';
$message .= '[Deployment logs]('.$this->deployment_url.')';
} else {
$message = 'Coolify: New version successfully deployed of ' . $this->application_name . '
$message = 'Coolify: New version successfully deployed of '.$this->application_name.'
';
if ($this->fqdn) {
$message .= '[Open Application](' . $this->fqdn . ') | ';
$message .= '[Open Application]('.$this->fqdn.') | ';
}
$message .= '[Deployment logs](' . $this->deployment_url . ')';
$message .= '[Deployment logs]('.$this->deployment_url.')';
}
return $message;
}
public function toTelegram(): array
{
if ($this->preview) {
$message = 'Coolify: New PR' . $this->preview->pull_request_id . ' version successfully deployed of ' . $this->application_name . '';
$message = 'Coolify: New PR'.$this->preview->pull_request_id.' version successfully deployed of '.$this->application_name.'';
if ($this->preview->fqdn) {
$buttons[] = [
"text" => "Open Application",
"url" => $this->preview->fqdn
'text' => 'Open Application',
'url' => $this->preview->fqdn,
];
}
} else {
$message = '✅ New version successfully deployed of ' . $this->application_name . '';
$message = '✅ New version successfully deployed of '.$this->application_name.'';
if ($this->fqdn) {
$buttons[] = [
"text" => "Open Application",
"url" => $this->fqdn
'text' => 'Open Application',
'url' => $this->fqdn,
];
}
}
$buttons[] = [
"text" => "Deployment logs",
"url" => $this->deployment_url
'text' => 'Deployment logs',
'url' => $this->deployment_url,
];
return [
"message" => $message,
"buttons" => [
...$buttons
'message' => $message,
'buttons' => [
...$buttons,
],
];
}

View File

@@ -16,10 +16,13 @@ class StatusChanged extends Notification implements ShouldQueue
public $tries = 1;
public string $resource_name;
public string $project_uuid;
public string $environment_name;
public ?string $resource_url = null;
public ?string $fqdn;
public function __construct(public Application $resource)
@@ -31,7 +34,7 @@ class StatusChanged extends Notification implements ShouldQueue
if (Str::of($this->fqdn)->explode(',')->count() > 1) {
$this->fqdn = Str::of($this->fqdn)->explode(',')->first();
}
$this->resource_url = base_url() . "/project/{$this->project_uuid}/" . urlencode($this->environment_name) . "/application/{$this->resource->uuid}";
$this->resource_url = base_url()."/project/{$this->project_uuid}/".urlencode($this->environment_name)."/application/{$this->resource->uuid}";
}
public function via(object $notifiable): array
@@ -49,27 +52,31 @@ class StatusChanged extends Notification implements ShouldQueue
'fqdn' => $fqdn,
'resource_url' => $this->resource_url,
]);
return $mail;
}
public function toDiscord(): string
{
$message = 'Coolify: ' . $this->resource_name . ' has been stopped.
$message = 'Coolify: '.$this->resource_name.' has been stopped.
';
$message .= '[Open Application in Coolify](' . $this->resource_url . ')';
$message .= '[Open Application in Coolify]('.$this->resource_url.')';
return $message;
}
public function toTelegram(): array
{
$message = 'Coolify: ' . $this->resource_name . ' has been stopped.';
$message = 'Coolify: '.$this->resource_name.' has been stopped.';
return [
"message" => $message,
"buttons" => [
'message' => $message,
'buttons' => [
[
"text" => "Open Application in Coolify",
"url" => $this->resource_url
]
'text' => 'Open Application in Coolify',
'url' => $this->resource_url,
],
],
];
}

View File

@@ -14,7 +14,7 @@ class DiscordChannel
{
$message = $notification->toDiscord($notifiable);
$webhookUrl = $notifiable->routeNotificationForDiscord();
if (!$webhookUrl) {
if (! $webhookUrl) {
return;
}
dispatch(new SendMessageToDiscordJob($message, $webhookUrl));

View File

@@ -6,7 +6,6 @@ use Exception;
use Illuminate\Mail\Message;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Mail;
use Log;
class EmailChannel
{
@@ -26,7 +25,7 @@ class EmailChannel
fn (Message $message) => $message
->to($recipients)
->subject($mailMessage->subject)
->html((string)$mailMessage->render())
->html((string) $mailMessage->render())
);
} catch (Exception $e) {
$error = $e->getMessage();
@@ -50,9 +49,10 @@ class EmailChannel
{
if (data_get($notifiable, 'use_instance_email_settings')) {
$type = set_transanctional_email_settings();
if (!$type) {
if (! $type) {
throw new Exception('No email settings found.');
}
return;
}
config()->set('mail.from.address', data_get($notifiable, 'smtp_from_address', 'test@example.com'));
@@ -64,14 +64,14 @@ class EmailChannel
if (data_get($notifiable, 'smtp_enabled')) {
config()->set('mail.default', 'smtp');
config()->set('mail.mailers.smtp', [
"transport" => "smtp",
"host" => data_get($notifiable, 'smtp_host'),
"port" => data_get($notifiable, 'smtp_port'),
"encryption" => data_get($notifiable, 'smtp_encryption'),
"username" => data_get($notifiable, 'smtp_username'),
"password" => data_get($notifiable, 'smtp_password'),
"timeout" => data_get($notifiable, 'smtp_timeout'),
"local_domain" => null,
'transport' => 'smtp',
'host' => data_get($notifiable, 'smtp_host'),
'port' => data_get($notifiable, 'smtp_port'),
'encryption' => data_get($notifiable, 'smtp_encryption'),
'username' => data_get($notifiable, 'smtp_username'),
'password' => data_get($notifiable, 'smtp_password'),
'timeout' => data_get($notifiable, 'smtp_timeout'),
'local_domain' => null,
]);
}
}

View File

@@ -5,5 +5,4 @@ namespace App\Notifications\Channels;
interface SendsTelegram
{
public function routeNotificationForTelegram();
}

View File

@@ -38,7 +38,7 @@ class TelegramChannel
$topicId = data_get($notifiable, 'telegram_notifications_scheduled_tasks_thread_id');
break;
}
if (!$telegramToken || !$chatId || !$message) {
if (! $telegramToken || ! $chatId || ! $message) {
return;
}
dispatch(new SendMessageToTelegramJob($message, $buttons, $telegramToken, $chatId, $topicId));

View File

@@ -15,12 +15,13 @@ class TransactionalEmailChannel
public function send(User $notifiable, Notification $notification): void
{
$settings = InstanceSettings::get();
if (!data_get($settings, 'smtp_enabled') && !data_get($settings, 'resend_enabled')) {
if (! data_get($settings, 'smtp_enabled') && ! data_get($settings, 'resend_enabled')) {
Log::info('SMTP/Resend not enabled');
return;
}
$email = $notifiable->email;
if (!$email) {
if (! $email) {
return;
}
$this->bootConfigs();
@@ -31,14 +32,14 @@ class TransactionalEmailChannel
fn (Message $message) => $message
->to($email)
->subject($mailMessage->subject)
->html((string)$mailMessage->render())
->html((string) $mailMessage->render())
);
}
private function bootConfigs(): void
{
$type = set_transanctional_email_settings();
if (!$type) {
if (! $type) {
throw new Exception('No email settings found.');
}
}

View File

@@ -14,7 +14,6 @@ class ContainerRestarted extends Notification implements ShouldQueue
public $tries = 1;
public function __construct(public string $name, public Server $server, public ?string $url = null)
{
}
@@ -33,30 +32,34 @@ class ContainerRestarted extends Notification implements ShouldQueue
'serverName' => $this->server->name,
'url' => $this->url,
]);
return $mail;
}
public function toDiscord(): string
{
$message = "Coolify: A resource ({$this->name}) has been restarted automatically on {$this->server->name}";
return $message;
}
public function toTelegram(): array
{
$message = "Coolify: A resource ({$this->name}) has been restarted automatically on {$this->server->name}";
$payload = [
"message" => $message,
'message' => $message,
];
if ($this->url) {
$payload['buttons'] = [
[
[
"text" => "Check Proxy in Coolify",
"url" => $this->url
]
]
'text' => 'Check Proxy in Coolify',
'url' => $this->url,
],
],
];
};
}
return $payload;
}
}

View File

@@ -32,30 +32,34 @@ class ContainerStopped extends Notification implements ShouldQueue
'serverName' => $this->server->name,
'url' => $this->url,
]);
return $mail;
}
public function toDiscord(): string
{
$message = "Coolify: A resource ($this->name) has been stopped unexpectedly on {$this->server->name}";
return $message;
}
public function toTelegram(): array
{
$message = "Coolify: A resource ($this->name) has been stopped unexpectedly on {$this->server->name}";
$payload = [
"message" => $message,
'message' => $message,
];
if ($this->url) {
$payload['buttons'] = [
[
[
"text" => "Open Application in Coolify",
"url" => $this->url
]
]
'text' => 'Open Application in Coolify',
'url' => $this->url,
],
],
];
}
return $payload;
}
}

View File

@@ -3,11 +3,8 @@
namespace App\Notifications\Database;
use App\Models\ScheduledDatabaseBackup;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\TelegramChannel;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Channels\MailChannel;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
@@ -16,8 +13,11 @@ class BackupFailed extends Notification implements ShouldQueue
use Queueable;
public $backoff = 10;
public $tries = 2;
public string $name;
public string $frequency;
public function __construct(ScheduledDatabaseBackup $backup, public $database, public $output, public $database_name)
@@ -41,6 +41,7 @@ class BackupFailed extends Notification implements ShouldQueue
'frequency' => $this->frequency,
'output' => $this->output,
]);
return $mail;
}
@@ -48,11 +49,13 @@ class BackupFailed extends Notification implements ShouldQueue
{
return "Coolify: Database backup for {$this->name} (db:{$this->database_name}) with frequency of {$this->frequency} was FAILED.\n\nReason:\n{$this->output}";
}
public function toTelegram(): array
{
$message = "Coolify: Database backup for {$this->name} (db:{$this->database_name}) with frequency of {$this->frequency} was FAILED.\n\nReason:\n{$this->output}";
return [
"message" => $message,
'message' => $message,
];
}
}

View File

@@ -13,8 +13,11 @@ class BackupSuccess extends Notification implements ShouldQueue
use Queueable;
public $backoff = 10;
public $tries = 3;
public string $name;
public string $frequency;
public function __construct(ScheduledDatabaseBackup $backup, public $database, public $database_name)
@@ -37,6 +40,7 @@ class BackupSuccess extends Notification implements ShouldQueue
'database_name' => $this->database_name,
'frequency' => $this->frequency,
]);
return $mail;
}
@@ -44,12 +48,14 @@ class BackupSuccess extends Notification implements ShouldQueue
{
return "Coolify: Database backup for {$this->name} (db:{$this->database_name}) with frequency of {$this->frequency} was successful.";
}
public function toTelegram(): array
{
$message = "Coolify: Database backup for {$this->name} (db:{$this->database_name}) with frequency of {$this->frequency} was successful.";
ray($message);
return [
"message" => $message,
'message' => $message,
];
}
}

View File

@@ -2,7 +2,6 @@
namespace App\Notifications\Database;
use App\Models\ScheduledDatabaseBackup;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\TelegramChannel;
use Illuminate\Bus\Queueable;
@@ -29,22 +28,25 @@ class DailyBackup extends Notification implements ShouldQueue
public function toMail(): MailMessage
{
$mail = new MailMessage();
$mail->subject("Coolify: Daily backup statuses");
$mail->subject('Coolify: Daily backup statuses');
$mail->view('emails.daily-backup', [
'databases' => $this->databases,
]);
return $mail;
}
public function toDiscord(): string
{
return "Coolify: Daily backup statuses";
return 'Coolify: Daily backup statuses';
}
public function toTelegram(): array
{
$message = "Coolify: Daily backup statuses";
$message = 'Coolify: Daily backup statuses';
return [
"message" => $message,
'message' => $message,
];
}
}

View File

@@ -13,6 +13,7 @@ class GeneralNotification extends Notification implements ShouldQueue
use Queueable;
public $tries = 1;
public function __construct(public string $message)
{
}
@@ -29,6 +30,7 @@ class GeneralNotification extends Notification implements ShouldQueue
if ($isTelegramEnabled) {
$channels[] = TelegramChannel::class;
}
return $channels;
}
@@ -36,10 +38,11 @@ class GeneralNotification extends Notification implements ShouldQueue
{
return $this->message;
}
public function toTelegram(): array
{
return [
"message" => $this->message,
'message' => $this->message,
];
}
}

View File

@@ -13,6 +13,7 @@ class TaskFailed extends Notification implements ShouldQueue
use Queueable;
public $backoff = 10;
public $tries = 2;
public ?string $url = null;
@@ -21,7 +22,7 @@ class TaskFailed extends Notification implements ShouldQueue
{
if ($task->application) {
$this->url = $task->application->failedTaskLink($task->uuid);
} else if ($task->service) {
} elseif ($task->service) {
$this->url = $task->service->failedTaskLink($task->uuid);
}
}
@@ -41,6 +42,7 @@ class TaskFailed extends Notification implements ShouldQueue
'url' => $this->url,
'output' => $this->output,
]);
return $mail;
}
@@ -48,17 +50,19 @@ class TaskFailed extends Notification implements ShouldQueue
{
return "Coolify: Scheduled task ({$this->task->name}, [link]({$this->url})) failed with output: {$this->output}";
}
public function toTelegram(): array
{
$message = "Coolify: Scheduled task ({$this->task->name}) failed with output: {$this->output}";
if ($this->url) {
$buttons[] = [
"text" => "Open task in Coolify",
"url" => (string) $this->url
'text' => 'Open task in Coolify',
'url' => (string) $this->url,
];
}
return [
"message" => $message,
'message' => $message,
];
}
}

View File

@@ -3,9 +3,9 @@
namespace App\Notifications\Server;
use App\Models\Server;
use Illuminate\Bus\Queueable;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\TelegramChannel;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
@@ -14,6 +14,7 @@ class DockerCleanup extends Notification implements ShouldQueue
use Queueable;
public $tries = 1;
public function __construct(public Server $server, public string $message)
{
}
@@ -34,6 +35,7 @@ class DockerCleanup extends Notification implements ShouldQueue
if ($isTelegramEnabled) {
$channels[] = TelegramChannel::class;
}
return $channels;
}
@@ -52,12 +54,14 @@ class DockerCleanup extends Notification implements ShouldQueue
public function toDiscord(): string
{
$message = "Coolify: Server '{$this->server->name}' cleanup job done!\n\n{$this->message}";
return $message;
}
public function toTelegram(): array
{
return [
"message" => "Coolify: Server '{$this->server->name}' cleanup job done!\n\n{$this->message}"
'message' => "Coolify: Server '{$this->server->name}' cleanup job done!\n\n{$this->message}",
];
}
}

View File

@@ -3,10 +3,10 @@
namespace App\Notifications\Server;
use App\Models\Server;
use Illuminate\Bus\Queueable;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\EmailChannel;
use App\Notifications\Channels\TelegramChannel;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
@@ -16,6 +16,7 @@ class ForceDisabled extends Notification implements ShouldQueue
use Queueable;
public $tries = 1;
public function __construct(public Server $server)
{
}
@@ -36,6 +37,7 @@ class ForceDisabled extends Notification implements ShouldQueue
if ($isTelegramEnabled) {
$channels[] = TelegramChannel::class;
}
return $channels;
}
@@ -46,18 +48,21 @@ class ForceDisabled extends Notification implements ShouldQueue
$mail->view('emails.server-force-disabled', [
'name' => $this->server->name,
]);
return $mail;
}
public function toDiscord(): string
{
$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/subsciprtions).";
return $message;
}
public function toTelegram(): array
{
return [
"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/subsciprtions)."
'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/subsciprtions).",
];
}
}

View File

@@ -3,10 +3,10 @@
namespace App\Notifications\Server;
use App\Models\Server;
use Illuminate\Bus\Queueable;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\EmailChannel;
use App\Notifications\Channels\TelegramChannel;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
@@ -16,6 +16,7 @@ class ForceEnabled extends Notification implements ShouldQueue
use Queueable;
public $tries = 1;
public function __construct(public Server $server)
{
}
@@ -36,6 +37,7 @@ class ForceEnabled extends Notification implements ShouldQueue
if ($isTelegramEnabled) {
$channels[] = TelegramChannel::class;
}
return $channels;
}
@@ -46,18 +48,21 @@ class ForceEnabled extends Notification implements ShouldQueue
$mail->view('emails.server-force-enabled', [
'name' => $this->server->name,
]);
return $mail;
}
public function toDiscord(): string
{
$message = "Coolify: Server ({$this->server->name}) enabled again!";
return $message;
}
public function toTelegram(): array
{
return [
"message" => "Coolify: Server ({$this->server->name}) enabled again!"
'message' => "Coolify: Server ({$this->server->name}) enabled again!",
];
}
}

View File

@@ -3,10 +3,10 @@
namespace App\Notifications\Server;
use App\Models\Server;
use Illuminate\Bus\Queueable;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\EmailChannel;
use App\Notifications\Channels\TelegramChannel;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
@@ -16,6 +16,7 @@ class HighDiskUsage extends Notification implements ShouldQueue
use Queueable;
public $tries = 1;
public function __construct(public Server $server, public int $disk_usage, public int $cleanup_after_percentage)
{
}
@@ -36,6 +37,7 @@ class HighDiskUsage extends Notification implements ShouldQueue
if ($isTelegramEnabled) {
$channels[] = TelegramChannel::class;
}
return $channels;
}
@@ -48,18 +50,21 @@ class HighDiskUsage extends Notification implements ShouldQueue
'disk_usage' => $this->disk_usage,
'threshold' => $this->cleanup_after_percentage,
]);
return $mail;
}
public function toDiscord(): string
{
$message = "Coolify: Server '{$this->server->name}' high disk usage detected!\nDisk usage: {$this->disk_usage}%. Threshold: {$this->cleanup_after_percentage}%.\nPlease cleanup your disk to prevent data-loss.\nHere are some tips: https://coolify.io/docs/knowledge-base/server/automated-cleanup.";
return $message;
}
public function toTelegram(): array
{
return [
"message" => "Coolify: Server '{$this->server->name}' high disk usage detected!\nDisk usage: {$this->disk_usage}%. Threshold: {$this->cleanup_after_percentage}%.\nPlease cleanup your disk to prevent data-loss.\nHere are some tips: https://coolify.io/docs/knowledge-base/server/automated-cleanup."
'message' => "Coolify: Server '{$this->server->name}' high disk usage detected!\nDisk usage: {$this->disk_usage}%. Threshold: {$this->cleanup_after_percentage}%.\nPlease cleanup your disk to prevent data-loss.\nHere are some tips: https://coolify.io/docs/knowledge-base/server/automated-cleanup.",
];
}
}

View File

@@ -5,10 +5,10 @@ namespace App\Notifications\Server;
use App\Actions\Docker\GetContainersStatus;
use App\Jobs\ContainerStatusJob;
use App\Models\Server;
use Illuminate\Bus\Queueable;
use App\Notifications\Channels\DiscordChannel;
use App\Notifications\Channels\EmailChannel;
use App\Notifications\Channels\TelegramChannel;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
@@ -18,6 +18,7 @@ class Revived extends Notification implements ShouldQueue
use Queueable;
public $tries = 1;
public function __construct(public Server $server)
{
if ($this->server->unreachable_notification_sent === false) {
@@ -37,12 +38,13 @@ class Revived extends Notification implements ShouldQueue
if ($isDiscordEnabled) {
$channels[] = DiscordChannel::class;
}
if ($isEmailEnabled ) {
if ($isEmailEnabled) {
$channels[] = EmailChannel::class;
}
if ($isTelegramEnabled) {
$channels[] = TelegramChannel::class;
}
return $channels;
}
@@ -53,18 +55,21 @@ class Revived extends Notification implements ShouldQueue
$mail->view('emails.server-revived', [
'name' => $this->server->name,
]);
return $mail;
}
public function toDiscord(): string
{
$message = "Coolify: Server '{$this->server->name}' revived. All automations & integrations are turned on again!";
return $message;
}
public function toTelegram(): array
{
return [
"message" => "Coolify: Server '{$this->server->name}' revived. All automations & integrations are turned on again!"
'message' => "Coolify: Server '{$this->server->name}' revived. All automations & integrations are turned on again!",
];
}
}

View File

@@ -16,6 +16,7 @@ class Unreachable extends Notification implements ShouldQueue
use Queueable;
public $tries = 1;
public function __construct(public Server $server)
{
@@ -31,12 +32,13 @@ class Unreachable extends Notification implements ShouldQueue
if ($isDiscordEnabled) {
$channels[] = DiscordChannel::class;
}
if ($isEmailEnabled ) {
if ($isEmailEnabled) {
$channels[] = EmailChannel::class;
}
if ($isTelegramEnabled) {
$channels[] = TelegramChannel::class;
}
return $channels;
}
@@ -47,18 +49,21 @@ class Unreachable extends Notification implements ShouldQueue
$mail->view('emails.server-lost-connection', [
'name' => $this->server->name,
]);
return $mail;
}
public function toDiscord(): string
{
$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.";
return $message;
}
public function toTelegram(): array
{
return [
"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."
'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.",
];
}
}

View File

@@ -12,7 +12,8 @@ class Test extends Notification implements ShouldQueue
use Queueable;
public $tries = 5;
public function __construct(public string|null $emails = null)
public function __construct(public ?string $emails = null)
{
}
@@ -24,8 +25,9 @@ class Test extends Notification implements ShouldQueue
public function toMail(): MailMessage
{
$mail = new MailMessage();
$mail->subject("Coolify: Test Email");
$mail->subject('Coolify: Test Email');
$mail->view('emails.test');
return $mail;
}
@@ -33,18 +35,20 @@ class Test extends Notification implements ShouldQueue
{
$message = 'Coolify: This is a test Discord notification from Coolify.';
$message .= "\n\n";
$message .= '[Go to your dashboard](' . base_url() . ')';
$message .= '[Go to your dashboard]('.base_url().')';
return $message;
}
public function toTelegram(): array
{
return [
"message" => 'Coolify: This is a test Telegram notification from Coolify.',
"buttons" => [
'message' => 'Coolify: This is a test Telegram notification from Coolify.',
'buttons' => [
[
"text" => "Go to your dashboard",
"url" => base_url()
]
'text' => 'Go to your dashboard',
'url' => base_url(),
],
],
];
}

View File

@@ -16,6 +16,7 @@ class InvitationLink extends Notification implements ShouldQueue
use Queueable;
public $tries = 5;
public function via(): array
{
return [TransactionalEmailChannel::class];
@@ -24,18 +25,20 @@ class InvitationLink extends Notification implements ShouldQueue
public function __construct(public User $user)
{
}
public function toMail(): MailMessage
{
$invitation = TeamInvitation::whereEmail($this->user->email)->first();
$invitation_team = Team::find($invitation->team->id);
$mail = new MailMessage();
$mail->subject('Coolify: Invitation for ' . $invitation_team->name);
$mail->subject('Coolify: Invitation for '.$invitation_team->name);
$mail->view('emails.invitation-link', [
'team' => $invitation_team->name,
'email' => $this->user->email,
'invitation_link' => $invitation->link,
]);
return $mail;
}
}

View File

@@ -9,8 +9,11 @@ use Illuminate\Notifications\Notification;
class ResetPassword extends Notification
{
public static $createUrlCallback;
public static $toMailCallback;
public $token;
public InstanceSettings $settings;
public function __construct($token)
@@ -32,9 +35,10 @@ class ResetPassword extends Notification
public function via($notifiable)
{
$type = set_transanctional_email_settings();
if (!$type) {
if (! $type) {
throw new \Exception('No email settings found.');
}
return ['mail'];
}
@@ -51,7 +55,8 @@ class ResetPassword extends Notification
{
$mail = new MailMessage();
$mail->subject('Coolify: Reset Password');
$mail->view('emails.reset-password', ['url' => $url, 'count' => config('auth.passwords.' . config('auth.defaults.passwords') . '.expire')]);
$mail->view('emails.reset-password', ['url' => $url, 'count' => config('auth.passwords.'.config('auth.defaults.passwords').'.expire')]);
return $mail;
}

View File

@@ -13,6 +13,7 @@ class Test extends Notification implements ShouldQueue
use Queueable;
public $tries = 5;
public function __construct(public string $emails)
{
}
@@ -27,6 +28,7 @@ class Test extends Notification implements ShouldQueue
$mail = new MailMessage();
$mail->subject('Coolify: Test Email');
$mail->view('emails.test');
return $mail;
}
}