Skip to content

Commit 19458c1

Browse files
committed
Update to allow unlisted tracks
1 parent 40c4677 commit 19458c1

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

api/v1_users_library_tracks.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,12 @@ func (app *ApiServer) v1UsersLibraryTracks(c *fiber.Ctx) error {
156156
trackIds = append(trackIds, i.ItemID)
157157
}
158158

159-
// get tracks
159+
// get tracks - include unlisted tracks since they may be in the library (e.g., purchases)
160160
tracks, err := app.queries.FullTracksKeyed(c.Context(), dbv1.FullTracksParams{
161161
GetTracksParams: dbv1.GetTracksParams{
162-
Ids: trackIds,
163-
MyID: myId,
162+
Ids: trackIds,
163+
MyID: myId,
164+
IncludeUnlisted: true,
164165
},
165166
})
166167
if err != nil {

api/v1_users_library_tracks_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,25 @@ func TestUsersLibraryTracksQuery(t *testing.T) {
199199
assert.Contains(t, item.Item.Title, "T1", "All results should match query")
200200
}
201201
}
202+
203+
func TestUsersLibraryTracksMetadataNotNull(t *testing.T) {
204+
app := testAppWithFixtures(t)
205+
user1Id := trashid.MustEncodeHashID(1)
206+
207+
var response struct {
208+
Data []struct {
209+
ItemID int32 `json:"item_id"`
210+
Item any `json:"item"`
211+
} `json:"data"`
212+
}
213+
214+
// Test that all returned tracks have non-null metadata
215+
status, _ := testGet(t, app, "/v1/full/users/"+user1Id+"/library/tracks?type=all", &response)
216+
assert.Equal(t, 200, status)
217+
assert.GreaterOrEqual(t, len(response.Data), 1, "Should have at least one track")
218+
219+
// Verify all items have non-null metadata
220+
for _, item := range response.Data {
221+
assert.NotNil(t, item.Item, "Track metadata should not be null for item_id %d", item.ItemID)
222+
}
223+
}

0 commit comments

Comments
 (0)