Starts Notifications feature. Missing to send email with runtime configs.
This commit is contained in:
25
app/Notifications/Channels/DiscordChannel.php
Normal file
25
app/Notifications/Channels/DiscordChannel.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications\Channels;
|
||||
|
||||
use App\Jobs\SendMessageToDiscordJob;
|
||||
use App\Models\InstanceSettings;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class DiscordChannel
|
||||
{
|
||||
/**
|
||||
* Send the given notification.
|
||||
*/
|
||||
public function send(object $notifiable, Notification $notification): void
|
||||
{
|
||||
$message = $notification->toDiscord($notifiable);
|
||||
|
||||
$webhookUrl = data_get(
|
||||
InstanceSettings::get(),
|
||||
'extra_attributes.discord_webhook'
|
||||
);
|
||||
|
||||
dispatch(new SendMessageToDiscordJob($message, $webhookUrl));
|
||||
}
|
||||
}
|
||||
60
app/Notifications/TestMessage.php
Normal file
60
app/Notifications/TestMessage.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Notifications\Channels\DiscordChannel;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class TestMessage extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['mail', DiscordChannel::class];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*/
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
return (new MailMessage)
|
||||
->line('Welcome to Coolify!')
|
||||
->action('Go to dashboard', url('/'))
|
||||
->line('We need your attention for disk usage.');
|
||||
}
|
||||
|
||||
public function toDiscord(object $notifiable): string
|
||||
{
|
||||
return 'Welcome to Coolify! We need your attention for disk usage. [Go to dashboard]('.url('/').')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(object $notifiable): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user