Disable Last.FM features based on LastFM.Enabled config option

This commit is contained in:
Deluan
2021-07-02 09:50:07 -04:00
parent 289da56f64
commit cfb113bd33
9 changed files with 9 additions and 20 deletions
+1 -1
View File
@@ -76,7 +76,7 @@ func startServer() (func() error, func(err error)) {
a := CreateServer(conf.Server.MusicFolder) a := CreateServer(conf.Server.MusicFolder)
a.MountRouter("Native API", consts.URLPathNativeAPI, CreateNativeAPIRouter()) a.MountRouter("Native API", consts.URLPathNativeAPI, CreateNativeAPIRouter())
a.MountRouter("Subsonic API", consts.URLPathSubsonicAPI, CreateSubsonicAPIRouter()) a.MountRouter("Subsonic API", consts.URLPathSubsonicAPI, CreateSubsonicAPIRouter())
if conf.Server.DevEnableScrobble { if conf.Server.LastFM.Enabled {
a.MountRouter("LastFM Auth", consts.URLPathNativeAPI+"/lastfm", CreateLastFMRouter()) a.MountRouter("LastFM Auth", consts.URLPathNativeAPI+"/lastfm", CreateLastFMRouter())
} }
return a.Run(fmt.Sprintf("%s:%d", conf.Server.Address, conf.Server.Port)) return a.Run(fmt.Sprintf("%s:%d", conf.Server.Address, conf.Server.Port))
-2
View File
@@ -70,7 +70,6 @@ type configOptions struct {
DevOldCacheLayout bool DevOldCacheLayout bool
DevActivityPanel bool DevActivityPanel bool
DevEnableShare bool DevEnableShare bool
DevEnableScrobble bool
} }
type scannerOptions struct { type scannerOptions struct {
@@ -230,7 +229,6 @@ func init() {
viper.SetDefault("devfastaccesscoverart", false) viper.SetDefault("devfastaccesscoverart", false)
viper.SetDefault("devactivitypanel", true) viper.SetDefault("devactivitypanel", true)
viper.SetDefault("devenableshare", false) viper.SetDefault("devenableshare", false)
viper.SetDefault("devenablescrobble", true)
} }
func InitConfig(cfgFile string) { func InitConfig(cfgFile string) {
+2 -9
View File
@@ -5,15 +5,11 @@ import (
"sort" "sort"
"time" "time"
"github.com/navidrome/navidrome/conf"
"github.com/navidrome/navidrome/server/events"
"github.com/navidrome/navidrome/log"
"github.com/ReneKroon/ttlcache/v2" "github.com/ReneKroon/ttlcache/v2"
"github.com/navidrome/navidrome/log"
"github.com/navidrome/navidrome/model" "github.com/navidrome/navidrome/model"
"github.com/navidrome/navidrome/model/request" "github.com/navidrome/navidrome/model/request"
"github.com/navidrome/navidrome/server/events"
"github.com/navidrome/navidrome/utils/singleton" "github.com/navidrome/navidrome/utils/singleton"
) )
@@ -184,9 +180,6 @@ func (p *playTracker) dispatchScrobble(ctx context.Context, t *model.MediaFile,
var constructors map[string]Constructor var constructors map[string]Constructor
func Register(name string, init Constructor) { func Register(name string, init Constructor) {
if !conf.Server.DevEnableScrobble {
return
}
if constructors == nil { if constructors == nil {
constructors = make(map[string]Constructor) constructors = make(map[string]Constructor)
} }
-2
View File
@@ -5,7 +5,6 @@ import (
"errors" "errors"
"time" "time"
"github.com/navidrome/navidrome/conf"
"github.com/navidrome/navidrome/model" "github.com/navidrome/navidrome/model"
"github.com/navidrome/navidrome/model/request" "github.com/navidrome/navidrome/model/request"
"github.com/navidrome/navidrome/server/events" "github.com/navidrome/navidrome/server/events"
@@ -24,7 +23,6 @@ var _ = Describe("PlayTracker", func() {
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"})
ctx = request.WithPlayer(ctx, model.Player{ScrobbleEnabled: true}) ctx = request.WithPlayer(ctx, model.Player{ScrobbleEnabled: true})
+1 -1
View File
@@ -45,7 +45,7 @@ func serveIndex(ds model.DataStore, fs fs.FS) http.HandlerFunc {
"devFastAccessCoverArt": conf.Server.DevFastAccessCoverArt, "devFastAccessCoverArt": conf.Server.DevFastAccessCoverArt,
"enableUserEditing": conf.Server.EnableUserEditing, "enableUserEditing": conf.Server.EnableUserEditing,
"devEnableShare": conf.Server.DevEnableShare, "devEnableShare": conf.Server.DevEnableShare,
"devEnableScrobble": conf.Server.DevEnableScrobble, "lastFMEnabled": conf.Server.LastFM.Enabled,
"lastFMApiKey": conf.Server.LastFM.ApiKey, "lastFMApiKey": conf.Server.LastFM.ApiKey,
} }
auth := handleLoginFromHeaders(ds, r) auth := handleLoginFromHeaders(ds, r)
+2 -2
View File
@@ -211,14 +211,14 @@ var _ = Describe("serveIndex", func() {
Expect(config).To(HaveKeyWithValue("devEnableShare", false)) Expect(config).To(HaveKeyWithValue("devEnableShare", false))
}) })
It("sets the devEnableScrobble", func() { It("sets the lastFMEnabled", func() {
r := httptest.NewRequest("GET", "/index.html", nil) r := httptest.NewRequest("GET", "/index.html", nil)
w := httptest.NewRecorder() w := httptest.NewRecorder()
serveIndex(ds, fs)(w, r) serveIndex(ds, fs)(w, r)
config := extractAppConfig(w.Body.String()) config := extractAppConfig(w.Body.String())
Expect(config).To(HaveKeyWithValue("devEnableScrobble", true)) Expect(config).To(HaveKeyWithValue("lastFMEnabled", true))
}) })
It("sets the lastFMApiKey", func() { It("sets the lastFMApiKey", func() {
+1 -1
View File
@@ -19,7 +19,7 @@ const defaultConfig = {
defaultTheme: 'Dark', defaultTheme: 'Dark',
enableUserEditing: true, enableUserEditing: true,
devEnableShare: true, devEnableShare: true,
devEnableScrobble: true, lastFMEnabled: true,
lastFMApiKey: '9b94a5515ea66b2da3ec03c12300327e', lastFMApiKey: '9b94a5515ea66b2da3ec03c12300327e',
enableCoverAnimation: true, enableCoverAnimation: true,
} }
+1 -1
View File
@@ -24,7 +24,7 @@ const Personal = () => {
<SelectLanguage /> <SelectLanguage />
<SelectDefaultView /> <SelectDefaultView />
<NotificationsToggle /> <NotificationsToggle />
{config.devEnableScrobble && <LastfmScrobbleToggle />} {config.lastFMEnabled && <LastfmScrobbleToggle />}
</SimpleForm> </SimpleForm>
</Card> </Card>
) )
+1 -1
View File
@@ -48,7 +48,7 @@ const PlayerEdit = (props) => (
]} ]}
/> />
<BooleanInput source="reportRealPath" fullWidth /> <BooleanInput source="reportRealPath" fullWidth />
{config.devEnableScrobble && ( {config.lastFMEnabled && (
<BooleanInput source="scrobbleEnabled" fullWidth /> <BooleanInput source="scrobbleEnabled" fullWidth />
)} )}
<TextField source="client" /> <TextField source="client" />