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
|
@ -18,29 +18,16 @@ func (s *service) sabnzbd(ctx context.Context, action *domain.Action, release do
|
|||
return nil, errors.New("action type: %s invalid protocol: %s", action.Type, release.Protocol)
|
||||
}
|
||||
|
||||
// get client for action
|
||||
client, err := s.clientSvc.FindByID(ctx, action.ClientID)
|
||||
client, err := s.clientSvc.GetClient(ctx, action.ClientID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "sonarr could not find client: %d", action.ClientID)
|
||||
return nil, errors.Wrap(err, "could not get client with id %d", action.ClientID)
|
||||
}
|
||||
|
||||
// return early if no client found
|
||||
if client == nil {
|
||||
return nil, errors.New("no sabnzbd client found by id: %d", action.ClientID)
|
||||
if !client.Enabled {
|
||||
return nil, errors.New("client %s %s not enabled", client.Type, client.Name)
|
||||
}
|
||||
|
||||
opts := sabnzbd.Options{
|
||||
Addr: client.Host,
|
||||
ApiKey: client.Settings.APIKey,
|
||||
Log: nil,
|
||||
}
|
||||
|
||||
if client.Settings.Basic.Auth {
|
||||
opts.BasicUser = client.Settings.Basic.Username
|
||||
opts.BasicPass = client.Settings.Basic.Password
|
||||
}
|
||||
|
||||
sab := sabnzbd.New(opts)
|
||||
sab := client.Client.(*sabnzbd.Client)
|
||||
|
||||
ids, err := sab.AddFromUrl(ctx, sabnzbd.AddNzbRequest{Url: release.DownloadURL, Category: action.Category})
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue