diff --git a/plugins/notifiers/client.go b/plugins/notifiers/client.go index a329d14f..9c94fbb9 100644 --- a/plugins/notifiers/client.go +++ b/plugins/notifiers/client.go @@ -89,40 +89,28 @@ func NewMultiClient(notifiers *[]Config, logger log.Logger) (*NotifyManager, err notifyManager := &NotifyManager{} for _, notifier := range *notifiers { if notifier.Provider == ProviderTypeSlack { - - httpClient := &http.Client{Timeout: 10 * time.Second} - - slackConfig, err := getSlackConfig(¬ifier, notifier.Messages) + slackConfig, err := NewSlackConfig(¬ifier) if err != nil { return nil, err - - } else { - slackClient := slack.NewNotifier(slackConfig, httpClient, logger) - notifyManager.addClient(slackClient) - notifyManager.addNotifier(notifier) } - + httpClient := &http.Client{Timeout: 10 * time.Second} + slackClient := slack.NewNotifier(slackConfig, httpClient, logger) + notifyManager.addClient(slackClient) + notifyManager.addNotifier(notifier) } if notifier.Provider == ProviderTypeLark { - - httpClient := &http.Client{Timeout: 10 * time.Second} - larkConfig, err := getLarkConfig(¬ifier, notifier.Messages) if err != nil { return nil, err - - } else { - larkClient := lark.NewNotifier(larkConfig, httpClient, logger) - notifyManager.addClient(larkClient) - notifyManager.addNotifier(notifier) } - + httpClient := &http.Client{Timeout: 10 * time.Second} + larkClient := lark.NewNotifier(larkConfig, httpClient, logger) + notifyManager.addClient(larkClient) + notifyManager.addNotifier(notifier) } - } return notifyManager, nil - } func NewClient(config *Config, logger log.Logger) (Client, error) { @@ -178,32 +166,6 @@ func NewSlackConfig(config *Config) (*slack.Config, error) { return slackConfig, nil } -func getSlackConfig(config *Config, messages domain.NotificationMessages) (*slack.Config, error) { - // validation - if config.AccessToken == "" { - return nil, errors.New("slack access token or workSpaceConfig must be provided") - } - - var slackConfig *slack.Config - if config.AccessToken != "" { - workspaces := []slack.SlackWorkspace{ - { - WorkspaceName: config.Provider, - AccessToken: config.AccessToken, - Criteria: config.Criteria, - }, - } - slackConfig = &slack.Config{ - Workspaces: workspaces, - Messages: messages, - } - return slackConfig, nil - - } - - return slackConfig, nil -} - func getLarkConfig(config *Config, messages domain.NotificationMessages) (*lark.Config, error) { // validation if config.ClientID == "" && config.ClientSecret == "" {