Revert "rector: arrrrr"

This reverts commit 16c0cd10d8.
This commit is contained in:
Andras Bacsai
2025-01-07 15:31:43 +01:00
parent da07b4fdcf
commit 1fe4dd722b
349 changed files with 3689 additions and 4184 deletions

View File

@@ -30,12 +30,12 @@ class DeploymentFailed extends CustomEmailNotification
public ?string $fqdn = null;
public function __construct(Application $application, string $deployment_uuid, ?ApplicationPreview $applicationPreview = null)
public function __construct(Application $application, string $deployment_uuid, ?ApplicationPreview $preview = null)
{
$this->onQueue('high');
$this->application = $application;
$this->deployment_uuid = $deployment_uuid;
$this->preview = $applicationPreview;
$this->preview = $preview;
$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
{
$mailMessage = new MailMessage;
$mail = new MailMessage;
$pull_request_id = data_get($this->preview, 'pull_request_id', 0);
$fqdn = $this->fqdn;
if ($pull_request_id === 0) {
$mailMessage->subject('Coolify: Deployment failed of '.$this->application_name.'.');
$mail->subject('Coolify: Deployment failed of '.$this->application_name.'.');
} else {
$fqdn = $this->preview->fqdn;
$mailMessage->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.'.');
}
$mailMessage->view('emails.application-deployment-failed', [
$mail->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 $mailMessage;
return $mail;
}
public function toDiscord(): DiscordMessage
{
if ($this->preview instanceof ApplicationPreview) {
if ($this->preview) {
$message = new DiscordMessage(
title: ':cross_mark: Deployment failed',
description: 'Pull request: '.$this->preview->pull_request_id,
@@ -92,16 +92,22 @@ class DeploymentFailed extends CustomEmailNotification
$message->addField('Domain', $this->fqdn, true);
}
} else {
$description = $this->fqdn ? '[Open application]('.$this->fqdn.')' : '';
if ($this->fqdn) {
$description = '[Open application]('.$this->fqdn.')';
} else {
$description = '';
}
$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.')');
}
@@ -110,7 +116,7 @@ class DeploymentFailed extends CustomEmailNotification
public function toTelegram(): array
{
if ($this->preview instanceof ApplicationPreview) {
if ($this->preview) {
$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.'): ';
@@ -130,7 +136,7 @@ class DeploymentFailed extends CustomEmailNotification
public function toPushover(): PushoverMessage
{
if ($this->preview instanceof ApplicationPreview) {
if ($this->preview) {
$title = "Pull request #{$this->preview->pull_request_id} deployment failed";
$message = "Pull request deployment failed for {$this->application_name}";
} else {
@@ -155,7 +161,7 @@ class DeploymentFailed extends CustomEmailNotification
public function toSlack(): SlackMessage
{
if ($this->preview instanceof ApplicationPreview) {
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) {

View File

@@ -30,12 +30,12 @@ class DeploymentSuccess extends CustomEmailNotification
public ?string $fqdn;
public function __construct(Application $application, string $deployment_uuid, ?ApplicationPreview $applicationPreview = null)
public function __construct(Application $application, string $deployment_uuid, ?ApplicationPreview $preview = null)
{
$this->onQueue('high');
$this->application = $application;
$this->deployment_uuid = $deployment_uuid;
$this->preview = $applicationPreview;
$this->preview = $preview;
$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
{
$mailMessage = new MailMessage;
$mail = new MailMessage;
$pull_request_id = data_get($this->preview, 'pull_request_id', 0);
$fqdn = $this->fqdn;
if ($pull_request_id === 0) {
$mailMessage->subject("Coolify: New version is deployed of {$this->application_name}");
$mail->subject("Coolify: New version is deployed of {$this->application_name}");
} else {
$fqdn = $this->preview->fqdn;
$mailMessage->subject("Coolify: Pull request #{$pull_request_id} of {$this->application_name} deployed successfully");
$mail->subject("Coolify: Pull request #{$pull_request_id} of {$this->application_name} deployed successfully");
}
$mailMessage->view('emails.application-deployment-success', [
$mail->view('emails.application-deployment-success', [
'name' => $this->application_name,
'fqdn' => $fqdn,
'deployment_url' => $this->deployment_url,
'pull_request_id' => $pull_request_id,
]);
return $mailMessage;
return $mail;
}
public function toDiscord(): DiscordMessage
{
if ($this->preview instanceof ApplicationPreview) {
if ($this->preview) {
$message = new DiscordMessage(
title: ':white_check_mark: Preview deployment successful',
description: 'Pull request: '.$this->preview->pull_request_id,
@@ -91,7 +91,11 @@ class DeploymentSuccess extends CustomEmailNotification
$message->addField('Name', $this->application_name, true);
$message->addField('Deployment logs', '[Link]('.$this->deployment_url.')');
} else {
$description = $this->fqdn ? '[Open application]('.$this->fqdn.')' : '';
if ($this->fqdn) {
$description = '[Open application]('.$this->fqdn.')';
} else {
$description = '';
}
$message = new DiscordMessage(
title: ':white_check_mark: New version successfully deployed',
description: $description,
@@ -100,6 +104,7 @@ 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.')');
}
@@ -108,7 +113,7 @@ class DeploymentSuccess extends CustomEmailNotification
public function toTelegram(): array
{
if ($this->preview instanceof ApplicationPreview) {
if ($this->preview) {
$message = 'Coolify: New PR'.$this->preview->pull_request_id.' version successfully deployed of '.$this->application_name.'';
if ($this->preview->fqdn) {
$buttons[] = [
@@ -140,7 +145,7 @@ class DeploymentSuccess extends CustomEmailNotification
public function toPushover(): PushoverMessage
{
if ($this->preview instanceof ApplicationPreview) {
if ($this->preview) {
$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) {
@@ -176,7 +181,7 @@ class DeploymentSuccess extends CustomEmailNotification
public function toSlack(): SlackMessage
{
if ($this->preview instanceof ApplicationPreview) {
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) {

View File

@@ -23,18 +23,18 @@ class StatusChanged extends CustomEmailNotification
public ?string $fqdn;
public function __construct(public Application $application)
public function __construct(public Application $resource)
{
$this->onQueue('high');
$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);
$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);
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->application->uuid}";
$this->resource_url = base_url()."/project/{$this->project_uuid}/environments/{$this->environment_uuid}/application/{$this->resource->uuid}";
}
public function via(object $notifiable): array
@@ -44,16 +44,16 @@ class StatusChanged extends CustomEmailNotification
public function toMail(): MailMessage
{
$mailMessage = new MailMessage;
$mail = new MailMessage;
$fqdn = $this->fqdn;
$mailMessage->subject("Coolify: {$this->resource_name} has been stopped");
$mailMessage->view('emails.application-status-changes', [
$mail->subject("Coolify: {$this->resource_name} has been stopped");
$mail->view('emails.application-status-changes', [
'name' => $this->resource_name,
'fqdn' => $fqdn,
'resource_url' => $this->resource_url,
]);
return $mailMessage;
return $mail;
}
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->application, '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}";