From 17dec929a049e98020097cd192667a02ec088db2 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Sun, 18 Jan 2026 15:16:37 +0000 Subject: [PATCH] feat: Add mention support for webhook alerts. Related to #1118 Adds a Mention field to webhook configurations that allows users to tag individuals or groups when alerts are sent. This works with: - Discord: @everyone, <@USER_ID>, <@&ROLE_ID> - Microsoft Teams: @General, user email - Mattermost: @channel, @all, @username The mention is included in the webhook payload via the {{.Mention}} template variable. Built-in templates for Discord, Slack, and Teams now conditionally include mentions when configured. Backend changes: - Add Mention field to WebhookConfig struct - Add Mention field to WebhookPayloadData for template access - Pass mention through sendGroupedWebhook Frontend changes: - Add mention field to Webhook interface - Add Mention input to webhook configuration form - Show service-specific help text for mention formats --- frontend-modern/src/api/notifications.ts | 1 + .../src/components/Alerts/WebhookConfig.tsx | 57 +++++++++++++++---- internal/notifications/notifications.go | 2 + internal/notifications/notifications_test.go | 7 ++- internal/notifications/webhook_enhanced.go | 1 + internal/notifications/webhook_templates.go | 17 ++++-- 6 files changed, 68 insertions(+), 17 deletions(-) diff --git a/frontend-modern/src/api/notifications.ts b/frontend-modern/src/api/notifications.ts index 9ea531d1e..1d8a145ec 100644 --- a/frontend-modern/src/api/notifications.ts +++ b/frontend-modern/src/api/notifications.ts @@ -55,6 +55,7 @@ export interface Webhook { enabled: boolean; service?: string; // Added to support Discord, Slack, etc. customFields?: Record; + mention?: string; // Platform-specific mention (e.g., @everyone, @channel, <@USER_ID>) } export interface AppriseConfig { diff --git a/frontend-modern/src/components/Alerts/WebhookConfig.tsx b/frontend-modern/src/components/Alerts/WebhookConfig.tsx index 9565fc73c..d7c192952 100644 --- a/frontend-modern/src/components/Alerts/WebhookConfig.tsx +++ b/frontend-modern/src/components/Alerts/WebhookConfig.tsx @@ -121,6 +121,7 @@ export function WebhookConfig(props: WebhookConfigProps) { enabled: true, payloadTemplate: '', customFields: {}, + mention: '', }); const [templates, setTemplates] = createSignal([]); const [showServiceDropdown, setShowServiceDropdown] = createSignal(false); @@ -190,6 +191,7 @@ export function WebhookConfig(props: WebhookConfigProps) { service: data.service, template: data.payloadTemplate, customFields, + mention: data.mention, }); setEditingId(null); setAdding(false); @@ -206,6 +208,7 @@ export function WebhookConfig(props: WebhookConfigProps) { service: data.service, template: data.payloadTemplate, customFields, + mention: data.mention, }; props.onAdd(newWebhook); // Reset form and close the adding panel @@ -218,9 +221,10 @@ export function WebhookConfig(props: WebhookConfigProps) { enabled: true, payloadTemplate: '', customFields: {}, + mention: '', }); setHeaderInputs([]); - setCustomFieldInputs([]); + setCustomFieldInputs([]); setAdding(false); } }; @@ -237,6 +241,7 @@ export function WebhookConfig(props: WebhookConfigProps) { enabled: true, payloadTemplate: '', customFields: {}, + mention: '', }); setHeaderInputs([]); setCustomFieldInputs([]); @@ -251,6 +256,7 @@ export function WebhookConfig(props: WebhookConfigProps) { service: webhook.service || 'generic', payloadTemplate: webhook.template || '', customFields: webhook.customFields || {}, + mention: webhook.mention || '', }); // Set up header inputs for editing const headers = webhook.headers || {}; @@ -366,11 +372,10 @@ export function WebhookConfig(props: WebhookConfigProps) { {webhook.name} @@ -455,11 +460,10 @@ export function WebhookConfig(props: WebhookConfigProps) {