From 7a25c56a964a239300904f17b4ca43802fc682ab Mon Sep 17 00:00:00 2001 From: utsav14nov Date: Fri, 30 Aug 2024 18:01:16 +0530 Subject: [PATCH] fix: notifier backward compatibility issue --- internal/server/server.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/internal/server/server.go b/internal/server/server.go index 0f8db794..ed4aac90 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -53,18 +53,19 @@ func RunServer(config *Config) error { crypto := crypto.NewAES(config.EncryptionSecretKeyKey) validator := validator.New() - var notifierMap map[string]interface{} - err := json.Unmarshal([]byte(config.Notifiers), ¬ifierMap) - if err != nil { - return fmt.Errorf("failed to parse notifier config: %w", err) - } - var notifierConfigMap map[string]notifiers.Config - err = mapstructure.Decode(notifierMap, ¬ifierConfigMap) - if err != nil { - return fmt.Errorf("failed to parse notifier config: %w", err) - } notifierConfig := []notifiers.Config{} if config.Notifiers != "" { + var notifierMap map[string]interface{} + err := json.Unmarshal([]byte(config.Notifiers), ¬ifierMap) + if err != nil { + return fmt.Errorf("failed to parse notifier config: %w", err) + } + var notifierConfigMap map[string]notifiers.Config + err = mapstructure.Decode(notifierMap, ¬ifierConfigMap) + if err != nil { + return fmt.Errorf("failed to parse notifier config: %w", err) + } + for _, val := range notifierConfigMap { notifierConfig = append(notifierConfig, val) }