From 5ec2947d86acdedfd3b532aa5883b5e230cfe122 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Sat, 8 Nov 2025 10:32:27 +0000 Subject: [PATCH] Fix Pushover webhook custom field overrides (related to #665) The Pushover webhook template now honors user-defined custom fields for sound, priority, and device. Previously, these fields were hardcoded based on alert level, ignoring any custom values set by users in the UI. Changes: - sound: Uses CustomFields.sound if provided, otherwise falls back to level-based default (critical=siren, warning=tugboat, else=pushover) - priority: Uses CustomFields.priority if provided, otherwise falls back to level-based default (critical=1, warning=0, else=-1) - device: Uses CustomFields.device if provided, otherwise falls back to ResourceName Updated setup instructions to document optional custom fields for sound, priority, and device configuration. This allows users to customize Pushover notification behavior without editing webhook templates, consistent with Pulse's maintainability goals. --- internal/notifications/webhook_templates.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/notifications/webhook_templates.go b/internal/notifications/webhook_templates.go index 7642bdc..cee6ab1 100644 --- a/internal/notifications/webhook_templates.go +++ b/internal/notifications/webhook_templates.go @@ -241,12 +241,12 @@ func GetWebhookTemplates() []WebhookTemplate { "user": "{{.CustomFields.user_token}}", "title": "Pulse Alert: {{.Level | title}} - {{.ResourceName}}", "message": "{{.Message}}\n\n• Resource: {{.ResourceName}}\n• Node: {{.Node}}\n• Type: {{.Type | title}}\n• Value: {{if or (eq .Type "diskRead") (eq .Type "diskWrite")}}{{printf "%.1f" .Value}} MB/s{{else}}{{printf "%.1f" .Value}}%{{end}}\n• Threshold: {{if or (eq .Type "diskRead") (eq .Type "diskWrite")}}{{printf "%.0f" .Threshold}} MB/s{{else}}{{printf "%.0f" .Threshold}}%{{end}}\n• Duration: {{.Duration}}", - "priority": {{if eq .Level "critical"}}1{{else if eq .Level "warning"}}0{{else}}-1{{end}}, - "sound": "{{if eq .Level "critical"}}siren{{else if eq .Level "warning"}}tugboat{{else}}pushover{{end}}", - "device": "{{.ResourceName}}", + "priority": {{if .CustomFields.priority}}{{.CustomFields.priority}}{{else}}{{if eq .Level "critical"}}1{{else if eq .Level "warning"}}0{{else}}-1{{end}}{{end}}, + "sound": "{{if .CustomFields.sound}}{{.CustomFields.sound}}{{else}}{{if eq .Level "critical"}}siren{{else if eq .Level "warning"}}tugboat{{else}}pushover{{end}}{{end}}", + "device": "{{if .CustomFields.device}}{{.CustomFields.device}}{{else}}{{.ResourceName}}{{end}}", "timestamp": "{{.Timestamp}}" }`, - Instructions: "1. Create an application at https://pushover.net/apps\n2. Copy your Application Token\n3. Get your User Key from your Pushover dashboard\n4. URL: https://api.pushover.net/1/messages.json\n5. Add custom fields:\n • app_token: YOUR_APP_TOKEN\n • user_token: YOUR_USER_KEY", + Instructions: "1. Create an application at https://pushover.net/apps\n2. Copy your Application Token\n3. Get your User Key from your Pushover dashboard\n4. URL: https://api.pushover.net/1/messages.json\n5. Add custom fields:\n • app_token: YOUR_APP_TOKEN (required)\n • user_token: YOUR_USER_KEY (required)\n • sound: notification sound (optional, e.g., spacealarm, siren, tugboat)\n • priority: -2 to 2 (optional, overrides level-based default)\n • device: specific device name (optional, overrides ResourceName)", }, { Service: "gotify",