Skip to content

Commit c9cf1cf

Browse files
committed
refactor: change alert rule update api
1 parent 9d1c011 commit c9cf1cf

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

models/alert_rule.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,12 +525,19 @@ func (ar *AlertRule) Verify() error {
525525
return err
526526
}
527527

528-
if len(ar.NotifyRuleIds) > 0 {
529-
ar.NotifyVersion = 1
528+
if ar.NotifyVersion == 0 {
529+
// 如果是旧版本,则清空 NotifyRuleIds
530+
ar.NotifyRuleIds = []int64{}
531+
}
532+
533+
if ar.NotifyVersion > 0 {
534+
// 如果是新版本,则清空旧的通知媒介和通知组
530535
ar.NotifyChannelsJSON = []string{}
531536
ar.NotifyGroupsJSON = []string{}
532537
ar.NotifyChannels = ""
533538
ar.NotifyGroups = ""
539+
ar.Callbacks = ""
540+
ar.CallbacksJSON = []string{}
534541
}
535542

536543
return nil

0 commit comments

Comments
 (0)