diff --git a/backend/app/service/clam.go b/backend/app/service/clam.go index cb1b82a15..f318105f7 100644 --- a/backend/app/service/clam.go +++ b/backend/app/service/clam.go @@ -249,15 +249,17 @@ func (c *ClamService) Update(req dto.ClamUpdate) error { if err := clamRepo.Update(req.ID, upMap); err != nil { return err } - updateAlert := dto.CreateOrUpdateAlert{ - AlertTitle: req.AlertTitle, - AlertType: "clams", - AlertCount: req.AlertCount, - EntryID: clam.ID, - } - err := xpack.UpdateAlert(updateAlert) - if err != nil { - return err + if req.AlertCount != 0 { + updateAlert := dto.CreateOrUpdateAlert{ + AlertTitle: req.AlertTitle, + AlertType: "clams", + AlertCount: req.AlertCount, + EntryID: clam.ID, + } + err := xpack.UpdateAlert(updateAlert) + if err != nil { + return err + } } return nil } diff --git a/backend/app/service/cronjob.go b/backend/app/service/cronjob.go index 81dee96fa..2f700a3c3 100644 --- a/backend/app/service/cronjob.go +++ b/backend/app/service/cronjob.go @@ -316,15 +316,17 @@ func (u *CronjobService) Update(id uint, req dto.CronjobUpdate) error { if err != nil { return err } - updateAlert := dto.CreateOrUpdateAlert{ - AlertTitle: req.AlertTitle, - AlertType: cronModel.Type, - AlertCount: req.AlertCount, - EntryID: cronModel.ID, - } - err = xpack.UpdateAlert(updateAlert) - if err != nil { - return err + if req.AlertCount != 0 { + updateAlert := dto.CreateOrUpdateAlert{ + AlertTitle: req.AlertTitle, + AlertType: cronModel.Type, + AlertCount: req.AlertCount, + EntryID: cronModel.ID, + } + err = xpack.UpdateAlert(updateAlert) + if err != nil { + return err + } } return nil }