Skip to content

Commit

Permalink
fix: map old notifier config to new multiple notifiers format
Browse files Browse the repository at this point in the history
  • Loading branch information
rahmatrhd committed Jul 23, 2024
1 parent e2d5e31 commit 6355db6
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,15 @@ func RunServer(config *Config) error {
logger := log.NewCtxLogger(config.LogLevel, []string{domain.TraceIDKey})
crypto := crypto.NewAES(config.EncryptionSecretKeyKey)
validator := validator.New()

notifierConfig := []notifiers.Config{}
if &config.Notifiers != nil {
if config.Notifiers != nil {
notifierConfig = config.Notifiers

} else {
// map old to the new format
var provider = config.Notifier.Provider
configSlack, err := notifiers.NewSlackConfig(&config.Notifier)
if err != nil {
return err
}
for _, workspace := range configSlack.Workspaces {
notifier_ := notifiers.Config{
Provider: provider,
AccessToken: workspace.AccessToken,
Criteria: "true",
}
notifierConfig = append(notifierConfig, notifier_)

}
oldConfig := config.Notifier
oldConfig.Criteria = "true"
notifierConfig = append(notifierConfig, oldConfig)
}
notifier, err := notifiers.NewMultiClient(&notifierConfig, logger)
if err != nil {
Expand Down

0 comments on commit 6355db6

Please sign in to comment.