Disable completely external scrobblers if feature is disabled (DevEnableScrobble)
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -184,8 +183,7 @@ func (c *Client) makeRequest(method string, params url.Values, signed bool) (*Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
body, _ := ioutil.ReadAll(resp.Body)
|
decoder := json.NewDecoder(resp.Body)
|
||||||
decoder := json.NewDecoder(strings.NewReader(string(body)))
|
|
||||||
|
|
||||||
var response Response
|
var response Response
|
||||||
jsonErr := decoder.Decode(&response)
|
jsonErr := decoder.Decode(&response)
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/navidrome/navidrome/conf"
|
||||||
|
|
||||||
"github.com/navidrome/navidrome/server/events"
|
"github.com/navidrome/navidrome/server/events"
|
||||||
|
|
||||||
"github.com/navidrome/navidrome/log"
|
"github.com/navidrome/navidrome/log"
|
||||||
@@ -172,6 +174,9 @@ func (p *playTracker) dispatchScrobble(ctx context.Context, t *model.MediaFile,
|
|||||||
var scrobblers map[string]Constructor
|
var scrobblers map[string]Constructor
|
||||||
|
|
||||||
func Register(name string, init Constructor) {
|
func Register(name string, init Constructor) {
|
||||||
|
if !conf.Server.DevEnableScrobble {
|
||||||
|
return
|
||||||
|
}
|
||||||
if scrobblers == nil {
|
if scrobblers == nil {
|
||||||
scrobblers = make(map[string]Constructor)
|
scrobblers = make(map[string]Constructor)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/navidrome/navidrome/conf"
|
||||||
|
|
||||||
"github.com/navidrome/navidrome/server/events"
|
"github.com/navidrome/navidrome/server/events"
|
||||||
|
|
||||||
"github.com/navidrome/navidrome/model"
|
"github.com/navidrome/navidrome/model"
|
||||||
@@ -22,7 +24,9 @@ var _ = Describe("PlayTracker", func() {
|
|||||||
var album model.Album
|
var album model.Album
|
||||||
var artist model.Artist
|
var artist model.Artist
|
||||||
var fake *fakeScrobbler
|
var fake *fakeScrobbler
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
|
conf.Server.DevEnableScrobble = true
|
||||||
ctx = context.Background()
|
ctx = context.Background()
|
||||||
ctx = request.WithUser(ctx, model.User{ID: "u-1"})
|
ctx = request.WithUser(ctx, model.User{ID: "u-1"})
|
||||||
ds = &tests.MockDataStore{}
|
ds = &tests.MockDataStore{}
|
||||||
|
|||||||
Reference in New Issue
Block a user