mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
cover?
This commit is contained in:
parent
4085a928a8
commit
ddd782d623
@ -168,20 +168,8 @@ func validateRule(c *gin.Context, r *model.AlertRule) error {
|
||||
if len(r.Rules) > 0 {
|
||||
for _, rule := range r.Rules {
|
||||
singleton.ServerLock.RLock()
|
||||
isCoverAll := rule.Cover == model.RuleCoverAll
|
||||
isCoverIgnoreAll := rule.Cover == model.RuleCoverIgnoreAll
|
||||
for s, enabled := range rule.Ignore {
|
||||
if isCoverAll {
|
||||
for id, server := range singleton.ServerList {
|
||||
if enabled && id == s {
|
||||
continue
|
||||
}
|
||||
if !server.HasPermission(c) {
|
||||
singleton.ServerLock.RUnlock()
|
||||
return singleton.Localizer.ErrorT("permission denied")
|
||||
}
|
||||
}
|
||||
} else if isCoverIgnoreAll && enabled {
|
||||
if enabled {
|
||||
if server, ok := singleton.ServerList[s]; ok {
|
||||
if !server.HasPermission(c) {
|
||||
singleton.ServerLock.RUnlock()
|
||||
|
@ -364,20 +364,8 @@ func validateServers(c *gin.Context, ss *model.Service) error {
|
||||
singleton.ServerLock.RLock()
|
||||
defer singleton.ServerLock.RUnlock()
|
||||
|
||||
isCoverAll := ss.Cover == model.ServiceCoverAll
|
||||
isCoverIgnoreAll := ss.Cover == model.ServiceCoverIgnoreAll
|
||||
|
||||
for s, enabled := range ss.SkipServers {
|
||||
if isCoverAll {
|
||||
for id, server := range singleton.ServerList {
|
||||
if enabled && id == s {
|
||||
continue
|
||||
}
|
||||
if !server.HasPermission(c) {
|
||||
return singleton.Localizer.ErrorT("permission denied")
|
||||
}
|
||||
}
|
||||
} else if isCoverIgnoreAll && enabled {
|
||||
if enabled {
|
||||
if server, ok := singleton.ServerList[s]; ok {
|
||||
if !server.HasPermission(c) {
|
||||
return singleton.Localizer.ErrorT("permission denied")
|
||||
|
Loading…
Reference in New Issue
Block a user