Skip to content

🎧 Your Personal Streaming Service

Make fields `songCount`, `duration`, `created` and `changed` mandatory in playlists responses (fixes #164)

Deluane476a5f6f183
diff --git a/server/subsonic/playlists.go b/server/subsonic/playlists.go
index 31012ef09..039ede726 100644
--- a/server/subsonic/playlists.go
+++ b/server/subsonic/playlists.go
@@ -36,8 +36,8 @@ func (c *PlaylistsController) GetPlaylists(w http.ResponseWriter, r *http.Reques
playlists[i].Duration = int(p.Duration)
playlists[i].Owner = p.Owner
playlists[i].Public = p.Public
- playlists[i].Created = &p.CreatedAt
- playlists[i].Changed = &p.UpdatedAt
+ playlists[i].Created = p.CreatedAt
+ playlists[i].Changed = p.UpdatedAt
}
response := NewResponse()
response.Playlists = &responses.Playlists{Playlist: playlists}
@@ -144,7 +144,7 @@ func (c *PlaylistsController) buildPlaylist(d *engine.PlaylistInfo) *responses.P
pls.Owner = d.Owner
pls.Duration = d.Duration
pls.Public = d.Public
- pls.Created = &d.Created
- pls.Changed = &d.Changed
+ pls.Created = d.Created
+ pls.Changed = d.Changed
return pls
}
diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists with data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists with data should match .JSON
index fa750b471..f20c45aeb 100644
--- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists with data should match .JSON
+++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists with data should match .JSON
@@ -1 +1 @@
-{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","playlists":{"playlist":[{"id":"111","name":"aaa","comment":"comment","songCount":2,"duration":120,"public":true,"owner":"admin","created":"0001-01-01T00:00:00Z","changed":"0001-01-01T00:00:00Z"},{"id":"222","name":"bbb"}]}}
+{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","playlists":{"playlist":[{"id":"111","name":"aaa","comment":"comment","songCount":2,"duration":120,"public":true,"owner":"admin","created":"0001-01-01T00:00:00Z","changed":"0001-01-01T00:00:00Z"},{"id":"222","name":"bbb","songCount":0,"duration":0,"created":"0001-01-01T00:00:00Z","changed":"0001-01-01T00:00:00Z"}]}}
diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists with data should match .XML b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists with data should match .XML
index db890725a..7c3f4118e 100644
--- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists with data should match .XML
+++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Playlists with data should match .XML
@@ -1 +1 @@
-<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0"><playlists><playlist id="111" name="aaa" comment="comment" songCount="2" duration="120" public="true" owner="admin" created="0001-01-01T00:00:00Z" changed="0001-01-01T00:00:00Z"></playlist><playlist id="222" name="bbb"></playlist></playlists></subsonic-response>
+<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0"><playlists><playlist id="111" name="aaa" comment="comment" songCount="2" duration="120" public="true" owner="admin" created="0001-01-01T00:00:00Z" changed="0001-01-01T00:00:00Z"></playlist><playlist id="222" name="bbb" songCount="0" duration="0" created="0001-01-01T00:00:00Z" changed="0001-01-01T00:00:00Z"></playlist></playlists></subsonic-response>
diff --git a/server/subsonic/responses/responses.go b/server/subsonic/responses/responses.go
index bfb6fbcb4..3db71b97d 100644
--- a/server/subsonic/responses/responses.go
+++ b/server/subsonic/responses/responses.go
@@ -188,15 +188,15 @@ type AlbumList struct {
}
type Playlist struct {
- Id string `xml:"id,attr" json:"id"`
- Name string `xml:"name,attr" json:"name"`
- Comment string `xml:"comment,attr,omitempty" json:"comment,omitempty"`
- SongCount int `xml:"songCount,attr,omitempty" json:"songCount,omitempty"`
- Duration int `xml:"duration,attr,omitempty" json:"duration,omitempty"`
- Public bool `xml:"public,attr,omitempty" json:"public,omitempty"`
- Owner string `xml:"owner,attr,omitempty" json:"owner,omitempty"`
- Created *time.Time `xml:"created,attr,omitempty" json:"created,omitempty"`
- Changed *time.Time `xml:"changed,attr,omitempty" json:"changed,omitempty"`
+ Id string `xml:"id,attr" json:"id"`
+ Name string `xml:"name,attr" json:"name"`
+ Comment string `xml:"comment,attr,omitempty" json:"comment,omitempty"`
+ SongCount int `xml:"songCount,attr" json:"songCount"`
+ Duration int `xml:"duration,attr" json:"duration"`
+ Public bool `xml:"public,attr,omitempty" json:"public,omitempty"`
+ Owner string `xml:"owner,attr,omitempty" json:"owner,omitempty"`
+ Created time.Time `xml:"created,attr" json:"created"`
+ Changed time.Time `xml:"changed,attr" json:"changed"`
/*
<xs:sequence>
<xs:element name="allowedUser" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> <!--Added in 1.8.0-->
diff --git a/server/subsonic/responses/responses_test.go b/server/subsonic/responses/responses_test.go
index f5164b5e6..cb5239212 100644
--- a/server/subsonic/responses/responses_test.go
+++ b/server/subsonic/responses/responses_test.go
@@ -246,8 +246,8 @@ var _ = Describe("Responses", func() {
Duration: 120,
Public: true,
Owner: "admin",
- Created: &timestamp,
- Changed: &timestamp,
+ Created: timestamp,
+ Changed: timestamp,
}
pls[1] = Playlist{Id: "222", Name: "bbb"}
response.Playlists.Playlist = pls