From 577c402a5b76bb01c585b5b127db0da6fb921a66 Mon Sep 17 00:00:00 2001 From: Ulric Qin Date: Wed, 12 Oct 2022 20:37:21 +0800 Subject: [PATCH] support: callback_del --- src/webapi/router/router_alert_rule.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/webapi/router/router_alert_rule.go b/src/webapi/router/router_alert_rule.go index 5fd13f2e..9ada06c1 100644 --- a/src/webapi/router/router_alert_rule.go +++ b/src/webapi/router/router_alert_rule.go @@ -209,7 +209,8 @@ func alertRulePutFields(c *gin.Context) { if callbacks, has := f.Fields["callbacks"]; has { callback := callbacks.(string) if !strings.Contains(ar.Callbacks, callback) { - f.Fields["callbacks"] = ar.Callbacks + " " + callback + ginx.Dangerous(ar.UpdateFieldsMap(map[string]interface{}{"callbacks": ar.Callbacks + " " + callback})) + continue } } } @@ -217,7 +218,9 @@ func alertRulePutFields(c *gin.Context) { if f.Action == "callback_del" { // 删除一个 callback 地址 if callbacks, has := f.Fields["callbacks"]; has { - f.Fields["callbacks"] = strings.ReplaceAll(ar.Callbacks, callbacks.(string), "") + callback := callbacks.(string) + ginx.Dangerous(ar.UpdateFieldsMap(map[string]interface{}{"callbacks": strings.ReplaceAll(ar.Callbacks, callback, "")})) + continue } }