feat(downloadclients): Porla support preset (#978)

* Correctly omit download/upload limits

* Prefix JWT correctly

* Allow setting Porla preset
This commit is contained in:
Viktor Elofsson 2023-06-14 19:51:34 +02:00 committed by GitHub
parent 956225c108
commit 3d9839d234
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 27 deletions

View file

@ -8,6 +8,7 @@ import (
"io"
"log"
"net/http"
"strings"
"time"
"github.com/autobrr/autobrr/pkg/jsonrpc"
@ -75,9 +76,15 @@ func NewClient(cfg Config) *Client {
Transport: customTransport,
}
token := cfg.AuthToken
if !strings.HasPrefix(token, "Bearer ") {
token = "Bearer " + token
}
c.rpcClient = jsonrpc.NewClientWithOpts(cfg.Hostname+"/api/v1/jsonrpc", &jsonrpc.ClientOpts{
Headers: map[string]string{
"X-Porla-Token": cfg.AuthToken,
"X-Porla-Token": token,
},
HTTPClient: httpClient,
BasicUser: cfg.BasicUser,