refresh email server pipeline when config change
This commit is contained in:
parent
d08c430356
commit
4223bd052d
|
@ -5,6 +5,7 @@
|
|||
package email
|
||||
|
||||
import (
|
||||
"infini.sh/console/plugin/api/email/common"
|
||||
"infini.sh/framework/core/api"
|
||||
)
|
||||
|
||||
|
@ -21,31 +22,9 @@ func InitAPI() {
|
|||
api.HandleAPIMethod(api.GET, "/email/server/_search", email.searchEmailServer)
|
||||
}
|
||||
|
||||
//func InitEmailServer() error {
|
||||
// q := orm.Query{
|
||||
// Size: 10,
|
||||
// }
|
||||
// q.Conds = orm.And(orm.Eq("enabled", true))
|
||||
// err, result := orm.Search(model.EmailServer{}, &q )
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
// if len(result.Result) == 0 {
|
||||
// return nil
|
||||
// }
|
||||
// for _, row := range result.Result {
|
||||
// emailServer := model.EmailServer{}
|
||||
// buf := util.MustToJSONBytes(row)
|
||||
// util.MustFromJSONBytes(buf, &emailServer)
|
||||
// err = emailServer.Validate(false)
|
||||
// if err != nil {
|
||||
// log.Error(err)
|
||||
// continue
|
||||
// }
|
||||
// err = common.StartEmailServer(&emailServer)
|
||||
// if err != nil {
|
||||
// log.Error(err)
|
||||
// }
|
||||
// }
|
||||
// return nil
|
||||
//}
|
||||
func InitEmailServer() error {
|
||||
if !common.CheckEmailPipelineExists() {
|
||||
return common.RefreshEmailServer()
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -148,11 +148,9 @@ func (h *EmailAPI) updateEmailServer(w http.ResponseWriter, req *http.Request, p
|
|||
log.Error(err)
|
||||
return
|
||||
}
|
||||
if obj.Enabled {
|
||||
err = common.RefreshEmailServer()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
err = common.RefreshEmailServer()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
h.WriteJSON(w, util.MapStr{
|
||||
|
|
|
@ -682,18 +682,16 @@ func (engine *Engine) Do(rule *alerting.Rule) error {
|
|||
// send recover message to channel
|
||||
recoverCfg := rule.RecoveryNotificationConfig
|
||||
if recoverCfg != nil && recoverCfg.Enabled {
|
||||
if recoverCfg.AcceptTimeRange.Include(time.Now()) {
|
||||
paramsCtx = newParameterCtx(rule, checkResults, util.MapStr{
|
||||
alerting2.ParamEventID: alertItem.ID,
|
||||
alerting2.ParamTimestamp: alertItem.Created.Unix(),
|
||||
})
|
||||
err = attachTitleMessageToCtx(recoverCfg.Title, recoverCfg.Message, paramsCtx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
actionResults, _ := performChannels(recoverCfg.Channels, paramsCtx)
|
||||
alertItem.ActionExecutionResults = actionResults
|
||||
paramsCtx = newParameterCtx(rule, checkResults, util.MapStr{
|
||||
alerting2.ParamEventID: alertItem.ID,
|
||||
alerting2.ParamTimestamp: alertItem.Created.Unix(),
|
||||
})
|
||||
err = attachTitleMessageToCtx(recoverCfg.Title, recoverCfg.Message, paramsCtx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
actionResults, _ := performChannels(recoverCfg.Channels, paramsCtx)
|
||||
alertItem.ActionExecutionResults = actionResults
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue