add enabled field to channel

This commit is contained in:
liugq 2023-07-27 15:15:15 +08:00
parent e6d08bc128
commit 3f5beb7c9f
2 changed files with 4 additions and 0 deletions

View File

@ -17,6 +17,7 @@ type Channel struct {
SearchText string `json:"-" elastic_mapping:"search_text:{type:text,index_prefixes:{},index_phrases:true, analyzer:suggest_text_search }"`
SubType string `json:"sub_type" elastic_mapping:"sub_type:{type:keyword,copy_to:search_text}"`
Email *Email `json:"email,omitempty" elastic_mapping:"email:{type:object}"`
Enabled bool `json:"enabled" elastic_mapping:"enabled:{type:boolean}"`
}

View File

@ -959,6 +959,9 @@ func performChannels(channels []alerting.Channel, ctx map[string]interface{}) ([
var errCount int
var actionResults []alerting.ActionExecutionResult
for _, channel := range channels {
if !channel.Enabled {
continue
}
resBytes, err, messageBytes := common.PerformChannel(&channel, ctx)
var errStr string
if err != nil {