autobrr/internal/release/process.go
Ludvig Lundgren c02f16b64d
Feature: Download client rules (#18)
* feat(web): add and update download client rules

* feat: add and update download client rules

* feat: add active downloads check

* chore: update pkg

* feat: deluge max active downloads

* feat: use basic rules for deluge

* feat: add as paused

* refactor: download file if needed

* feat: better errors qbit
2021-09-10 16:54:30 +02:00

41 lines
915 B
Go

package release
import (
"fmt"
"github.com/rs/zerolog/log"
"github.com/autobrr/autobrr/internal/action"
"github.com/autobrr/autobrr/internal/domain"
)
type Service interface {
Process(announce domain.Announce) error
}
type service struct {
actionSvc action.Service
}
func NewService(actionService action.Service) Service {
return &service{actionSvc: actionService}
}
func (s *service) Process(announce domain.Announce) error {
log.Trace().Msgf("start to process release: %+v", announce)
if announce.Filter.Actions == nil {
return fmt.Errorf("no actions for filter: %v", announce.Filter.Name)
}
// smart episode?
// run actions (watchFolder, test, exec, qBittorrent, Deluge etc.)
err := s.actionSvc.RunActions(announce.Filter.Actions, announce)
if err != nil {
log.Error().Stack().Err(err).Msgf("error running actions for filter: %v", announce.Filter.Name)
return err
}
return nil
}