mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-05 05:27:37 +03:00
parent
86567f5406
commit
dd4374cec6
3 changed files with 17 additions and 4 deletions
|
@ -146,6 +146,7 @@ type jukeboxOptions struct {
|
||||||
Enabled bool
|
Enabled bool
|
||||||
Devices []AudioDeviceDefinition
|
Devices []AudioDeviceDefinition
|
||||||
Default string
|
Default string
|
||||||
|
AdminOnly bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -340,6 +341,7 @@ func init() {
|
||||||
viper.SetDefault("jukebox.enabled", false)
|
viper.SetDefault("jukebox.enabled", false)
|
||||||
viper.SetDefault("jukebox.devices", []AudioDeviceDefinition{})
|
viper.SetDefault("jukebox.devices", []AudioDeviceDefinition{})
|
||||||
viper.SetDefault("jukebox.default", "")
|
viper.SetDefault("jukebox.default", "")
|
||||||
|
viper.SetDefault("jukebox.adminonly", true)
|
||||||
|
|
||||||
viper.SetDefault("scanner.extractor", consts.DefaultScannerExtractor)
|
viper.SetDefault("scanner.extractor", consts.DefaultScannerExtractor)
|
||||||
viper.SetDefault("scanner.genreseparators", ";/,")
|
viper.SetDefault("scanner.genreseparators", ";/,")
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/navidrome/navidrome/conf"
|
||||||
"github.com/navidrome/navidrome/core/playback"
|
"github.com/navidrome/navidrome/core/playback"
|
||||||
"github.com/navidrome/navidrome/log"
|
"github.com/navidrome/navidrome/log"
|
||||||
"github.com/navidrome/navidrome/server/subsonic/responses"
|
"github.com/navidrome/navidrome/server/subsonic/responses"
|
||||||
|
@ -29,6 +30,14 @@ func (api *Router) JukeboxControl(r *http.Request) (*responses.Subsonic, error)
|
||||||
user := getUser(ctx)
|
user := getUser(ctx)
|
||||||
p := req.Params(r)
|
p := req.Params(r)
|
||||||
|
|
||||||
|
if !conf.Server.Jukebox.Enabled {
|
||||||
|
return nil, newError(responses.ErrorGeneric, "Jukebox is disabled")
|
||||||
|
}
|
||||||
|
|
||||||
|
if conf.Server.Jukebox.AdminOnly && !user.IsAdmin {
|
||||||
|
return nil, newError(responses.ErrorAuthorizationFail, "Jukebox is admin only")
|
||||||
|
}
|
||||||
|
|
||||||
actionString, err := p.String("action")
|
actionString, err := p.String("action")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -40,7 +40,9 @@ func (api *Router) GetUsers(r *http.Request) (*responses.Subsonic, error) {
|
||||||
user.ScrobblingEnabled = true
|
user.ScrobblingEnabled = true
|
||||||
user.DownloadRole = conf.Server.EnableDownloads
|
user.DownloadRole = conf.Server.EnableDownloads
|
||||||
user.ShareRole = conf.Server.EnableSharing
|
user.ShareRole = conf.Server.EnableSharing
|
||||||
user.JukeboxRole = conf.Server.Jukebox.Enabled
|
if conf.Server.Jukebox.Enabled {
|
||||||
|
user.JukeboxRole = !conf.Server.Jukebox.AdminOnly || loggedUser.IsAdmin
|
||||||
|
}
|
||||||
response := newResponse()
|
response := newResponse()
|
||||||
response.Users = &responses.Users{User: []responses.User{user}}
|
response.Users = &responses.Users{User: []responses.User{user}}
|
||||||
return response, nil
|
return response, nil
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue