Rename ListenBrainz config flag and enable by default (#1443)

This commit is contained in:
Steve Richter 2021-11-17 21:11:53 -05:00 committed by GitHub
parent da26c5cfe0
commit 3bd6f82c80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 19 additions and 15 deletions

View File

@ -80,7 +80,7 @@ func startServer() (func() error, func(err error)) {
if conf.Server.LastFM.Enabled {
a.MountRouter("LastFM Auth", consts.URLPathNativeAPI+"/lastfm", CreateLastFMRouter())
}
if conf.Server.DevListenBrainzEnabled {
if conf.Server.ListenBrainz.Enabled {
a.MountRouter("ListenBrainz Auth", consts.URLPathNativeAPI+"/listenbrainz", CreateListenBrainzRouter())
}
return a.Run(fmt.Sprintf("%s:%d", conf.Server.Address, conf.Server.Port))

View File

@ -59,9 +59,10 @@ type configOptions struct {
Scanner scannerOptions
Agents string
LastFM lastfmOptions
Spotify spotifyOptions
Agents string
LastFM lastfmOptions
Spotify spotifyOptions
ListenBrainz listenBrainzOptions
// DevFlags. These are used to enable/disable debugging and incomplete features
DevLogSourceLine bool
@ -75,7 +76,6 @@ type configOptions struct {
DevSidebarPlaylists bool
DevEnableBufferedScrobble bool
DevShowArtistPage bool
DevListenBrainzEnabled bool
}
type scannerOptions struct {
@ -95,6 +95,10 @@ type spotifyOptions struct {
Secret string
}
type listenBrainzOptions struct {
Enabled bool
}
var (
Server = &configOptions{}
hooks []func()
@ -153,10 +157,10 @@ func disableExternalServices() {
log.Info("All external integrations are DISABLED!")
Server.LastFM.Enabled = false
Server.Spotify.ID = ""
Server.ListenBrainz.Enabled = false
if Server.UILoginBackgroundURL == consts.DefaultUILoginBackgroundURL {
Server.UILoginBackgroundURL = consts.DefaultUILoginBackgroundURLOffline
}
Server.DevListenBrainzEnabled = false
}
func validateScanSchedule() error {
@ -246,6 +250,7 @@ func init() {
viper.SetDefault("lastfm.secret", consts.LastFMAPISecret)
viper.SetDefault("spotify.id", "")
viper.SetDefault("spotify.secret", "")
viper.SetDefault("listenbrainz.enabled", true)
// DevFlags. These are used to enable/disable debugging and incomplete features
viper.SetDefault("devlogsourceline", false)
@ -258,7 +263,6 @@ func init() {
viper.SetDefault("devenablebufferedscrobble", true)
viper.SetDefault("devsidebarplaylists", true)
viper.SetDefault("devshowartistpage", true)
viper.SetDefault("devlistenbrainzenabled", false)
}
func InitConfig(cfgFile string) {

View File

@ -104,7 +104,7 @@ func (l *listenBrainzAgent) IsAuthorized(ctx context.Context, userId string) boo
func init() {
conf.AddHook(func() {
if conf.Server.DevListenBrainzEnabled {
if conf.Server.ListenBrainz.Enabled {
scrobbler.Register(listenBrainzAgentName, func(ds model.DataStore) scrobbler.Scrobbler {
return listenBrainzConstructor(ds)
})

View File

@ -49,7 +49,7 @@ func serveIndex(ds model.DataStore, fs fs.FS) http.HandlerFunc {
"lastFMEnabled": conf.Server.LastFM.Enabled,
"lastFMApiKey": conf.Server.LastFM.ApiKey,
"devShowArtistPage": conf.Server.DevShowArtistPage,
"devListenBrainzEnabled": conf.Server.DevListenBrainzEnabled,
"listenBrainzEnabled": conf.Server.ListenBrainz.Enabled,
}
auth := handleLoginFromHeaders(ds, r)
if auth != nil {

View File

@ -266,15 +266,15 @@ var _ = Describe("serveIndex", func() {
Expect(config).To(HaveKeyWithValue("devShowArtistPage", true))
})
It("sets the devListenBrainzEnabled", func() {
conf.Server.DevListenBrainzEnabled = true
It("sets the listenBrainzEnabled", func() {
conf.Server.ListenBrainz.Enabled = true
r := httptest.NewRequest("GET", "/index.html", nil)
w := httptest.NewRecorder()
serveIndex(ds, fs)(w, r)
config := extractAppConfig(w.Body.String())
Expect(config).To(HaveKeyWithValue("devListenBrainzEnabled", true))
Expect(config).To(HaveKeyWithValue("listenBrainzEnabled", true))
})
})

View File

@ -23,9 +23,9 @@ const defaultConfig = {
devSidebarPlaylists: true,
lastFMEnabled: true,
lastFMApiKey: '9b94a5515ea66b2da3ec03c12300327e',
listenBrainzEnabled: true,
enableCoverAnimation: true,
devShowArtistPage: true,
devListenBrainzEnabled: true,
}
let config

View File

@ -26,7 +26,7 @@ const Personal = () => {
<SelectDefaultView />
<NotificationsToggle />
{config.lastFMEnabled && <LastfmScrobbleToggle />}
{config.devListenBrainzEnabled && <ListenBrainzScrobbleToggle />}
{config.listenBrainzEnabled && <ListenBrainzScrobbleToggle />}
</SimpleForm>
</Card>
)

View File

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