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

Method checkAlertConfigSMSPhoneUnique

agent/app/service/alert.go:544–565  ·  view source on GitHub ↗
(req dto.AlertConfigUpdate)

Source from the content-addressed store, hash-verified

542}
543
544func (a AlertService) checkAlertConfigSMSPhoneUnique(req dto.AlertConfigUpdate) error {
545 if req.Type != constant.SMSConfig {
546 return nil
547 }
548
549 phone := alertConfigSMSPhone(req.Config)
550 configs, err := alertRepo.AlertConfigList(alertRepo.WithByType(req.Type))
551 if err != nil {
552 return err
553 }
554
555 for _, config := range configs {
556 if req.ID != 0 && config.ID == req.ID {
557 continue
558 }
559 if alertConfigSMSPhone(config.Config) == phone {
560 return buserr.New("ErrAlertConfigPhoneExist")
561 }
562 }
563
564 return nil
565}
566
567func (a AlertService) checkAlertConfigDisplayNameUnique(req dto.AlertConfigUpdate) error {
568 displayName := alertConfigDisplayName(req.Type, req.Config)

Callers 1

UpdateAlertConfigMethod · 0.95

Calls 3

alertConfigSMSPhoneFunction · 0.85
AlertConfigListMethod · 0.65
WithByTypeMethod · 0.65

Tested by

no test coverage detected