未验证 提交 7164b696 编写于 作者: S shardingHe 提交者: GitHub

Change validate rule ignore non-default channels (#1680)

* change validate rule ignore non-default channels

* refactor code

---------
Co-authored-by: NshardingHe <wangzihe@flashcat.cloud>
Co-authored-by: NYening Qin <710leo@gmail.com>
上级 87281677
......@@ -305,6 +305,15 @@ func (rt *Router) alertRuleValidation(c *gin.Context) {
ancs := make([]string, 0, len(f.NotifyChannelsJSON)) //absent Notify Channels
for i := range f.NotifyChannelsJSON {
flag := true
//ignore non-default channels
switch f.NotifyChannelsJSON[i] {
case models.Dingtalk, models.Wecom, models.Feishu, models.Mm,
models.Telegram, models.Email, models.FeishuCard:
// do nothing
default:
continue
}
//default channels
for ui := range users {
if _, b := users[ui].ExtractToken(f.NotifyChannelsJSON[i]); b {
flag = false
......@@ -317,7 +326,7 @@ func (rt *Router) alertRuleValidation(c *gin.Context) {
}
if len(ancs) > 0 {
ginx.NewRender(c).Message(i18n.Sprintf(c.GetHeader("X-Language"), "All users are missing notify channel configurations. Please check for missing tokens (each channel should be configured with at least one user). %s", ancs))
ginx.NewRender(c).Message("All users are missing notify channel configurations. Please check for missing tokens (each channel should be configured with at least one user). %s", ancs)
return
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册