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

Function PushAlert

agent/utils/alert_push/alert_push.go:17–40  ·  view source on GitHub ↗
(pushAlert dto.PushAlert)

Source from the content-addressed store, hash-verified

15)
16
17func PushAlert(pushAlert dto.PushAlert) error {
18 if !alertUtil.CheckSendTimeRange(alertUtil.GetCronJobType(pushAlert.AlertType)) {
19 return nil
20 }
21
22 alertRepo := repo.NewIAlertRepo()
23 alertInfo, err := alertRepo.Get(alertRepo.WithByType(pushAlert.AlertType), alertRepo.WithByProject(strconv.Itoa(int(pushAlert.EntryID))), repo.WithByStatus(constant.AlertEnable))
24 if err != nil {
25 return err
26 }
27 var alert dto.AlertDTO
28 _ = copier.Copy(&alert, &alertInfo)
29
30 methods := strings.Split(alert.Method, ",")
31 for _, m := range methods {
32 m = strings.TrimSpace(m)
33 if configId, err := strconv.ParseUint(m, 10, 64); err == nil {
34 pushByConfigId(alertRepo, alert, pushAlert, uint(configId))
35 } else {
36 pushByLegacyMethod(alertRepo, alert, pushAlert, m)
37 }
38 }
39 return nil
40}
41
42func pushByConfigId(alertRepo repo.IAlertRepo, alert dto.AlertDTO, pushAlert dto.PushAlert, configId uint) {
43 config, err := alertRepo.GetConfigById(configId)

Callers

nothing calls this directly

Calls 7

GetMethod · 0.95
WithByTypeMethod · 0.95
WithByProjectMethod · 0.95
pushByConfigIdFunction · 0.85
pushByLegacyMethodFunction · 0.85
CopyMethod · 0.80
WithByStatusMethod · 0.65

Tested by

no test coverage detected