Skip to content

Commit

Permalink
Disable Last.FM features based on LastFM.Enabled config option
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Jul 2, 2021
1 parent 289da56 commit cfb113b
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 0 additions & 2 deletions conf/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ type configOptions struct {
DevOldCacheLayout bool
DevActivityPanel bool
DevEnableShare bool
DevEnableScrobble bool
}

type scannerOptions struct {
Expand Down Expand Up @@ -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) {
Expand Down
11 changes: 2 additions & 9 deletions core/scrobbler/play_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 0 additions & 2 deletions core/scrobbler/play_tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion server/serve_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions server/serve_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const defaultConfig = {
defaultTheme: 'Dark',
enableUserEditing: true,
devEnableShare: true,
devEnableScrobble: true,
lastFMEnabled: true,
lastFMApiKey: '9b94a5515ea66b2da3ec03c12300327e',
enableCoverAnimation: true,
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/personal/Personal.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Personal = () => {
<SelectLanguage />
<SelectDefaultView />
<NotificationsToggle />
{config.devEnableScrobble && <LastfmScrobbleToggle />}
{config.lastFMEnabled && <LastfmScrobbleToggle />}
</SimpleForm>
</Card>
)
Expand Down
2 changes: 1 addition & 1 deletion ui/src/player/PlayerEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const PlayerEdit = (props) => (
]}
/>
<BooleanInput source="reportRealPath" fullWidth />
{config.devEnableScrobble && (
{config.lastFMEnabled && (
<BooleanInput source="scrobbleEnabled" fullWidth />
)}
<TextField source="client" />
Expand Down

0 comments on commit cfb113b

Please sign in to comment.