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

Method UpdateAlertConfig

agent/app/service/alert.go:508–542  ·  view source on GitHub ↗
(req dto.AlertConfigUpdate, operator string)

Source from the content-addressed store, hash-verified

506}
507
508func (a AlertService) UpdateAlertConfig(req dto.AlertConfigUpdate, operator string) error {
509 if err := a.validateCommunityAlertConfigType(req.Type); err != nil {
510 return err
511 }
512 if err := a.checkAlertConfigDisplayNameUnique(req); err != nil {
513 return err
514 }
515 if err := a.checkAlertConfigSMSPhoneUnique(req); err != nil {
516 return err
517 }
518 if req.ID != 0 {
519 upMap := make(map[string]interface{})
520 upMap["id"] = req.ID
521 upMap["type"] = req.Type
522 upMap["title"] = req.Title
523 upMap["status"] = req.Status
524 upMap["config"] = req.Config
525 upMap["update_user"] = operator
526 if err := alertRepo.UpdateAlertConfig(upMap, repo.WithByID(req.ID)); err != nil {
527 return err
528 }
529 } else {
530 var alertConfig model.AlertConfig
531 if err := copier.Copy(&alertConfig, &req); err != nil {
532 return buserr.WithErr("ErrStructTransform", err)
533 }
534 alertConfig.CreateUser = operator
535 alertConfig.UpdateUser = operator
536 if err := alertRepo.CreateAlertConfig(&alertConfig); err != nil {
537 return err
538 }
539 }
540
541 return nil
542}
543
544func (a AlertService) checkAlertConfigSMSPhoneUnique(req dto.AlertConfigUpdate) error {
545 if req.Type != constant.SMSConfig {

Callers

nothing calls this directly

Calls 7

CopyMethod · 0.80
UpdateAlertConfigMethod · 0.65
WithByIDMethod · 0.65
CreateAlertConfigMethod · 0.65

Tested by

no test coverage detected