mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 00:39:13 +00:00
fix(actions): reject if client is disabled (#1626)
* fix(actions): error on disabled client * fix(actions): sql scan args * refactor: download client cache for actions * fix: tests client store * fix: tests client store and int conversion * fix: tests revert findbyid ctx timeout * fix: tests row.err * feat: add logging to download client cache
This commit is contained in:
parent
77e1c2c305
commit
861f30c144
30 changed files with 928 additions and 680 deletions
|
@ -13,34 +13,21 @@ import (
|
|||
"github.com/autobrr/autobrr/internal/domain"
|
||||
"github.com/autobrr/autobrr/pkg/errors"
|
||||
"github.com/autobrr/autobrr/pkg/porla"
|
||||
|
||||
"github.com/dcarbone/zadapters/zstdlog"
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
func (s *service) porla(ctx context.Context, action *domain.Action, release domain.Release) ([]string, error) {
|
||||
s.log.Debug().Msgf("action Porla: %s", action.Name)
|
||||
|
||||
client, err := s.clientSvc.FindByID(ctx, action.ClientID)
|
||||
client, err := s.clientSvc.GetClient(ctx, action.ClientID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error finding client: %d", action.ClientID)
|
||||
return nil, errors.Wrap(err, "could not get client with id %d", action.ClientID)
|
||||
}
|
||||
|
||||
if client == nil {
|
||||
return nil, errors.New("could not find client by id: %d", action.ClientID)
|
||||
if !client.Enabled {
|
||||
return nil, errors.New("client %s %s not enabled", client.Type, client.Name)
|
||||
}
|
||||
|
||||
porlaSettings := porla.Config{
|
||||
Hostname: client.Host,
|
||||
AuthToken: client.Settings.APIKey,
|
||||
TLSSkipVerify: client.TLSSkipVerify,
|
||||
BasicUser: client.Settings.Basic.Username,
|
||||
BasicPass: client.Settings.Basic.Password,
|
||||
}
|
||||
|
||||
porlaSettings.Log = zstdlog.NewStdLoggerWithLevel(s.log.With().Str("type", "Porla").Str("client", client.Name).Logger(), zerolog.TraceLevel)
|
||||
|
||||
prl := porla.NewClient(porlaSettings)
|
||||
prl := client.Client.(*porla.Client)
|
||||
|
||||
rejections, err := s.porlaCheckRulesCanDownload(ctx, action, client, prl)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue