Add Discord allowed mentions configuration to notification settings #64

Merged
Twyco merged 3 commits from koda/allowed-mentions-ui-for-discord into main 2026-04-25 18:31:26 +00:00
2 changed files with 10 additions and 3 deletions
Showing only changes of commit 22caed4fa1 - Show all commits
@@ -26,6 +26,10 @@ class StoreProjectNotificationActionRequest extends FormRequest
*/
public function rules(): array
{
$messageTemplateRules = $this->input('channel') === NotificationChannel::Discord->value
? ['required', 'string', 'max:2000']
: ['nullable', 'string', 'max:2000'];
return [
'name' => ['required', 'string', 'max:255'],
'event_type' => ['required', 'string', Rule::in(NotificationEventType::values())],
@@ -35,7 +39,7 @@ class StoreProjectNotificationActionRequest extends FormRequest
'channel_configuration.allowed_mentions.*' => ['nullable', 'string', Rule::in(DiscordAllowedMentionType::values())],
'enabled' => ['required', 'boolean'],
'delivery_url' => ['required', 'string', 'max:2048', 'url'],
'message_template' => [Rule::requiredIf($this->input('channel') === NotificationChannel::Discord->value), 'string', 'max:2000'],
'message_template' => $messageTemplateRules,
];
}
}
@@ -11,7 +11,6 @@ use Illuminate\Validation\Rule;
class UpdateProjectNotificationActionRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
@@ -27,6 +26,10 @@ class UpdateProjectNotificationActionRequest extends FormRequest
*/
public function rules(): array
{
$messageTemplateRules = $this->input('channel') === NotificationChannel::Discord->value
? ['required', 'string', 'max:2000']
: ['nullable', 'string', 'max:2000'];
return [
'name' => ['required', 'string', 'max:255'],
'event_type' => ['required', 'string', Rule::in(NotificationEventType::values())],
@@ -36,7 +39,7 @@ class UpdateProjectNotificationActionRequest extends FormRequest
'channel_configuration.allowed_mentions.*' => ['nullable', 'string', Rule::in(DiscordAllowedMentionType::values())],
'enabled' => ['required', 'boolean'],
'delivery_url' => ['nullable', 'string', 'max:2048', 'url'],
'message_template' => [Rule::requiredIf($this->input('channel') === NotificationChannel::Discord->value), 'string', 'max:2000'],
'message_template' => $messageTemplateRules,
];
}
}