fix scanning from jamstash

This commit is contained in:
sentriz
2019-07-31 15:01:48 +01:00
parent c514f83cf7
commit 7580835146
3 changed files with 44 additions and 5 deletions

View File

@@ -102,6 +102,18 @@ func (c *Controller) ServeGetScanStatus(r *http.Request) *spec.Response {
return sub
}
func (c *Controller) ServeGetUser(r *http.Request) *spec.Response {
user := r.Context().Value(key.User).(*model.User)
sub := spec.NewResponse()
sub.User = &spec.User{
Username: user.Name,
AdminRole: user.IsAdmin,
ScrobblingEnabled: user.LastFMSession != "",
Folder: []int{1},
}
return sub
}
func (c *Controller) ServeNotFound(r *http.Request) *spec.Response {
return spec.NewError(70, "view not found")
}

View File

@@ -29,6 +29,7 @@ type Response struct {
Licence *Licence `xml:"license" json:"license,omitempty"`
SearchResultTwo *SearchResultTwo `xml:"searchResult2" json:"searchResult2,omitempty"`
SearchResultThree *SearchResultThree `xml:"searchResult3" json:"searchResult3,omitempty"`
User *User `xml:"user" json:"user,omitempty"`
}
func NewResponse() *Response {
@@ -177,3 +178,21 @@ type SearchResultThree struct {
Albums []*Album `xml:"album,omitempty" json:"album,omitempty"`
Tracks []*TrackChild `xml:"song,omitempty" json:"song,omitempty"`
}
type User struct {
Username string `xml:"username,attr" json:"username"`
ScrobblingEnabled bool `xml:"scrobblingEnabled,attr" json:"scrobblingEnabled"`
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,attr" json:"folder"`
}