52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications\Internal;
|
|
|
|
use App\Notifications\Channels\DiscordChannel;
|
|
use App\Notifications\Channels\TelegramChannel;
|
|
use App\Notifications\Dto\DiscordMessage;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
class GeneralNotification extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public $tries = 1;
|
|
|
|
public function __construct(public string $message) {}
|
|
|
|
public function via(object $notifiable): array
|
|
{
|
|
$channels = [];
|
|
$isDiscordEnabled = data_get($notifiable, 'discord_enabled');
|
|
$isTelegramEnabled = data_get($notifiable, 'telegram_enabled');
|
|
|
|
if ($isDiscordEnabled) {
|
|
$channels[] = DiscordChannel::class;
|
|
}
|
|
if ($isTelegramEnabled) {
|
|
$channels[] = TelegramChannel::class;
|
|
}
|
|
|
|
return $channels;
|
|
}
|
|
|
|
public function toDiscord(): DiscordMessage
|
|
{
|
|
return new DiscordMessage(
|
|
title: 'Coolify: General Notification',
|
|
description: $this->message,
|
|
color: DiscordMessage::infoColor(),
|
|
);
|
|
}
|
|
|
|
public function toTelegram(): array
|
|
{
|
|
return [
|
|
'message' => $this->message,
|
|
];
|
|
}
|
|
}
|