mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
fix(notifications): test handle unsupported type (#841)
* bugfix: nil pointer dereference if agent variable is nil when the Send method is called, will crash. * refactor: return early. * refactor: idiomatic solution. --------- Co-authored-by: KaiserBh <kaiserbh@proton.me>
This commit is contained in:
parent
fe71dfc3af
commit
e0aaa0bcab
1 changed files with 5 additions and 1 deletions
|
@ -8,6 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/autobrr/autobrr/internal/domain"
|
"github.com/autobrr/autobrr/internal/domain"
|
||||||
"github.com/autobrr/autobrr/internal/logger"
|
"github.com/autobrr/autobrr/internal/logger"
|
||||||
|
"github.com/autobrr/autobrr/pkg/errors"
|
||||||
|
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
)
|
)
|
||||||
|
@ -235,9 +236,12 @@ func (s *service) Test(ctx context.Context, notification domain.Notification) er
|
||||||
agent = NewNotifiarrSender(s.log, notification)
|
agent = NewNotifiarrSender(s.log, notification)
|
||||||
case domain.NotificationTypeTelegram:
|
case domain.NotificationTypeTelegram:
|
||||||
agent = NewTelegramSender(s.log, notification)
|
agent = NewTelegramSender(s.log, notification)
|
||||||
|
default:
|
||||||
|
s.log.Error().Msgf("unsupported notification type: %v", notification.Type)
|
||||||
|
return errors.New("unsupported notification type")
|
||||||
}
|
}
|
||||||
|
|
||||||
g, ctx := errgroup.WithContext(ctx)
|
g, _ := errgroup.WithContext(ctx)
|
||||||
|
|
||||||
for _, event := range events {
|
for _, event := range events {
|
||||||
e := event
|
e := event
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue