Merge branch 'main' into koda/ticket-create-notification-action
linter / quality (pull_request) Successful in 1m19s
tests / ci (8.4) (pull_request) Successful in 1m37s

# Conflicts:
#	resources/js/pages/projects/settings/Notifications.vue
This commit is contained in:
2026-04-25 20:35:38 +02:00
11 changed files with 372 additions and 124 deletions
@@ -2,6 +2,7 @@
namespace App\Actions\Notifications;
use App\Enums\DiscordAllowedMentionType;
use App\Enums\NotificationChannel;
use App\Enums\NotificationEventType;
use App\Http\Resources\NotificationActionResource;
@@ -22,6 +23,7 @@ class BuildProjectNotificationSettingsPayload
return [
'channelOptions' => NotificationChannel::options(),
'eventTypeOptions' => NotificationEventType::options(),
'discordAllowedMentionOptions' => DiscordAllowedMentionType::options(),
'notificationActions' => NotificationActionResource::collection(
$this->listProjectNotificationActions->handle($project),
)->resolve(),
@@ -2,6 +2,7 @@
namespace App\Actions\Notifications;
use App\Enums\DiscordAllowedMentionType;
use App\Enums\NotificationChannel;
use App\Enums\NotificationDeliveryStatus;
use App\Models\NotificationAction;
@@ -280,11 +281,53 @@ class DeliverNotificationAction implements ShouldQueue
->post($notificationAction->delivery_url, [
'content' => $message,
'allowed_mentions' => [
'parse' => [],
'parse' => $this->discordAllowedMentions($notificationAction),
],
]);
}
/**
* @return list<string>
*/
private function discordAllowedMentions(NotificationAction $notificationAction): array
{
$configuredAllowedMentions = data_get(
$notificationAction->channel_configuration,
'allowed_mentions',
[],
);
if (! is_array($configuredAllowedMentions)) {
return [];
}
$allowedMentions = [];
foreach ($configuredAllowedMentions as $allowedMention) {
if (! is_string($allowedMention)) {
continue;
}
$allowedMention = Str::lower(trim($allowedMention));
if ($allowedMention === '') {
continue;
}
if (! in_array($allowedMention, DiscordAllowedMentionType::values(), true)) {
continue;
}
if (in_array($allowedMention, $allowedMentions, true)) {
continue;
}
$allowedMentions[] = $allowedMention;
}
return $allowedMentions;
}
private function sendWebhookRequest(NotificationAction $notificationAction): Response
{
return Http::acceptJson()