Skip to content

Commit

Permalink
fix: notifier backward compatibility issue
Browse files Browse the repository at this point in the history
  • Loading branch information
utsav14nov committed Aug 30, 2024
1 parent b87bd5a commit 7a25c56
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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), &notifierMap)
if err != nil {
return fmt.Errorf("failed to parse notifier config: %w", err)
}
var notifierConfigMap map[string]notifiers.Config
err = mapstructure.Decode(notifierMap, &notifierConfigMap)
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), &notifierMap)
if err != nil {
return fmt.Errorf("failed to parse notifier config: %w", err)
}
var notifierConfigMap map[string]notifiers.Config
err = mapstructure.Decode(notifierMap, &notifierConfigMap)
if err != nil {
return fmt.Errorf("failed to parse notifier config: %w", err)
}

for _, val := range notifierConfigMap {
notifierConfig = append(notifierConfig, val)
}
Expand Down

0 comments on commit 7a25c56

Please sign in to comment.