updated DiscordMessages for Internal&ScheduledTask notifications
This commit is contained in:
parent
f021a42890
commit
cb5dc13bf1
3 changed files with 23 additions and 4 deletions
|
|
@ -28,6 +28,11 @@ public static function errorColor(): int
|
||||||
return hexdec('ff705f');
|
return hexdec('ff705f');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function infoColor(): int
|
||||||
|
{
|
||||||
|
return hexdec('4f545c');
|
||||||
|
}
|
||||||
|
|
||||||
public function addField(string $name, string $value): self
|
public function addField(string $name, string $value): self
|
||||||
{
|
{
|
||||||
$this->fields[] = [
|
$this->fields[] = [
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
use App\Notifications\Channels\DiscordChannel;
|
use App\Notifications\Channels\DiscordChannel;
|
||||||
use App\Notifications\Channels\TelegramChannel;
|
use App\Notifications\Channels\TelegramChannel;
|
||||||
|
use App\Notifications\Dto\DiscordMessage;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
|
@ -32,9 +33,13 @@ public function via(object $notifiable): array
|
||||||
return $channels;
|
return $channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toDiscord(): string
|
public function toDiscord(): DiscordMessage
|
||||||
{
|
{
|
||||||
return $this->message;
|
return new DiscordMessage(
|
||||||
|
title: 'Coolify: General Notification',
|
||||||
|
description: $this->message,
|
||||||
|
color: DiscordMessage::infoColor(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toTelegram(): array
|
public function toTelegram(): array
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Notifications\ScheduledTask;
|
namespace App\Notifications\ScheduledTask;
|
||||||
|
|
||||||
use App\Models\ScheduledTask;
|
use App\Models\ScheduledTask;
|
||||||
|
use App\Notifications\Dto\DiscordMessage;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
|
@ -46,9 +47,17 @@ public function toMail(): MailMessage
|
||||||
return $mail;
|
return $mail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toDiscord(): string
|
public function toDiscord(): DiscordMessage
|
||||||
{
|
{
|
||||||
return "Coolify: Scheduled task ({$this->task->name}, [link]({$this->url})) failed with output: {$this->output}";
|
$message = new DiscordMessage(
|
||||||
|
title: "Coolify: Scheduled task ({$this->task->name}) failed.",
|
||||||
|
description: "Output: {$this->output}",
|
||||||
|
color: DiscordMessage::errorColor(),
|
||||||
|
);
|
||||||
|
|
||||||
|
$message->addField('Link', '[Open task in Coolify]('.$this->url.')');
|
||||||
|
|
||||||
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toTelegram(): array
|
public function toTelegram(): array
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue