Add Unraid and Gotify notifications
This commit is contained in:
@@ -85,6 +85,7 @@ func (s *Service) LastRun(jobID string) time.Time {
|
||||
}
|
||||
|
||||
func (s *Service) SaveConfig(config model.Config) error {
|
||||
config = model.NormalizeConfig(config)
|
||||
for _, job := range config.Jobs {
|
||||
if job.Schedule.Cron != "" {
|
||||
if _, err := scheduler.Parse(job.Schedule.Cron); err != nil {
|
||||
@@ -316,12 +317,8 @@ func (s *Service) executeRestore(ctx context.Context, run model.Run) model.Run {
|
||||
}
|
||||
|
||||
func (s *Service) finishJob(run model.Run, job model.Job, result model.Run) model.Run {
|
||||
event := result.Status
|
||||
for _, wanted := range job.NotifyOn {
|
||||
if wanted == event {
|
||||
go s.notify(job.Name, result)
|
||||
break
|
||||
}
|
||||
if result.Status == "success" || result.Status == "warning" || result.Status == "failed" {
|
||||
go s.notify(job.Name, result)
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -330,7 +327,9 @@ func (s *Service) notify(name string, run model.Run) {
|
||||
for _, target := range s.Config().Notifications {
|
||||
for _, event := range target.Events {
|
||||
if event == run.Status {
|
||||
_ = s.notifier.Send(context.Background(), target, "Backupper: "+name, run.Message, run.Status)
|
||||
if err := s.notifier.Send(context.Background(), target, "Backupper: "+name, run.Message, run.Status); err != nil {
|
||||
s.log.Warn("send notification failed", "target", target.ID, "type", target.Type, "error", err)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user