2023-05-19 17:01:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Notifications\Channels;
|
|
|
|
|
|
|
|
|
|
use App\Jobs\SendMessageToDiscordJob;
|
|
|
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
|
|
|
|
|
|
class DiscordChannel
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Send the given notification.
|
|
|
|
|
*/
|
2025-01-07 14:31:43 +00:00
|
|
|
public function send(SendsDiscord $notifiable, Notification $notification): void
|
2023-05-19 17:01:56 +00:00
|
|
|
{
|
2024-09-29 22:43:35 +00:00
|
|
|
$message = $notification->toDiscord();
|
2024-12-09 16:36:23 +00:00
|
|
|
|
2025-01-07 14:31:43 +00:00
|
|
|
$discordSettings = $notifiable->discordNotificationSettings;
|
2024-12-09 16:36:23 +00:00
|
|
|
|
|
|
|
|
if (! $discordSettings || ! $discordSettings->isEnabled() || ! $discordSettings->discord_webhook_url) {
|
2023-08-24 19:00:19 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2024-12-09 16:36:23 +00:00
|
|
|
|
2025-03-21 11:16:33 +00:00
|
|
|
if (! $discordSettings->discord_ping_enabled) {
|
|
|
|
|
$message->isCritical = false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-09 16:36:23 +00:00
|
|
|
SendMessageToDiscordJob::dispatch($message, $discordSettings->discord_webhook_url);
|
2023-05-19 17:01:56 +00:00
|
|
|
}
|
|
|
|
|
}
|