(method string)
| 588 | } |
| 589 | |
| 590 | func (a AlertService) validateCommunityAlertMethod(method string) error { |
| 591 | if global.CONF.Base.IsEnterprise || global.CONF.Base.Edition == "cn" { |
| 592 | return nil |
| 593 | } |
| 594 | if strings.TrimSpace(method) == "" { |
| 595 | return nil |
| 596 | } |
| 597 | |
| 598 | for _, item := range strings.Split(method, ",") { |
| 599 | item = strings.TrimSpace(item) |
| 600 | if item == "" { |
| 601 | continue |
| 602 | } |
| 603 | if configID, err := strconv.ParseUint(item, 10, 64); err == nil { |
| 604 | config, err := alertRepo.GetConfigById(uint(configID)) |
| 605 | if err != nil { |
| 606 | return err |
| 607 | } |
| 608 | if _, ok := communityAlertMethodTypeNames[config.Type]; ok { |
| 609 | return buserr.WithErr("ErrAlertMethodNotSupported", nil) |
| 610 | } |
| 611 | continue |
| 612 | } |
| 613 | if _, ok := communityAlertMethodTypeNames[item]; ok { |
| 614 | return buserr.WithErr("ErrAlertMethodNotSupported", nil) |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | return nil |
| 619 | } |
| 620 | |
| 621 | func (a AlertService) validateCommunityAlertConfigType(configType string) error { |
| 622 | if global.CONF.Base.IsEnterprise || global.CONF.Base.Edition == "cn" { |
no test coverage detected