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

View File

@ -76,7 +76,7 @@ func startServer() (func() error, func(err error)) {
a := CreateServer(conf.Server.MusicFolder)
a.MountRouter("Native API", consts.URLPathNativeAPI, CreateNativeAPIRouter())
a.MountRouter("Subsonic API", consts.URLPathSubsonicAPI, CreateSubsonicAPIRouter())
if conf.Server.DevEnableScrobble {
if conf.Server.LastFM.Enabled {
a.MountRouter("LastFM Auth", consts.URLPathNativeAPI+"/lastfm", CreateLastFMRouter())
}
return a.Run(fmt.Sprintf("%s:%d", conf.Server.Address, conf.Server.Port))

View File

@ -70,7 +70,6 @@ type configOptions struct {
DevOldCacheLayout bool
DevActivityPanel bool
DevEnableShare bool
DevEnableScrobble bool
}
type scannerOptions struct {
@ -230,7 +229,6 @@ func init() {
viper.SetDefault("devfastaccesscoverart", false)
viper.SetDefault("devactivitypanel", true)
viper.SetDefault("devenableshare", false)
viper.SetDefault("devenablescrobble", true)
}
func InitConfig(cfgFile string) {

View File

@ -5,15 +5,11 @@ import (
"sort"
"time"
"github.com/navidrome/navidrome/conf"
"github.com/navidrome/navidrome/server/events"
"github.com/navidrome/navidrome/log"
"github.com/ReneKroon/ttlcache/v2"
"github.com/navidrome/navidrome/log"
"github.com/navidrome/navidrome/model"
"github.com/navidrome/navidrome/model/request"
"github.com/navidrome/navidrome/server/events"
"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
func Register(name string, init Constructor) {
if !conf.Server.DevEnableScrobble {
return
}
if constructors == nil {
constructors = make(map[string]Constructor)
}

View File

@ -5,7 +5,6 @@ import (
"errors"
"time"
"github.com/navidrome/navidrome/conf"
"github.com/navidrome/navidrome/model"
"github.com/navidrome/navidrome/model/request"
"github.com/navidrome/navidrome/server/events"
@ -24,7 +23,6 @@ var _ = Describe("PlayTracker", func() {
var fake fakeScrobbler
BeforeEach(func() {
conf.Server.DevEnableScrobble = true
ctx = context.Background()
ctx = request.WithUser(ctx, model.User{ID: "u-1"})
ctx = request.WithPlayer(ctx, model.Player{ScrobbleEnabled: true})

View File

@ -45,7 +45,7 @@ func serveIndex(ds model.DataStore, fs fs.FS) http.HandlerFunc {
"devFastAccessCoverArt": conf.Server.DevFastAccessCoverArt,
"enableUserEditing": conf.Server.EnableUserEditing,
"devEnableShare": conf.Server.DevEnableShare,
"devEnableScrobble": conf.Server.DevEnableScrobble,
"lastFMEnabled": conf.Server.LastFM.Enabled,
"lastFMApiKey": conf.Server.LastFM.ApiKey,
}
auth := handleLoginFromHeaders(ds, r)

View File

@ -211,14 +211,14 @@ var _ = Describe("serveIndex", func() {
Expect(config).To(HaveKeyWithValue("devEnableShare", false))
})
It("sets the devEnableScrobble", func() {
It("sets the lastFMEnabled", func() {
r := httptest.NewRequest("GET", "/index.html", nil)
w := httptest.NewRecorder()
serveIndex(ds, fs)(w, r)
config := extractAppConfig(w.Body.String())
Expect(config).To(HaveKeyWithValue("devEnableScrobble", true))
Expect(config).To(HaveKeyWithValue("lastFMEnabled", true))
})
It("sets the lastFMApiKey", func() {

View File

@ -19,7 +19,7 @@ const defaultConfig = {
defaultTheme: 'Dark',
enableUserEditing: true,
devEnableShare: true,
devEnableScrobble: true,
lastFMEnabled: true,
lastFMApiKey: '9b94a5515ea66b2da3ec03c12300327e',
enableCoverAnimation: true,
}

View File

@ -24,7 +24,7 @@ const Personal = () => {
<SelectLanguage />
<SelectDefaultView />
<NotificationsToggle />
{config.devEnableScrobble && <LastfmScrobbleToggle />}
{config.lastFMEnabled && <LastfmScrobbleToggle />}
</SimpleForm>
</Card>
)

View File

@ -48,7 +48,7 @@ const PlayerEdit = (props) => (
]}
/>
<BooleanInput source="reportRealPath" fullWidth />
{config.devEnableScrobble && (
{config.lastFMEnabled && (
<BooleanInput source="scrobbleEnabled" fullWidth />
)}
<TextField source="client" />