mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
feat: return action rejections from arrs (#103)
* refactor: push status * feat: return push status for arr actions
This commit is contained in:
parent
20138030e1
commit
373c85f060
16 changed files with 294 additions and 255 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
func (s *service) sonarr(release domain.Release, action domain.Action) error {
|
||||
func (s *service) sonarr(release domain.Release, action domain.Action) ([]string, error) {
|
||||
log.Trace().Msg("action SONARR")
|
||||
|
||||
// TODO validate data
|
||||
|
@ -18,13 +18,13 @@ func (s *service) sonarr(release domain.Release, action domain.Action) error {
|
|||
// get client for action
|
||||
client, err := s.clientSvc.FindByID(context.TODO(), action.ClientID)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msgf("error finding client: %v", action.ClientID)
|
||||
return err
|
||||
log.Error().Err(err).Msgf("sonarr: error finding client: %v", action.ClientID)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// return early if no client found
|
||||
if client == nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// initial config
|
||||
|
@ -52,23 +52,19 @@ func (s *service) sonarr(release domain.Release, action domain.Action) error {
|
|||
PublishDate: time.Now().Format(time.RFC3339),
|
||||
}
|
||||
|
||||
success, rejections, err := arr.Push(r)
|
||||
rejections, err := arr.Push(r)
|
||||
if err != nil {
|
||||
log.Error().Stack().Err(err).Msgf("sonarr: failed to push release: %v", r)
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !success {
|
||||
if rejections != nil {
|
||||
log.Debug().Msgf("sonarr: release push rejected: %v, indexer %v to %v reasons: '%v'", r.Title, r.Indexer, client.Host, rejections)
|
||||
|
||||
// save pushed release
|
||||
s.bus.Publish("release:update-push-status-rejected", release.ID, rejections)
|
||||
return nil
|
||||
return rejections, nil
|
||||
}
|
||||
|
||||
log.Debug().Msgf("sonarr: successfully pushed release: %v, indexer %v to %v", r.Title, r.Indexer, client.Host)
|
||||
|
||||
s.bus.Publish("release:update-push-status", release.ID, domain.ReleasePushStatusApproved)
|
||||
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue