feat: use new notification event names

This commit is contained in:
peaklabs-dev
2024-12-09 16:57:15 +01:00
parent bc726ddd6e
commit b6500142c4
12 changed files with 75 additions and 150 deletions

View File

@@ -5,8 +5,8 @@ namespace App\Notifications\Application;
use App\Models\Application;
use App\Notifications\CustomEmailNotification;
use App\Notifications\Dto\DiscordMessage;
use Illuminate\Notifications\Messages\MailMessage;
use App\Notifications\Dto\SlackMessage;
use Illuminate\Notifications\Messages\MailMessage;
class StatusChanged extends CustomEmailNotification
{
@@ -30,12 +30,12 @@ class StatusChanged extends CustomEmailNotification
if (str($this->fqdn)->explode(',')->count() > 1) {
$this->fqdn = str($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
{
return setNotificationChannels($notifiable, 'status_changes');
return $notifiable->getEnabledChannels('status_change');
}
public function toMail(): MailMessage
@@ -56,7 +56,7 @@ class StatusChanged extends CustomEmailNotification
{
return new DiscordMessage(
title: ':cross_mark: Application stopped',
description: '[Open Application in Coolify](' . $this->resource_url . ')',
description: '[Open Application in Coolify]('.$this->resource_url.')',
color: DiscordMessage::errorColor(),
isCritical: true,
);
@@ -64,7 +64,7 @@ class StatusChanged extends CustomEmailNotification
public function toTelegram(): array
{
$message = 'Coolify: ' . $this->resource_name . ' has been stopped.';
$message = 'Coolify: '.$this->resource_name.' has been stopped.';
return [
'message' => $message,
@@ -79,10 +79,10 @@ class StatusChanged extends CustomEmailNotification
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}";