mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-14 02:15:51 +00:00
Merge remote-tracking branch 'origin/next' into jean/add-restart-loop-limit
This commit is contained in:
commit
d581abb284
767 files changed
+43354
-12714
No files matched your search
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\PersonalAccessToken;
|
||||
use App\Notifications\Dto\DiscordMessage;
|
||||
use App\Notifications\Dto\PushoverMessage;
|
||||
use App\Notifications\Dto\SlackMessage;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class ApiTokenExpiringNotification extends CustomEmailNotification
|
||||
{
|
||||
protected string $tokenName;
|
||||
|
||||
protected string $expiresAt;
|
||||
|
||||
protected string $manageUrl;
|
||||
|
||||
public function __construct(public PersonalAccessToken $token)
|
||||
{
|
||||
$this->onQueue('high');
|
||||
$this->tokenName = $token->name;
|
||||
$this->expiresAt = $token->expires_at?->format('Y-m-d H:i:s') ?? '';
|
||||
$this->manageUrl = route('security.api-tokens');
|
||||
}
|
||||
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return $notifiable->getEnabledChannels('api_token_expiring');
|
||||
}
|
||||
|
||||
public function toMail(): MailMessage
|
||||
{
|
||||
$mail = new MailMessage;
|
||||
$mail->subject("Coolify: API token '{$this->tokenName}' expires in 24 hours");
|
||||
$mail->view('emails.api-token-expiring', [
|
||||
'tokenName' => $this->tokenName,
|
||||
'expiresAt' => $this->expiresAt,
|
||||
'manageUrl' => $this->manageUrl,
|
||||
]);
|
||||
|
||||
return $mail;
|
||||
}
|
||||
|
||||
public function toDiscord(): DiscordMessage
|
||||
{
|
||||
$message = new DiscordMessage(
|
||||
title: '🔑 API token expiring soon',
|
||||
description: "API token **{$this->tokenName}** expires on {$this->expiresAt}.\n\n**Action Required:** Rotate this token before it expires to avoid API outages.",
|
||||
color: DiscordMessage::warningColor(),
|
||||
);
|
||||
|
||||
$message->addField('Manage tokens', "[Open Security settings]({$this->manageUrl})");
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
public function toTelegram(): array
|
||||
{
|
||||
$message = "Coolify: API token '{$this->tokenName}' expires on {$this->expiresAt}.\n\nAction Required: Rotate this token before it expires to avoid API outages.";
|
||||
|
||||
return [
|
||||
'message' => $message,
|
||||
'buttons' => [
|
||||
[
|
||||
'text' => 'Manage API tokens',
|
||||
'url' => $this->manageUrl,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function toPushover(): PushoverMessage
|
||||
{
|
||||
$message = "API token <b>{$this->tokenName}</b> expires on {$this->expiresAt}.<br/><br/>";
|
||||
$message .= '<b>Action Required:</b> Rotate this token before it expires to avoid API outages.';
|
||||
|
||||
return new PushoverMessage(
|
||||
title: 'API token expiring soon',
|
||||
level: 'warning',
|
||||
message: $message,
|
||||
buttons: [
|
||||
[
|
||||
'text' => 'Manage API tokens',
|
||||
'url' => $this->manageUrl,
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
public function toSlack(): SlackMessage
|
||||
{
|
||||
$description = "API token *{$this->tokenName}* expires on {$this->expiresAt}.\n\n";
|
||||
$description .= "*Action Required:* Rotate this token before it expires to avoid API outages.\n\n";
|
||||
$description .= "Manage tokens: {$this->manageUrl}";
|
||||
|
||||
return new SlackMessage(
|
||||
title: '🔑 API token expiring soon',
|
||||
description: $description,
|
||||
color: SlackMessage::warningColor(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ class ForceDisabled extends CustomEmailNotification
|
||||
color: DiscordMessage::errorColor(),
|
||||
);
|
||||
|
||||
$message->addField('Please update your subscription to enable the server again!', '[Link](https://app.coolify.io/subscriptions)');
|
||||
$message->addField('Please update your subscription to enable the server again!', '[Link](https://app.coolify.io/subscription)');
|
||||
|
||||
return $message;
|
||||
}
|
||||
@@ -48,7 +48,7 @@ class ForceDisabled extends CustomEmailNotification
|
||||
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/subscriptions).",
|
||||
'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/subscription).",
|
||||
];
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class ForceDisabled extends CustomEmailNotification
|
||||
return new PushoverMessage(
|
||||
title: 'Server disabled',
|
||||
level: 'error',
|
||||
message: "Server ({$this->server->name}) disabled because it is not paid!\n All automations and integrations are stopped.<br/>Please update your subscription to enable the server again [here](https://app.coolify.io/subscriptions).",
|
||||
message: "Server ({$this->server->name}) disabled because it is not paid!\n All automations and integrations are stopped.<br/>Please update your subscription to enable the server again [here](https://app.coolify.io/subscription).",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class ForceDisabled extends CustomEmailNotification
|
||||
$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/subscription';
|
||||
|
||||
return new SlackMessage(
|
||||
title: $title,
|
||||
|
||||
@@ -67,9 +67,12 @@ class ResetPassword extends Notification
|
||||
return call_user_func(static::$createUrlCallback, $notifiable, $this->token);
|
||||
}
|
||||
|
||||
return url(route('password.reset', [
|
||||
$path = route('password.reset', [
|
||||
'token' => $this->token,
|
||||
'email' => $notifiable->getEmailForPasswordReset(),
|
||||
], false));
|
||||
], false);
|
||||
|
||||
// Use server-side config (FQDN / public IP) instead of request host
|
||||
return rtrim(base_url(), '/').$path;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user