Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: preserve notification event subscriptions on partial settings updates and warn when none are subscribed (#3925)
Kyle Mendell817444abbd79
diff --git a/backend/internal/notification/notification.go b/backend/internal/notification/notification.goindex b1cf859d7..b8c88250c 100644--- a/backend/internal/notification/notification.go+++ b/backend/internal/notification/notification.go@@ -10,6 +10,7 @@ import ("log/slog""maps""net/http"+ "slices""strings""time"@@ -359,6 +360,11 @@ func (s *NotificationService) CreateOrUpdateSettings(ctx context.Context, providreturn nil, encryptErr}config = encryptedConfig+ if _, ok := config["events"]; !ok {+ if existingEvents, ok := existingConfig["events"]; ok {+ config["events"] = existingEvents+ }+ }if err != nil {setting = NotificationSettings{@@ -1217,9 +1223,15 @@ func (s *NotificationService) testNotificationWarningInternal(setting *Notificatif !setting.Enabled {return fmt.Sprintf("%s is disabled, so real notifications will not send", setting.Provider)}- if eventType := notificationEventTypeForTestTypeInternal(testType); eventType != "" && !s.isEventEnabled(setting.Config, eventType) {+ eventType := notificationEventTypeForTestTypeInternal(testType)+ if eventType != "" && !s.isEventEnabled(setting.Config, eventType) {return fmt.Sprintf("%s events are disabled for %s, so real notifications will not send", eventType, setting.Provider)}+ if eventType == "" && !slices.ContainsFunc(notifications.AllNotificationEventTypes, func(candidate notifications.NotificationEventType) bool {+ return s.isEventEnabled(setting.Config, candidate)+ }) {+ return fmt.Sprintf("no events are subscribed for %s, so real notifications will not send", setting.Provider)+ }return ""}diff --git a/backend/pkg/utils/notifications/config.go b/backend/pkg/utils/notifications/config.goindex b14218dc9..7bef0cbb9 100644--- a/backend/pkg/utils/notifications/config.go+++ b/backend/pkg/utils/notifications/config.go@@ -45,6 +45,14 @@ const (NotificationEventAutoHeal NotificationEventType = "auto_heal")+var AllNotificationEventTypes = []NotificationEventType{+ NotificationEventImageUpdate,+ NotificationEventContainerUpdate,+ NotificationEventVulnerabilityFound,+ NotificationEventPruneReport,+ NotificationEventAutoHeal,+}+type EmailTLSMode stringconst (diff --git a/backend/pkg/utils/notifications/config_credentials.go b/backend/pkg/utils/notifications/config_credentials.goindex b85f23c88..8896b95b0 100644--- a/backend/pkg/utils/notifications/config_credentials.go+++ b/backend/pkg/utils/notifications/config_credentials.go@@ -77,6 +77,12 @@ func PrepareNtfyConfig(config database.JSON, providerName string, requireTopic bif requireTopic && ntfyConfig.Topic == "" {return NtfyConfig{}, errors.New("ntfy topic is required")}+ if _, ok := config["cache"]; !ok {+ ntfyConfig.Cache = true+ }+ if _, ok := config["firebase"]; !ok {+ ntfyConfig.Firebase = true+ }if err := DecryptStringCredential(&ntfyConfig.Password); err != nil {return NtfyConfig{}, err}