Allow sending helcase battle to custom discord webhook
All checks were successful
Push image to registry / build-image (push) Successful in 4m24s

This commit is contained in:
2025-03-20 19:28:40 +01:00
parent fadb4d2748
commit c26a09701a
4 changed files with 18 additions and 7 deletions

View File

@ -12,9 +12,9 @@ class AllNotification extends NotificationProvider {
/**
* @inheritDoc
*/
public static function send(\App\Notification\Notification $notification): void {
public static function send(\App\Notification\Notification $notification, array $options = []): void {
foreach (self::NOTIFICATIONS_PROVIDERS as $provider) {
$provider::send($notification);
$provider::send($notification, $options);
}
}
}

View File

@ -13,7 +13,7 @@ class DiscordWebHookNotification extends NotificationProvider {
/**
* @inheritDoc
*/
public static function send(\App\Notification\Notification $notification): void {
public static function send(\App\Notification\Notification $notification, array $options): void {
/*
Test Json for a complete embed :
{
@ -44,7 +44,7 @@ class DiscordWebHookNotification extends NotificationProvider {
"avatar_url": "https://www.fairytailrp.com/t40344-here-come-dat-boi"
}
*/
$webHookUrl = static::getDiscordWebHookUrl($notification->isError);
$webHookUrl = static::getDiscordWebHookUrl($notification->isError, $options);
$body = [
"content"=> "",
"tts"=> false,
@ -86,7 +86,11 @@ class DiscordWebHookNotification extends NotificationProvider {
curl_close($ch);
}
private static function getDiscordWebHookUrl(bool $isError): string {
private static function getDiscordWebHookUrl(bool $isError, array $options): string {
if ($options["discord_webhook_url"] !== null) {
return $options["discord_webhook_url"];
}
$generalWebHookUrlKey = 'discord_webhook_url';
$generalWebHookUrl = Cache::rememberForever($generalWebHookUrlKey, function () use ($generalWebHookUrlKey) {
return JobInfo::where('key', $generalWebHookUrlKey)->first()->value;