Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
feat(notifications): improve ntfy notification formatting (#4336)
Maghuro1899f0b7da30
diff --git a/backend/internal/notification/children/templates/service.go b/backend/internal/notification/children/templates/service.goindex 6ebaa659a..aaff2c818 100644--- a/backend/internal/notification/children/templates/service.go+++ b/backend/internal/notification/children/templates/service.go@@ -35,7 +35,8 @@ func (s *Service) ImageUpdate(environmentName, imageRef string, updateInfo *imagText: notifications.TextByFormat(func(format notifications.MessageFormat) string {return notifications.BuildImageUpdateNotificationMessage(format, environmentName, imageRef, updateInfo)}),- Title: "Container Image Update",+ Title: "Container Image Update",+ NtfyTitle: "π¦ Container Image Update",RenderEmail: func() (string, string, error) {htmlBody, _, err := s.renderEmailTemplateInternal(environmentName, imageRef, updateInfo)if err != nil {@@ -54,7 +55,8 @@ func (s *Service) ContainerUpdate(environmentName, containerName, imageRef, oldDText: notifications.TextByFormat(func(format notifications.MessageFormat) string {return notifications.BuildContainerUpdateNotificationMessage(format, environmentName, containerName, imageRef, oldDigest, newDigest)}),- Title: "Container Updated",+ Title: "Container Updated",+ NtfyTitle: "β Container Updated",RenderEmail: func() (string, string, error) {htmlBody, _, err := s.renderContainerUpdateEmailTemplateInternal(environmentName, containerName, imageRef, oldDigest, newDigest)if err != nil {@@ -83,6 +85,7 @@ func (s *Service) Vulnerability(environmentName string, payload notification.Dis)}),Title: defaultTitle,+ NtfyTitle: "π‘οΈ Daily Vulnerability Summary",DefaultTitle: defaultTitle,RenderEmail: func() (string, string, error) {htmlBody, _, err := s.renderVulnerabilitySummaryEmailTemplateInternal(environmentName, payload)@@ -98,11 +101,17 @@ func (s *Service) Vulnerability(environmentName string, payload notification.Dis}func (s *Service) BatchImageUpdate(environmentName string, updates map[string]*imageupdate.Response) notifications.Content {+ ntfyTitle := fmt.Sprintf("π¦ %d Container Image Updates", len(updates))+ if len(updates) == 1 {+ ntfyTitle = "π¦ 1 Container Image Update"+ }+return notifications.Content{Text: notifications.TextByFormat(func(format notifications.MessageFormat) string {return notifications.BuildBatchImageUpdateNotificationMessage(format, environmentName, updates)}),- Title: "Container Image Updates Available",+ Title: "Container Image Updates Available",+ NtfyTitle: ntfyTitle,RenderEmail: func() (string, string, error) {htmlBody, _, err := s.renderBatchEmailTemplateInternal(environmentName, updates)if err != nil {@@ -117,11 +126,17 @@ func (s *Service) BatchImageUpdate(environmentName string, updates map[string]*i}func (s *Service) BatchContainerUpdate(environmentName string, entries []notifications.ContainerUpdateBatchEntry) notifications.Content {+ ntfyTitle := fmt.Sprintf("β %d Containers Updated", len(entries))+ if len(entries) == 1 {+ ntfyTitle = "β 1 Container Updated"+ }+return notifications.Content{Text: notifications.TextByFormat(func(format notifications.MessageFormat) string {return notifications.BuildBatchContainerUpdateNotificationMessage(format, environmentName, entries)}),- Title: "Containers Updated",+ Title: "Containers Updated",+ NtfyTitle: ntfyTitle,RenderEmail: func() (string, string, error) {htmlBody, _, err := s.renderBatchContainerUpdateEmailTemplateInternal(environmentName, entries)if err != nil {@@ -144,6 +159,7 @@ func (s *Service) PruneReport(environmentName string, result *system.PruneAllResreturn notifications.BuildPruneReportNotificationMessage(format, environmentName, result)}),Title: defaultTitle,+ NtfyTitle: "π§Ή System Prune Complete",DefaultTitle: defaultTitle,RenderEmail: func() (string, string, error) {htmlBody, _, err := s.renderPruneReportEmailTemplateInternal(environmentName, result)@@ -163,6 +179,7 @@ func (s *Service) AutoHeal(environmentName, containerName string) notifications.return notifications.BuildAutoHealNotificationMessage(format, environmentName, containerName)}),Title: defaultTitle,+ NtfyTitle: "β€οΈβπ©Ή Container Auto-Healed",DefaultTitle: defaultTitle,RenderEmail: func() (string, string, error) {subject := notifications.BuildEmailSubject(environmentName, fmt.Sprintf("Auto Heal: Container '%s' Restarted", containerName))diff --git a/backend/pkg/utils/notifications/deliver.go b/backend/pkg/utils/notifications/deliver.goindex f32fb8046..14c27cc90 100644--- a/backend/pkg/utils/notifications/deliver.go+++ b/backend/pkg/utils/notifications/deliver.go@@ -21,6 +21,10 @@ type Content struct {// Title is the generic-webhook title.Title string+ // NtfyTitle is the event-specific ntfy title used when the provider does+ // not have a custom title configured.+ NtfyTitle string+// DefaultTitle is applied to pushover/gotify when their config has no// title; "" means don't default.DefaultTitle string@@ -202,7 +206,10 @@ func deliverNtfy(ctx context.Context, config database.JSON, c Content) error {if err != nil {return err}- if sendNtfyErr := SendNtfy(ctx, ntfyConfig, c.Text[MessageFormatPlain]); sendNtfyErr != nil {+ if ntfyConfig.Title == "" {+ ntfyConfig.Title = c.NtfyTitle+ }+ if sendNtfyErr := SendNtfy(ctx, ntfyConfig, c.Text[MessageFormatNtfyMarkdown]); sendNtfyErr != nil {return fmt.Errorf("failed to send Ntfy notification: %w", sendNtfyErr)}return nil@@ -289,7 +296,13 @@ func deliverGeneric(ctx context.Context, config database.JSON, c Content) error// TextByFormat builds the per-format message map for Content.Text from a// single messages.go builder closure.func TextByFormat(build func(MessageFormat) string) map[MessageFormat]string {- formats := []MessageFormat{MessageFormatMarkdown, MessageFormatHTML, MessageFormatSlack, MessageFormatPlain}+ formats := []MessageFormat{+ MessageFormatMarkdown,+ MessageFormatNtfyMarkdown,+ MessageFormatHTML,+ MessageFormatSlack,+ MessageFormatPlain,+ }text := make(map[MessageFormat]string, len(formats))for _, format := range formats {text[format] = build(format)diff --git a/backend/pkg/utils/notifications/deliver_test.go b/backend/pkg/utils/notifications/deliver_test.goindex 6913d59b0..f5dfc701c 100644--- a/backend/pkg/utils/notifications/deliver_test.go+++ b/backend/pkg/utils/notifications/deliver_test.go@@ -36,8 +36,9 @@ func TestTextByFormat_BuildsEveryFormat(t *testing.T) {return "msg:" + string(format)})- require.Len(t, text, 4)+ require.Len(t, text, 5)require.Equal(t, "msg:"+string(MessageFormatMarkdown), text[MessageFormatMarkdown])+ require.Equal(t, "msg:"+string(MessageFormatNtfyMarkdown), text[MessageFormatNtfyMarkdown])require.Equal(t, "msg:"+string(MessageFormatHTML), text[MessageFormatHTML])require.Equal(t, "msg:"+string(MessageFormatSlack), text[MessageFormatSlack])require.Equal(t, "msg:"+string(MessageFormatPlain), text[MessageFormatPlain])diff --git a/backend/pkg/utils/notifications/messages.go b/backend/pkg/utils/notifications/messages.goindex 373d56d2a..007b5c313 100644--- a/backend/pkg/utils/notifications/messages.go+++ b/backend/pkg/utils/notifications/messages.go@@ -1,6 +1,7 @@package notificationsimport (+ "encoding/hex""fmt""maps""slices"@@ -15,10 +16,11 @@ import (type MessageFormat stringconst (- MessageFormatPlain MessageFormat = "plain"- MessageFormatMarkdown MessageFormat = "markdown"- MessageFormatSlack MessageFormat = "slack"- MessageFormatHTML MessageFormat = "html"+ MessageFormatPlain MessageFormat = "plain"+ MessageFormatMarkdown MessageFormat = "markdown"+ MessageFormatNtfyMarkdown MessageFormat = "ntfy_markdown"+ MessageFormatSlack MessageFormat = "slack"+ MessageFormatHTML MessageFormat = "html")func formatNotificationTitleInternal(format MessageFormat, title string) string {@@ -65,6 +67,10 @@ func formatNotificationCodeInternal(format MessageFormat, value string) string {}func BuildImageUpdateNotificationMessage(format MessageFormat, environmentName, imageRef string, updateInfo *imageupdate.Response) string {+ if format == MessageFormatNtfyMarkdown {+ return buildNtfyImageUpdateNotificationMessageInternal(environmentName, imageRef, updateInfo)+ }+updateStatus := kit.Ternary(updateInfo != nil && updateInfo.HasUpdate, "Update Available", "No Update")if format != MessageFormatPlain && updateStatus == "Update Available" {updateStatus = "β οΈ Update Available"@@ -89,6 +95,10 @@ func BuildImageUpdateNotificationMessage(format MessageFormat, environmentName,}func BuildContainerUpdateNotificationMessage(format MessageFormat, environmentName, containerName, imageRef, oldDigest, newDigest string) string {+ if format == MessageFormatNtfyMarkdown {+ return buildNtfyContainerUpdateNotificationMessageInternal(environmentName, containerName, imageRef, oldDigest, newDigest)+ }+status := kit.Ternary(format != MessageFormatPlain, "β Updated Successfully", "Updated Successfully")var message strings.Builder@@ -109,6 +119,10 @@ func BuildContainerUpdateNotificationMessage(format MessageFormat, environmentNa}func BuildBatchImageUpdateNotificationMessage(format MessageFormat, environmentName string, updates map[string]*imageupdate.Response) string {+ if format == MessageFormatNtfyMarkdown {+ return buildNtfyBatchImageUpdateNotificationMessageInternal(environmentName, updates)+ }+title := "Container Image Updates Available"description := fmt.Sprintf("%d container image(s) have updates available.", len(updates))if len(updates) == 1 {@@ -160,6 +174,10 @@ type ContainerUpdateBatchEntry struct {// BuildBatchContainerUpdateNotificationMessage builds a formatted notification for a batch of container updates.func BuildBatchContainerUpdateNotificationMessage(format MessageFormat, environmentName string, entries []ContainerUpdateBatchEntry) string {+ if format == MessageFormatNtfyMarkdown {+ return buildNtfyBatchContainerUpdateNotificationMessageInternal(environmentName, entries)+ }+title := "Containers Updated"description := fmt.Sprintf("%d container(s) were updated.", len(entries))if len(entries) == 1 {@@ -201,6 +219,17 @@ func BuildBatchContainerUpdateNotificationMessage(format MessageFormat, environm}func BuildVulnerabilitySummaryNotificationMessage(format MessageFormat, environmentName, summaryLabel, overview, fixableCount, severityBreakdown, sampleCVEs string) string {+ if format == MessageFormatNtfyMarkdown {+ return buildNtfyVulnerabilitySummaryNotificationMessageInternal(+ environmentName,+ summaryLabel,+ overview,+ fixableCount,+ severityBreakdown,+ sampleCVEs,+ )+ }+var message strings.Builderfmt.Fprintf(&message, "%s\n\n", formatNotificationTitleInternal(format, "π Daily Vulnerability Summary"))@@ -225,6 +254,10 @@ func BuildVulnerabilitySummaryNotificationMessage(format MessageFormat, environm}func BuildPruneReportNotificationMessage(format MessageFormat, environmentName string, result *system.PruneAllResult) string {+ if format == MessageFormatNtfyMarkdown {+ return buildNtfyPruneReportNotificationMessageInternal(environmentName, result)+ }+var message strings.Builderfmt.Fprintf(&message, "%s\n\n", formatNotificationTitleInternal(format, "π§Ή System Prune Report"))fmt.Fprintf(&message, "%s %s\n", formatNotificationLabelInternal(format, "Environment"), environmentName)@@ -238,6 +271,10 @@ func BuildPruneReportNotificationMessage(format MessageFormat, environmentName s}func BuildAutoHealNotificationMessage(format MessageFormat, environmentName, containerName string) string {+ if format == MessageFormatNtfyMarkdown {+ return buildNtfyAutoHealNotificationMessageInternal(environmentName, containerName)+ }+var message strings.Builderfmt.Fprintf(&message, "%s\n\n", formatNotificationTitleInternal(format, "Auto Heal"))fmt.Fprintf(&message, "%s %s\n", formatNotificationLabelInternal(format, "Environment"), environmentName)@@ -246,19 +283,279 @@ func BuildAutoHealNotificationMessage(format MessageFormat, environmentName, conreturn message.String()}-func FormatBytes(bytes uint64) string {+func shortenNotificationDigestInternal(value string) string {+ trimmed := strings.TrimSpace(value)+ algorithm, digest, found := strings.Cut(trimmed, ":")+ if !found {+ return trimmed+ }++ var expectedLength int+ switch algorithm {+ case "sha256":+ expectedLength = 64+ case "sha384":+ expectedLength = 96+ case "sha512":+ expectedLength = 128+ default:+ return trimmed+ }+ if len(digest) != expectedLength {+ return trimmed+ }+ if _, err := hex.DecodeString(digest); err != nil {+ return trimmed+ }++ return algorithm + ":" + digest[:6] + "..."+}++func ntfyUpdateTransitionInternal(update *imageupdate.Response) (string, string) {+ if update == nil {+ return "", ""+ }++ if update.UpdateType == "tag" && (update.CurrentVersion != "" || update.LatestVersion != "") {+ return update.CurrentVersion, update.LatestVersion+ }++ if update.CurrentDigest != "" || update.LatestDigest != "" {+ return shortenNotificationDigestInternal(update.CurrentDigest),+ shortenNotificationDigestInternal(update.LatestDigest)+ }++ return update.CurrentVersion, update.LatestVersion+}++func writeNtfyTransitionInternal(message *strings.Builder, current, latest, indent string) bool {+ if current == "" && latest == "" {+ return false+ }++ switch {+ case current != "" && latest != "":+ fmt.Fprintf(+ message,+ "%sπ `%s` β `%s`\n",+ indent,+ current,+ latest,+ )+ case latest != "":+ fmt.Fprintf(message, "%sπ `%s`\n", indent, latest)+ default:+ fmt.Fprintf(message, "%sπ `%s`\n", indent, current)+ }++ return true+}++func byteMagnitudeInternal(bytes uint64) (float64, int) {const unit = 1024if bytes < unit {- return fmt.Sprintf("%d B", bytes)+ return float64(bytes), -1}- div, exp := int64(unit), 0+ div, exp := uint64(unit), 0for n := bytes / unit; n >= unit; n /= unit {div *= unitexp++}- return fmt.Sprintf("%.1f %cB", float64(bytes)/float64(div), "KMGTPE"[exp])+ return float64(bytes) / float64(div), exp+}++func formatNtfyBytesInternal(bytes uint64) string {+ value, exp := byteMagnitudeInternal(bytes)+ if exp < 0 {+ return fmt.Sprintf("%d B", bytes)+ }++ units := []string{"KiB", "MiB", "GiB", "TiB", "PiB", "EiB"}+ return fmt.Sprintf("%.1f %s", value, units[exp])+}++func buildNtfyImageUpdateNotificationMessageInternal(+ environmentName,+ imageRef string,+ updateInfo *imageupdate.Response,+) string {+ var message strings.Builder++ fmt.Fprintf(&message, "π₯οΈ %s\n\n", environmentName)+ fmt.Fprintf(&message, "π¦ **%s**\n", imageRef)++ if updateInfo == nil {+ fmt.Fprintln(&message, "βΉοΈ Update details unavailable")+ return message.String()+ }++ if !updateInfo.HasUpdate {+ fmt.Fprintln(&message, "β Already up to date")+ return message.String()+ }++ current, latest := ntfyUpdateTransitionInternal(updateInfo)+ if !writeNtfyTransitionInternal(&message, current, latest, "") {+ fmt.Fprintln(&message, "β οΈ Update available")+ }++ return message.String()+}++func buildNtfyContainerUpdateNotificationMessageInternal(+ environmentName,+ containerName,+ imageRef,+ oldDigest,+ newDigest string,+) string {+ var message strings.Builder++ fmt.Fprintf(&message, "π₯οΈ %s\n\n", environmentName)+ fmt.Fprintf(&message, "π³ **%s**\n", containerName)+ fmt.Fprintf(&message, "π¦ `%s`\n", imageRef)++ if !writeNtfyTransitionInternal(+ &message,+ shortenNotificationDigestInternal(oldDigest),+ shortenNotificationDigestInternal(newDigest),+ "",+ ) {+ fmt.Fprintln(&message, "β Updated successfully")+ }++ return message.String()+}++func buildNtfyBatchImageUpdateNotificationMessageInternal(+ environmentName string,+ updates map[string]*imageupdate.Response,+) string {+ imageRefs := slices.Sorted(maps.Keys(updates))++ var message strings.Builder+ fmt.Fprintf(&message, "π₯οΈ %s\n", environmentName)++ for _, imageRef := range imageRefs {+ update := updates[imageRef]++ fmt.Fprintf(&message, "\nπ¦ **%s**\n", imageRef)++ current, latest := ntfyUpdateTransitionInternal(update)+ if !writeNtfyTransitionInternal(&message, current, latest, " ") {+ fmt.Fprintln(&message, " β οΈ Update available")+ }+ }++ return message.String()+}++func buildNtfyBatchContainerUpdateNotificationMessageInternal(+ environmentName string,+ entries []ContainerUpdateBatchEntry,+) string {+ sorted := make([]ContainerUpdateBatchEntry, len(entries))+ copy(sorted, entries)++ sort.Slice(sorted, func(i, j int) bool {+ return sorted[i].ContainerName < sorted[j].ContainerName+ })++ var message strings.Builder+ fmt.Fprintf(&message, "π₯οΈ %s\n", environmentName)++ for _, entry := range sorted {+ fmt.Fprintf(&message, "\nπ³ **%s**\n", entry.ContainerName)+ fmt.Fprintf(&message, " π¦ `%s`\n", entry.ImageRef)++ if !writeNtfyTransitionInternal(+ &message,+ shortenNotificationDigestInternal(entry.OldDigest),+ shortenNotificationDigestInternal(entry.NewDigest),+ " ",+ ) {+ fmt.Fprintln(&message, " β Updated successfully")+ }+ }++ return message.String()+}++func buildNtfyVulnerabilitySummaryNotificationMessageInternal(+ environmentName,+ summaryLabel,+ overview,+ fixableCount,+ severityBreakdown,+ sampleCVEs string,+) string {+ var message strings.Builder++ fmt.Fprintf(&message, "π₯οΈ %s\n", environmentName)++ if strings.TrimSpace(summaryLabel) != "" {+ fmt.Fprintf(&message, "\nπ **%s**\n", summaryLabel)+ }+ if strings.TrimSpace(overview) != "" {+ fmt.Fprintf(&message, "π¦ %s\n", overview)+ }+ if strings.TrimSpace(fixableCount) != "" {+ fmt.Fprintf(&message, "π οΈ %s\n", fixableCount)+ }+ if strings.TrimSpace(severityBreakdown) != "" {+ severityItems := strings.Fields(severityBreakdown)+ fmt.Fprintf(&message, "π¨ %s\n", strings.Join(severityItems, " β’ "))+ }+ if strings.TrimSpace(sampleCVEs) != "" {+ fmt.Fprintf(&message, "π `%s`\n", sampleCVEs)+ }++ return message.String()+}++func buildNtfyPruneReportNotificationMessageInternal(+ environmentName string,+ result *system.PruneAllResult,+) string {+ var message strings.Builder++ fmt.Fprintf(&message, "π₯οΈ %s\n", environmentName)+ fmt.Fprintf(+ &message,+ "πΎ **%s** reclaimed\n\n",+ formatNtfyBytesInternal(result.SpaceReclaimed),+ )+ fmt.Fprintf(&message, "π¦ Images: %s\n", formatNtfyBytesInternal(result.ImageSpaceReclaimed))+ fmt.Fprintf(&message, "π§± Containers: %s\n", formatNtfyBytesInternal(result.ContainerSpaceReclaimed))+ fmt.Fprintf(&message, "πΏ Volumes: %s\n", formatNtfyBytesInternal(result.VolumeSpaceReclaimed))+ fmt.Fprintf(&message, "π οΈ Build cache: %s\n", formatNtfyBytesInternal(result.BuildCacheSpaceReclaimed))++ return message.String()+}++func buildNtfyAutoHealNotificationMessageInternal(+ environmentName,+ containerName string,+) string {+ var message strings.Builder++ fmt.Fprintf(&message, "π₯οΈ %s\n\n", environmentName)+ fmt.Fprintf(&message, "π³ **%s**\n", containerName)+ fmt.Fprintln(&message, "π Restarted automatically")+ fmt.Fprintln(&message, "β οΈ Reason: container was unhealthy")++ return message.String()+}++func FormatBytes(bytes uint64) string {+ value, exp := byteMagnitudeInternal(bytes)+ if exp < 0 {+ return fmt.Sprintf("%d B", bytes)+ }++ return fmt.Sprintf("%.1f %cB", value, "KMGTPE"[exp])}func BuildEmailSubject(environmentName, subject string) string {diff --git a/backend/pkg/utils/notifications/messages_test.go b/backend/pkg/utils/notifications/messages_test.gonew file mode 100644index 000000000..3da2f8af5--- /dev/null+++ b/backend/pkg/utils/notifications/messages_test.go@@ -0,0 +1,300 @@+package notifications++import (+ "strings"+ "testing"++ "github.com/getarcaneapp/arcane/types/v2/imageupdate"+ "github.com/getarcaneapp/arcane/types/v2/system"+ "github.com/stretchr/testify/require"+)++func TestNtfyNotificationMessagesVisualLayout(t *testing.T) {+ currentDigest := "sha256:6ef4b819f722fccdc036af611c4774cfdc2de821ab74fdd48bbf4c9d6f8973da"+ latestDigest := "sha256:4c599cf0818965782f93f652bd843e92714992e84d6b88ad17713dc0951cda1f"++ tests := []struct {+ name string+ build func() string+ contains []string+ notContains []string+ }{+ {+ name: "single image update",+ build: func() string {+ return BuildImageUpdateNotificationMessage(+ MessageFormatNtfyMarkdown,+ "Local Docker",+ "binwiederhier/ntfy:latest",+ &imageupdate.Response{+ HasUpdate: true,+ UpdateType: "digest",+ CurrentDigest: currentDigest,+ LatestDigest: latestDigest,+ },+ )+ },+ contains: []string{+ "π₯οΈ Local Docker",+ "π¦ **binwiederhier/ntfy:latest**",+ "π `sha256:6ef4b8...` β `sha256:4c599c...`",+ },+ notContains: []string{+ "Container Image Update",+ "Update Type:",+ currentDigest,+ latestDigest,+ },+ },+ {+ name: "batch image updates",+ build: func() string {+ return BuildBatchImageUpdateNotificationMessage(+ MessageFormatNtfyMarkdown,+ "Local Docker",+ map[string]*imageupdate.Response{+ "binwiederhier/ntfy:latest": {+ HasUpdate: true,+ UpdateType: "digest",+ CurrentDigest: currentDigest,+ LatestDigest: latestDigest,+ },+ "postgres:18": {+ HasUpdate: true,+ UpdateType: "tag",+ CurrentVersion: "17",+ LatestVersion: "18",+ },+ },+ )+ },+ contains: []string{+ "π¦ **binwiederhier/ntfy:latest**",+ "π `sha256:6ef4b8...` β `sha256:4c599c...`",+ "π¦ **postgres:18**",+ "π `17` β `18`",+ },+ notContains: []string{+ "Container Image Updates Available",+ "Type:",+ },+ },+ {+ name: "single container update",+ build: func() string {+ return BuildContainerUpdateNotificationMessage(+ MessageFormatNtfyMarkdown,+ "Local Docker",+ "jellyfin",+ "jellyfin/jellyfin:latest",+ currentDigest,+ latestDigest,+ )+ },+ contains: []string{+ "π³ **jellyfin**",+ "π¦ `jellyfin/jellyfin:latest`",+ "π `sha256:6ef4b8...` β `sha256:4c599c...`",+ },+ notContains: []string{+ "Container Updated",+ "Previous Version:",+ "Current Version:",+ },+ },+ {+ name: "batch container updates",+ build: func() string {+ return BuildBatchContainerUpdateNotificationMessage(+ MessageFormatNtfyMarkdown,+ "Local Docker",+ []ContainerUpdateBatchEntry{+ {+ ContainerName: "jellyfin",+ ImageRef: "jellyfin/jellyfin:latest",+ OldDigest: currentDigest,+ NewDigest: latestDigest,+ },+ {+ ContainerName: "ntfy",+ ImageRef: "binwiederhier/ntfy:latest",+ OldDigest: currentDigest,+ NewDigest: latestDigest,+ },+ },+ )+ },+ contains: []string{+ "π³ **jellyfin**",+ "π³ **ntfy**",+ "π `sha256:6ef4b8...` β `sha256:4c599c...`",+ },+ notContains: []string{+ "Containers Updated",+ "Previous Version:",+ },+ },+ {+ name: "single container update with image tags",+ build: func() string {+ return BuildContainerUpdateNotificationMessage(+ MessageFormatNtfyMarkdown,+ "Local Docker",+ "nginx",+ "nginx:1.27-alpine",+ "nginx:1.26-alpine",+ "nginx:1.27-alpine",+ )+ },+ contains: []string{+ "π¦ `nginx:1.27-alpine`",+ "π `nginx:1.26-alpine` β `nginx:1.27-alpine`",+ },+ notContains: []string{+ "nginx:1.26-a...",+ "nginx:1.27-a...",+ },+ },+ {+ name: "batch container updates with image tags",+ build: func() string {+ return BuildBatchContainerUpdateNotificationMessage(+ MessageFormatNtfyMarkdown,+ "Local Docker",+ []ContainerUpdateBatchEntry{+ {+ ContainerName: "nginx",+ ImageRef: "nginx:1.27-alpine",+ OldDigest: "nginx:1.26-alpine",+ NewDigest: "nginx:1.27-alpine",+ },+ {+ ContainerName: "private-registry",+ ImageRef: "registry.example.com:5000/example/app:1.27-alpine",+ OldDigest: "registry.example.com:5000/example/app:1.26-alpine",+ NewDigest: "registry.example.com:5000/example/app:1.27-alpine",+ },+ },+ )+ },+ contains: []string{+ "π³ **nginx**",+ "π `nginx:1.26-alpine` β `nginx:1.27-alpine`",+ "π³ **private-registry**",+ "π `registry.example.com:5000/example/app:1.26-alpine` β `registry.example.com:5000/example/app:1.27-alpine`",+ },+ notContains: []string{+ "alpine...",+ },+ },+ {+ name: "vulnerability summary",+ build: func() string {+ return BuildVulnerabilitySummaryNotificationMessage(+ MessageFormatNtfyMarkdown,+ "Local Docker",+ "Daily Summary - 2026-10-07",+ "5 image(s) scanned, 2 with fixable vulnerabilities",+ "7 fixable vulnerability record(s)",+ "Critical:1 High:3 Medium:2 Low:1 Unknown:0",+ "CVE-2025-1234, CVE-2025-5678",+ )+ },+ contains: []string{+ "π **Daily Summary - 2026-10-07**",+ "π¦ 5 image(s) scanned, 2 with fixable vulnerabilities",+ "π οΈ 7 fixable vulnerability record(s)",+ "π¨ Critical:1 β’ High:3 β’ Medium:2 β’ Low:1 β’ Unknown:0",+ "π `CVE-2025-1234, CVE-2025-5678`",+ },+ notContains: []string{+ "Daily Vulnerability Summary",+ "Severity Breakdown:",+ },+ },+ {+ name: "prune report",+ build: func() string {+ return BuildPruneReportNotificationMessage(+ MessageFormatNtfyMarkdown,+ "Local Docker",+ &system.PruneAllResult{+ SpaceReclaimed: 3825205248,+ ContainerSpaceReclaimed: 503316480,+ ImageSpaceReclaimed: 2449473536,+ VolumeSpaceReclaimed: 641728512,+ BuildCacheSpaceReclaimed: 230162432,+ },+ )+ },+ contains: []string{+ "πΎ **3.6 GiB** reclaimed",+ "π¦ Images: 2.3 GiB",+ "π§± Containers: 480.0 MiB",+ "πΏ Volumes: 612.0 MiB",+ "π οΈ Build cache: 219.5 MiB",+ },+ notContains: []string{+ "System Prune Report",+ "Breakdown:",+ },+ },+ {+ name: "auto heal",+ build: func() string {+ return BuildAutoHealNotificationMessage(+ MessageFormatNtfyMarkdown,+ "Local Docker",+ "jellyfin",+ )+ },+ contains: []string{+ "π³ **jellyfin**",+ "π Restarted automatically",+ "β οΈ Reason: container was unhealthy",+ },+ notContains: []string{+ "Container Auto-Healed",+ "Status:",+ },+ },+ }++ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ message := tt.build()++ require.True(+ t,+ strings.HasPrefix(message, "π₯οΈ Local Docker"),+ )++ for _, expected := range tt.contains {+ require.Contains(t, message, expected)+ }++ for _, unexpected := range tt.notContains {+ require.NotContains(t, message, unexpected)+ }+ })+ }+}++func TestNtfyImageUpdateTagUsesVersions(t *testing.T) {+ message := BuildImageUpdateNotificationMessage(+ MessageFormatNtfyMarkdown,+ "Local Docker",+ "example/app:1.2",+ &imageupdate.Response{+ HasUpdate: true,+ UpdateType: "tag",+ CurrentVersion: "1.2.3",+ LatestVersion: "1.3.0",+ CurrentDigest: "sha256:1111111111111111111111111111111111111111111111111111111111111111",+ LatestDigest: "sha256:2222222222222222222222222222222222222222222222222222222222222222",+ },+ )++ require.Contains(t, message, "π `1.2.3` β `1.3.0`")+ require.NotContains(t, message, "sha256:")+}diff --git a/backend/pkg/utils/notifications/ntfy_sender.go b/backend/pkg/utils/notifications/ntfy_sender.goindex 1bf56df45..cf695c0f5 100644--- a/backend/pkg/utils/notifications/ntfy_sender.go+++ b/backend/pkg/utils/notifications/ntfy_sender.go@@ -60,6 +60,9 @@ func BuildNtfyURL(config NtfyConfig) (string, error) {q.Set("icon", config.Icon)}+ // Arcane notification bodies use Markdown for improved readability.+ q.Set("markdown", "yes")+// Always send explicit cache/firebase params to avoid ambiguityif config.Cache {q.Set("cache", "yes")diff --git a/backend/pkg/utils/notifications/ntfy_sender_test.go b/backend/pkg/utils/notifications/ntfy_sender_test.goindex 18e0a05cc..524649686 100644--- a/backend/pkg/utils/notifications/ntfy_sender_test.go+++ b/backend/pkg/utils/notifications/ntfy_sender_test.go@@ -24,7 +24,7 @@ func TestBuildNtfyURL(t *testing.T) {},wantErr: false,check: func(url string) bool {- return url == "ntfy://ntfy.sh/test-topic?cache=yes&firebase=yes"+ return url == "ntfy://ntfy.sh/test-topic?cache=yes&firebase=yes&markdown=yes"},},{@@ -37,7 +37,7 @@ func TestBuildNtfyURL(t *testing.T) {},wantErr: false,check: func(url string) bool {- return url == "ntfy://ntfy.example.com/alerts?cache=yes&firebase=yes"+ return url == "ntfy://ntfy.example.com/alerts?cache=yes&firebase=yes&markdown=yes"},},{@@ -51,7 +51,7 @@ func TestBuildNtfyURL(t *testing.T) {},wantErr: false,check: func(url string) bool {- return url == "ntfy://ntfy.example.com:8080/updates?cache=yes&firebase=yes"+ return url == "ntfy://ntfy.example.com:8080/updates?cache=yes&firebase=yes&markdown=yes"},},{@@ -67,7 +67,7 @@ func TestBuildNtfyURL(t *testing.T) {},wantErr: false,check: func(url string) bool {- return url == "ntfy://user:[email protected]:443/private?cache=yes&firebase=yes"+ return url == "ntfy://user:[email protected]:443/private?cache=yes&firebase=yes&markdown=yes"},},{@@ -83,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&title=Arcane+Update"+ return url == "ntfy://ntfy.sh/alerts?cache=yes&firebase=yes&markdown=yes&priority=high&tags=warning%2Cserver&title=Arcane+Update"},},{@@ -112,7 +112,7 @@ func TestBuildNtfyURL(t *testing.T) {wantErr: false,check: func(url string) bool {return url == "ntfy://user:[email protected]:8080/test?cache=no&disabletlsverification=yes&firebase=no&icon=htt"+- "ps%3A%2F%2Fexample.com%2Ficon.png&priority=max&tags=urgent&title=Arcane+Alert"+ "ps%3A%2F%2Fexample.com%2Ficon.png&markdown=yes&priority=max&tags=urgent&title=Arcane+Alert"},},}@@ -144,6 +144,7 @@ func TestBuildNtfyURLDisableTLSVerificationUsesCertificateVerificationFlag(t *terequire.NoError(t, err)query := parsedURL.Query()+ assert.Equal(t, "yes", query.Get("markdown"))assert.Equal(t, "yes", query.Get("disabletlsverification"))assert.Empty(t, query.Get("disabletls"))}@@ -162,6 +163,7 @@ func TestBuildNtfyURLDisableTLSUsesPlainHTTPFlag(t *testing.T) {require.NoError(t, err)query := parsedURL.Query()+ assert.Equal(t, "yes", query.Get("markdown"))assert.Equal(t, "yes", query.Get("disabletls"))assert.Empty(t, query.Get("disabletlsverification"))}