refresh email server pipeline when config change
This commit is contained in:
parent
d08c430356
commit
4223bd052d
|
@ -5,6 +5,7 @@
|
||||||
package email
|
package email
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"infini.sh/console/plugin/api/email/common"
|
||||||
"infini.sh/framework/core/api"
|
"infini.sh/framework/core/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,31 +22,9 @@ func InitAPI() {
|
||||||
api.HandleAPIMethod(api.GET, "/email/server/_search", email.searchEmailServer)
|
api.HandleAPIMethod(api.GET, "/email/server/_search", email.searchEmailServer)
|
||||||
}
|
}
|
||||||
|
|
||||||
//func InitEmailServer() error {
|
func InitEmailServer() error {
|
||||||
// q := orm.Query{
|
if !common.CheckEmailPipelineExists() {
|
||||||
// Size: 10,
|
return common.RefreshEmailServer()
|
||||||
// }
|
}
|
||||||
// q.Conds = orm.And(orm.Eq("enabled", true))
|
return nil
|
||||||
// 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
|
|
||||||
//}
|
|
|
@ -148,12 +148,10 @@ func (h *EmailAPI) updateEmailServer(w http.ResponseWriter, req *http.Request, p
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if obj.Enabled {
|
|
||||||
err = common.RefreshEmailServer()
|
err = common.RefreshEmailServer()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
h.WriteJSON(w, util.MapStr{
|
h.WriteJSON(w, util.MapStr{
|
||||||
"_id": obj.ID,
|
"_id": obj.ID,
|
||||||
|
|
|
@ -682,7 +682,6 @@ func (engine *Engine) Do(rule *alerting.Rule) error {
|
||||||
// send recover message to channel
|
// send recover message to channel
|
||||||
recoverCfg := rule.RecoveryNotificationConfig
|
recoverCfg := rule.RecoveryNotificationConfig
|
||||||
if recoverCfg != nil && recoverCfg.Enabled {
|
if recoverCfg != nil && recoverCfg.Enabled {
|
||||||
if recoverCfg.AcceptTimeRange.Include(time.Now()) {
|
|
||||||
paramsCtx = newParameterCtx(rule, checkResults, util.MapStr{
|
paramsCtx = newParameterCtx(rule, checkResults, util.MapStr{
|
||||||
alerting2.ParamEventID: alertItem.ID,
|
alerting2.ParamEventID: alertItem.ID,
|
||||||
alerting2.ParamTimestamp: alertItem.Created.Unix(),
|
alerting2.ParamTimestamp: alertItem.Created.Unix(),
|
||||||
|
@ -695,7 +694,6 @@ func (engine *Engine) Do(rule *alerting.Rule) error {
|
||||||
alertItem.ActionExecutionResults = actionResults
|
alertItem.ActionExecutionResults = actionResults
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
alertItem.State = alerting.AlertStateAlerting
|
alertItem.State = alerting.AlertStateAlerting
|
||||||
|
|
Loading…
Reference in New Issue