mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat(notifications): add Pushover (#598)
* feat(notifications): add pushover * add db migration * fix lint error * some small corrections * fixed README * added missing columns to postgres_migrate.go * use token for user_key * refactor(notifications): change priority to int * fix: only test selected events --------- Co-authored-by: soup <soup@r4tio.dev> Co-authored-by: ze0s <ze0s@riseup.net>
This commit is contained in:
parent
1b8f2fce3c
commit
da5492febb
12 changed files with 290 additions and 37 deletions
|
@ -125,6 +125,8 @@ func (s *service) registerSenders() {
|
|||
s.senders = append(s.senders, NewNotifiarrSender(s.log, n))
|
||||
case domain.NotificationTypeTelegram:
|
||||
s.senders = append(s.senders, NewTelegramSender(s.log, n))
|
||||
case domain.NotificationTypePushover:
|
||||
s.senders = append(s.senders, NewPushoverSender(s.log, n))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -236,6 +238,8 @@ func (s *service) Test(ctx context.Context, notification domain.Notification) er
|
|||
agent = NewNotifiarrSender(s.log, notification)
|
||||
case domain.NotificationTypeTelegram:
|
||||
agent = NewTelegramSender(s.log, notification)
|
||||
case domain.NotificationTypePushover:
|
||||
agent = NewPushoverSender(s.log, notification)
|
||||
default:
|
||||
s.log.Error().Msgf("unsupported notification type: %v", notification.Type)
|
||||
return errors.New("unsupported notification type")
|
||||
|
@ -245,9 +249,15 @@ func (s *service) Test(ctx context.Context, notification domain.Notification) er
|
|||
|
||||
for _, event := range events {
|
||||
e := event
|
||||
g.Go(func() error {
|
||||
return agent.Send(e.Event, e)
|
||||
})
|
||||
|
||||
if !enabledEvent(notification.Events, e.Event) {
|
||||
continue
|
||||
}
|
||||
|
||||
if err := agent.Send(e.Event, e); err != nil {
|
||||
s.log.Error().Err(err).Msgf("error sending test notification: %#v", notification)
|
||||
return err
|
||||
}
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
|
@ -259,3 +269,13 @@ func (s *service) Test(ctx context.Context, notification domain.Notification) er
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func enabledEvent(events []string, e domain.NotificationEvent) bool {
|
||||
for _, v := range events {
|
||||
if v == string(e) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue