(pushAlert dto.PushAlert)
| 15 | ) |
| 16 | |
| 17 | func 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 | |
| 42 | func pushByConfigId(alertRepo repo.IAlertRepo, alert dto.AlertDTO, pushAlert dto.PushAlert, configId uint) { |
| 43 | config, err := alertRepo.GetConfigById(configId) |
nothing calls this directly
no test coverage detected