feat(subsonic): populate Folder field with user's accessible library IDs
Added functionality to populate the Folder field in GetUser and GetUsers API responses with the library IDs that the user has access to. This allows Subsonic API clients to understand which music folders (libraries) a user can access for proper content filtering and UI presentation. Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/navidrome/navidrome/model"
|
||||
"github.com/navidrome/navidrome/model/request"
|
||||
"github.com/navidrome/navidrome/server/subsonic/responses"
|
||||
"github.com/navidrome/navidrome/utils/slice"
|
||||
)
|
||||
|
||||
// buildUserResponse creates a User response object from a User model
|
||||
@@ -19,6 +20,7 @@ func buildUserResponse(user model.User) responses.User {
|
||||
ScrobblingEnabled: true,
|
||||
DownloadRole: conf.Server.EnableDownloads,
|
||||
ShareRole: conf.Server.EnableSharing,
|
||||
Folder: slice.Map(user.Libraries, func(lib model.Library) int32 { return int32(lib.ID) }),
|
||||
}
|
||||
|
||||
if conf.Server.Jukebox.Enabled {
|
||||
@@ -28,7 +30,6 @@ func buildUserResponse(user model.User) responses.User {
|
||||
return userResponse
|
||||
}
|
||||
|
||||
// TODO This is a placeholder. The real one has to read this info from a config file or the database
|
||||
func (api *Router) GetUser(r *http.Request) (*responses.Subsonic, error) {
|
||||
loggedUser, ok := request.UserFrom(r.Context())
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user