mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-23 15:20:33 +03:00
Adding a "placeholder" to getUser.view endpoint
This commit is contained in:
parent
adfec414a1
commit
3b60b62aa1
@ -14,6 +14,7 @@ type Subsonic struct {
|
||||
MusicFolders *MusicFolders `xml:"musicFolders,omitempty" json:"musicFolders,omitempty"`
|
||||
Indexes *Indexes `xml:"indexes,omitempty" json:"indexes,omitempty"`
|
||||
Directory *Directory `xml:"directory,omitempty" json:"directory,omitempty"`
|
||||
User *User `xml:"user,omitempty" json:"user,omitempty"`
|
||||
}
|
||||
|
||||
type JsonWrapper struct {
|
||||
@ -79,3 +80,23 @@ type Directory struct {
|
||||
Id string `xml:"id,attr" json:"id"`
|
||||
Name string `xml:"name,attr" json:"name"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
Username string `xml:"username,attr" json:"username"`
|
||||
Email string `xml:"email,attr,omitempty" json:"email,omitempty"`
|
||||
ScrobblingEnabled bool `xml:"scrobblingEnabled,attr" json:"scrobblingEnabled"`
|
||||
MaxBitRate int `xml:"maxBitRate,attr,omitempty" json:"maxBitRate,omitempty"`
|
||||
AdminRole bool `xml:"adminRole,attr" json:"adminRole"`
|
||||
SettingsRole bool `xml:"settingsRole,attr" json:"settingsRole"`
|
||||
DownloadRole bool `xml:"downloadRole,attr" json:"downloadRole"`
|
||||
UploadRole bool `xml:"uploadRole,attr" json:"uploadRole"`
|
||||
PlaylistRole bool `xml:"playlistRole,attr" json:"playlistRole"`
|
||||
CoverArtRole bool `xml:"coverArtRole,attr" json:"coverArtRole"`
|
||||
CommentRole bool `xml:"commentRole,attr" json:"commentRole"`
|
||||
PodcastRole bool `xml:"podcastRole,attr" json:"podcastRole"`
|
||||
StreamRole bool `xml:"streamRole,attr" json:"streamRole"`
|
||||
JukeboxRole bool `xml:"jukeboxRole,attr" json:"jukeboxRole"`
|
||||
ShareRole bool `xml:"shareRole,attr" json:"shareRole"`
|
||||
VideoConversionRole bool `xml:"videoConversionRole,attr" json:"videoConversionRole"`
|
||||
Folder []int `xml:"folder,omitempty" json:"folder,omitempty"`
|
||||
}
|
||||
|
@ -124,6 +124,28 @@ func TestSubsonicResponses(t *testing.T) {
|
||||
})
|
||||
})
|
||||
|
||||
Convey("User", func() {
|
||||
response.User = &User{Username: "deluan"}
|
||||
Convey("Without optional fields", func() {
|
||||
Convey("XML", func() {
|
||||
So(response, ShouldMatchXML, `<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.0.0"><user username="deluan" scrobblingEnabled="false" adminRole="false" settingsRole="false" downloadRole="false" uploadRole="false" playlistRole="false" coverArtRole="false" commentRole="false" podcastRole="false" streamRole="false" jukeboxRole="false" shareRole="false" videoConversionRole="false"></user></subsonic-response>`)
|
||||
})
|
||||
Convey("JSON", func() {
|
||||
So(response, ShouldMatchJSON, `{"status":"ok","user":{"adminRole":false,"commentRole":false,"coverArtRole":false,"downloadRole":false,"jukeboxRole":false,"playlistRole":false,"podcastRole":false,"scrobblingEnabled":false,"settingsRole":false,"shareRole":false,"streamRole":false,"uploadRole":false,"username":"deluan","videoConversionRole":false},"version":"1.0.0"}`)
|
||||
})
|
||||
})
|
||||
Convey("With optional fields", func() {
|
||||
response.User.Email = "gosonic@deluan.com"
|
||||
response.User.Folder = []int{1}
|
||||
Convey("XML", func() {
|
||||
So(response, ShouldMatchXML, `<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.0.0"><user username="deluan" email="gosonic@deluan.com" scrobblingEnabled="false" adminRole="false" settingsRole="false" downloadRole="false" uploadRole="false" playlistRole="false" coverArtRole="false" commentRole="false" podcastRole="false" streamRole="false" jukeboxRole="false" shareRole="false" videoConversionRole="false"><folder>1</folder></user></subsonic-response>`)
|
||||
})
|
||||
Convey("JSON", func() {
|
||||
So(response, ShouldMatchJSON, `{"status":"ok","user":{"adminRole":false,"commentRole":false,"coverArtRole":false,"downloadRole":false,"email":"gosonic@deluan.com","folder":[1],"jukeboxRole":false,"playlistRole":false,"podcastRole":false,"scrobblingEnabled":false,"settingsRole":false,"shareRole":false,"streamRole":false,"uploadRole":false,"username":"deluan","videoConversionRole":false},"version":"1.0.0"}`)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reset(func() {
|
||||
response = &Subsonic{Status: "ok", Version: "1.0.0"}
|
||||
})
|
||||
|
16
api/users.go
Normal file
16
api/users.go
Normal file
@ -0,0 +1,16 @@
|
||||
package api
|
||||
|
||||
import "github.com/deluan/gosonic/api/responses"
|
||||
|
||||
type UsersController struct{ BaseAPIController }
|
||||
|
||||
// TODO This is a placeholder. The real one has to read this info from a config file
|
||||
func (c *UsersController) GetUser() {
|
||||
r := c.NewEmpty()
|
||||
r.User = &responses.User{}
|
||||
r.User.Username = c.GetParameter("username", "Required string parameter 'username' is not present")
|
||||
r.User.StreamRole = true
|
||||
r.User.DownloadRole = true
|
||||
c.SendResponse(r)
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ func mapEndpoints() {
|
||||
beego.NSRouter("/getCoverArt.view", &api.GetCoverArtController{}, "*:Get"),
|
||||
beego.NSRouter("/stream.view", &api.StreamController{}, "*:Get"),
|
||||
beego.NSRouter("/download.view", &api.StreamController{}, "*:Get"),
|
||||
beego.NSRouter("/getUser.view", &api.UsersController{}, "*:GetUser"),
|
||||
)
|
||||
beego.AddNamespace(ns)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user