Skip to content

Modern Docker Management, Designed for Everyone

fix: add missing title to ntfy provider (#1955)

Kyle Mendell31000548dbcb
diff --git a/backend/internal/models/notification.go b/backend/internal/models/notification.go
index 911d6d1f1..44e68bc39 100644
--- a/backend/internal/models/notification.go
+++ b/backend/internal/models/notification.go
@@ -142,6 +142,7 @@ type NtfyConfig struct {
Topic string `json:"topic"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"` //nolint:gosec // JSON schema compatibility with external provider config
+ Title string `json:"title,omitempty"`
Priority string `json:"priority,omitempty"`
Tags []string `json:"tags,omitempty"`
Icon string `json:"icon,omitempty"`
diff --git a/backend/internal/services/notification_service.go b/backend/internal/services/notification_service.go
index 97e193979..f4a894cc9 100644
--- a/backend/internal/services/notification_service.go
+++ b/backend/internal/services/notification_service.go
@@ -3125,9 +3125,6 @@ func (s *NotificationService) sendNtfyPruneNotification(ctx context.Context, res
s.formatBytesInternal(result.VolumeSpaceReclaimed),
s.formatBytesInternal(result.BuildCacheSpaceReclaimed))
- // Ntfy sends the title as part of the message or needs a separate header not currently in config
- // For now, we omit the title attribute as it is not in the struct
-
return notifications.SendNtfy(ctx, ntfyConfig, message)
}
diff --git a/backend/internal/utils/notifications/ntfy_sender.go b/backend/internal/utils/notifications/ntfy_sender.go
index 854f8c741..fda1f926c 100644
--- a/backend/internal/utils/notifications/ntfy_sender.go
+++ b/backend/internal/utils/notifications/ntfy_sender.go
@@ -47,6 +47,10 @@ func BuildNtfyURL(config models.NtfyConfig) (string, error) {
// Add query parameters
q := u.Query()
+ if config.Title != "" {
+ q.Set("title", config.Title)
+ }
+
if config.Priority != "" {
q.Set("priority", config.Priority)
}
diff --git a/backend/internal/utils/notifications/ntfy_sender_test.go b/backend/internal/utils/notifications/ntfy_sender_test.go
index dcc8747f7..295299b3e 100644
--- a/backend/internal/utils/notifications/ntfy_sender_test.go
+++ b/backend/internal/utils/notifications/ntfy_sender_test.go
@@ -71,10 +71,11 @@ func TestBuildNtfyURL(t *testing.T) {
},
},
{
- name: "config with priority and tags",
+ name: "config with title priority and tags",
config: models.NtfyConfig{
Host: "ntfy.sh",
Topic: "alerts",
+ Title: "Arcane Update",
Priority: "high",
Tags: []string{"warning", "server"},
Cache: true,
@@ -82,7 +83,7 @@ func TestBuildNtfyURL(t *testing.T) {
},
wantErr: false,
check: func(url string) bool {
- return url == "ntfy://ntfy.sh/alerts?cache=yes&firebase=yes&priority=high&tags=warning%2Cserver"
+ return url == "ntfy://ntfy.sh/alerts?cache=yes&firebase=yes&priority=high&tags=warning%2Cserver&title=Arcane+Update"
},
},
{
@@ -100,6 +101,7 @@ func TestBuildNtfyURL(t *testing.T) {
Topic: "test",
Username: "user",
Password: "pass",
+ Title: "Arcane Alert",
Priority: "max",
Tags: []string{"urgent"},
Icon: "https://example.com/icon.png",
@@ -109,7 +111,7 @@ func TestBuildNtfyURL(t *testing.T) {
},
wantErr: false,
check: func(url string) bool {
- return url == "ntfy://user:[email protected]:8080/test?cache=no&disabletls=yes&firebase=no&icon=https%3A%2F%2Fexample.com%2Ficon.png&priority=max&tags=urgent"
+ return url == "ntfy://user:[email protected]:8080/test?cache=no&disabletls=yes&firebase=no&icon=https%3A%2F%2Fexample.com%2Ficon.png&priority=max&tags=urgent&title=Arcane+Alert"
},
},
}
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index f3ace1183..020bfaa5c 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -1824,6 +1824,9 @@
"notifications_ntfy_password_help": "Password for authentication (if required by server)",
"notifications_ntfy_priority_label": "Priority",
"notifications_ntfy_priority_help": "Notification priority level (Min=1, Low=2, Default=3, High=4, Max/Urgent=5)",
+ "notifications_ntfy_title_label": "Title (Optional)",
+ "notifications_ntfy_title_placeholder": "Container Update",
+ "notifications_ntfy_title_help": "Optional title override for notifications",
"notifications_ntfy_tags_label": "Tags (Optional)",
"notifications_ntfy_tags_placeholder": "warning, server, docker",
"notifications_ntfy_tags_help": "Comma-separated list of tags (may map to emojis on supported clients)",
diff --git a/frontend/src/lib/types/notification-providers.ts b/frontend/src/lib/types/notification-providers.ts
index 452ddec79..65f120e8d 100644
--- a/frontend/src/lib/types/notification-providers.ts
+++ b/frontend/src/lib/types/notification-providers.ts
@@ -78,6 +78,7 @@ export interface NtfyFormValues extends BaseProviderFormValues {
topic: string;
username: string;
password: string;
+ title: string;
priority: string;
tags: string;
icon: string;
@@ -402,6 +403,7 @@ export function ntfySettingsToFormValues(settings?: NotificationSettings): NtfyF
topic: (cfg?.topic as string) || '',
username: (cfg?.username as string) || '',
password: (cfg?.password as string) || '',
+ title: (cfg?.title as string) || '',
priority: (cfg?.priority as string) || 'default',
tags: Array.isArray(cfg?.tags) ? (cfg.tags as string[]).join(', ') : '',
icon: (cfg?.icon as string) || '',
@@ -509,6 +511,7 @@ export function ntfyFormValuesToSettings(values: NtfyFormValues): NotificationSe
topic: values.topic,
username: values.username,
password: values.password,
+ title: values.title,
priority: values.priority,
tags: values.tags
.split(',')
diff --git a/frontend/src/routes/(app)/settings/notifications/providers/BuiltInProviderForm.svelte b/frontend/src/routes/(app)/settings/notifications/providers/BuiltInProviderForm.svelte
index 582c1d7ae..c13fac622 100644
--- a/frontend/src/routes/(app)/settings/notifications/providers/BuiltInProviderForm.svelte
+++ b/frontend/src/routes/(app)/settings/notifications/providers/BuiltInProviderForm.svelte
@@ -277,6 +277,7 @@
topic: z.string(),
username: z.string(),
password: z.string(),
+ title: z.string(),
priority: z.string(),
tags: z.string(),
icon: z.string(),
@@ -759,6 +760,14 @@
helpText: m.notifications_ntfy_password_help(),
inputType: 'password'
},
+ {
+ kind: 'input',
+ key: 'title',
+ id: 'ntfy-title',
+ label: m.notifications_ntfy_title_label(),
+ placeholder: m.notifications_ntfy_title_placeholder(),
+ helpText: m.notifications_ntfy_title_help()
+ },
{
kind: 'native-select',
key: 'priority',