MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / validateCommunityAlertMethod

Method validateCommunityAlertMethod

agent/app/service/alert.go:590–619  ·  view source on GitHub ↗
(method string)

Source from the content-addressed store, hash-verified

588}
589
590func (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
621func (a AlertService) validateCommunityAlertConfigType(configType string) error {
622 if global.CONF.Base.IsEnterprise || global.CONF.Base.Edition == "cn" {

Callers 3

CreateAlertMethod · 0.95
UpdateAlertMethod · 0.95
ExternalUpdateAlertMethod · 0.95

Calls 1

GetConfigByIdMethod · 0.65

Tested by

no test coverage detected