From 5f242f49b3cbf18b80adaafb54bbe937be9a40d2 Mon Sep 17 00:00:00 2001 From: Dylan Jeffers Date: Fri, 13 Mar 2026 14:16:30 -0700 Subject: [PATCH 1/3] Handle unlisted tracks with id --- api/v1_track.go | 7 ++++--- api/v1_track_download.go | 7 ++++--- api/v1_track_inspect.go | 14 ++++++++------ api/v1_track_remixing.go | 5 ++--- api/v1_track_stream.go | 7 ++++--- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/api/v1_track.go b/api/v1_track.go index cdc9d311..31c55c89 100644 --- a/api/v1_track.go +++ b/api/v1_track.go @@ -201,9 +201,10 @@ func (app *ApiServer) v1Track(c *fiber.Ctx) error { tracks, err := app.queries.Tracks(c.Context(), dbv1.TracksParams{ GetTracksParams: dbv1.GetTracksParams{ - MyID: myId, - Ids: []int32{int32(trackId)}, - AuthedWallet: app.tryGetAuthedWallet(c), + MyID: myId, + Ids: []int32{int32(trackId)}, + AuthedWallet: app.tryGetAuthedWallet(c), + IncludeUnlisted: true, // allow fetch by ID even when track is unlisted }, }) if err != nil { diff --git a/api/v1_track_download.go b/api/v1_track_download.go index 7dcaca30..4e5bef78 100644 --- a/api/v1_track_download.go +++ b/api/v1_track_download.go @@ -27,9 +27,10 @@ func (app *ApiServer) v1TrackDownload(c *fiber.Ctx) error { tracks, err := app.queries.Tracks(c.Context(), dbv1.TracksParams{ GetTracksParams: dbv1.GetTracksParams{ - MyID: myId, - Ids: []int32{int32(trackId)}, - AuthedWallet: app.tryGetAuthedWallet(c), + MyID: myId, + Ids: []int32{int32(trackId)}, + AuthedWallet: app.tryGetAuthedWallet(c), + IncludeUnlisted: true, // allow download by ID even when track is unlisted }, }) if err != nil { diff --git a/api/v1_track_inspect.go b/api/v1_track_inspect.go index 6b45ba8b..bc8af090 100644 --- a/api/v1_track_inspect.go +++ b/api/v1_track_inspect.go @@ -75,9 +75,10 @@ func (app *ApiServer) v1TrackInspect(c *fiber.Ctx) error { tracks, err := app.queries.Tracks(c.Context(), dbv1.TracksParams{ GetTracksParams: dbv1.GetTracksParams{ - MyID: myId, - Ids: []int32{int32(trackId)}, - AuthedWallet: app.tryGetAuthedWallet(c), + MyID: myId, + Ids: []int32{int32(trackId)}, + AuthedWallet: app.tryGetAuthedWallet(c), + IncludeUnlisted: true, // allow inspect by ID even when track is unlisted }, }) if err != nil { @@ -106,9 +107,10 @@ func (app *ApiServer) v1TracksInspect(c *fiber.Ctx) error { tracks, err := app.queries.Tracks(c.Context(), dbv1.TracksParams{ GetTracksParams: dbv1.GetTracksParams{ - MyID: myId, - Ids: ids, - AuthedWallet: app.tryGetAuthedWallet(c), + MyID: myId, + Ids: ids, + AuthedWallet: app.tryGetAuthedWallet(c), + IncludeUnlisted: true, // allow inspect by ID even when track is unlisted }, }) if err != nil { diff --git a/api/v1_track_remixing.go b/api/v1_track_remixing.go index e7955983..3de33dab 100644 --- a/api/v1_track_remixing.go +++ b/api/v1_track_remixing.go @@ -19,15 +19,14 @@ func (app *ApiServer) v1TrackRemixing(c *fiber.Ctx) error { myId := app.getMyId(c) trackId := c.Locals("trackId").(int) + // Allow unlisted when requesting by track ID (caller has the id so may share the track) sql := ` SELECT pt.track_id FROM tracks pt JOIN remixes r ON r.parent_track_id = pt.track_id AND r.child_track_id = @trackId - JOIN tracks ct ON ct.track_id = @trackId + JOIN tracks ct ON ct.track_id = @trackId AND ct.is_current = true WHERE pt.is_current = true AND pt.is_unlisted = false - AND ct.is_current = true - AND ct.is_stream_gated = false ORDER BY pt.created_at DESC, pt.track_id DESC LIMIT @limit OFFSET @offset ` diff --git a/api/v1_track_stream.go b/api/v1_track_stream.go index 0d9d2fb5..1bab663f 100644 --- a/api/v1_track_stream.go +++ b/api/v1_track_stream.go @@ -11,9 +11,10 @@ func (app *ApiServer) v1TrackStream(c *fiber.Ctx) error { tracks, err := app.queries.Tracks(c.Context(), dbv1.TracksParams{ GetTracksParams: dbv1.GetTracksParams{ - MyID: myId, - Ids: []int32{int32(trackId)}, - AuthedWallet: app.tryGetAuthedWallet(c), + MyID: myId, + Ids: []int32{int32(trackId)}, + AuthedWallet: app.tryGetAuthedWallet(c), + IncludeUnlisted: true, // allow stream by ID even when track is unlisted }, }) if err != nil { From 1a86c6d7d73ea39f2177e90c063525572572e2a2 Mon Sep 17 00:00:00 2001 From: Dylan Jeffers Date: Fri, 13 Mar 2026 14:22:33 -0700 Subject: [PATCH 2/3] Address comments --- api/v1_track.go | 2 +- api/v1_track_download.go | 2 +- api/v1_track_inspect.go | 4 ++-- api/v1_track_remixing.go | 3 +-- api/v1_track_stream.go | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/api/v1_track.go b/api/v1_track.go index 31c55c89..a8d24fd2 100644 --- a/api/v1_track.go +++ b/api/v1_track.go @@ -204,7 +204,7 @@ func (app *ApiServer) v1Track(c *fiber.Ctx) error { MyID: myId, Ids: []int32{int32(trackId)}, AuthedWallet: app.tryGetAuthedWallet(c), - IncludeUnlisted: true, // allow fetch by ID even when track is unlisted + IncludeUnlisted: true, }, }) if err != nil { diff --git a/api/v1_track_download.go b/api/v1_track_download.go index 4e5bef78..ef0a6454 100644 --- a/api/v1_track_download.go +++ b/api/v1_track_download.go @@ -30,7 +30,7 @@ func (app *ApiServer) v1TrackDownload(c *fiber.Ctx) error { MyID: myId, Ids: []int32{int32(trackId)}, AuthedWallet: app.tryGetAuthedWallet(c), - IncludeUnlisted: true, // allow download by ID even when track is unlisted + IncludeUnlisted: true, }, }) if err != nil { diff --git a/api/v1_track_inspect.go b/api/v1_track_inspect.go index bc8af090..a5b24504 100644 --- a/api/v1_track_inspect.go +++ b/api/v1_track_inspect.go @@ -78,7 +78,7 @@ func (app *ApiServer) v1TrackInspect(c *fiber.Ctx) error { MyID: myId, Ids: []int32{int32(trackId)}, AuthedWallet: app.tryGetAuthedWallet(c), - IncludeUnlisted: true, // allow inspect by ID even when track is unlisted + IncludeUnlisted: true, }, }) if err != nil { @@ -110,7 +110,7 @@ func (app *ApiServer) v1TracksInspect(c *fiber.Ctx) error { MyID: myId, Ids: ids, AuthedWallet: app.tryGetAuthedWallet(c), - IncludeUnlisted: true, // allow inspect by ID even when track is unlisted + IncludeUnlisted: true, }, }) if err != nil { diff --git a/api/v1_track_remixing.go b/api/v1_track_remixing.go index 3de33dab..09df26d6 100644 --- a/api/v1_track_remixing.go +++ b/api/v1_track_remixing.go @@ -19,12 +19,11 @@ func (app *ApiServer) v1TrackRemixing(c *fiber.Ctx) error { myId := app.getMyId(c) trackId := c.Locals("trackId").(int) - // Allow unlisted when requesting by track ID (caller has the id so may share the track) sql := ` SELECT pt.track_id FROM tracks pt JOIN remixes r ON r.parent_track_id = pt.track_id AND r.child_track_id = @trackId - JOIN tracks ct ON ct.track_id = @trackId AND ct.is_current = true + JOIN tracks ct ON ct.track_id = @trackId AND ct.is_current = true AND ct.is_stream_gated = false WHERE pt.is_current = true AND pt.is_unlisted = false ORDER BY pt.created_at DESC, pt.track_id DESC diff --git a/api/v1_track_stream.go b/api/v1_track_stream.go index 1bab663f..bbae56dc 100644 --- a/api/v1_track_stream.go +++ b/api/v1_track_stream.go @@ -14,7 +14,7 @@ func (app *ApiServer) v1TrackStream(c *fiber.Ctx) error { MyID: myId, Ids: []int32{int32(trackId)}, AuthedWallet: app.tryGetAuthedWallet(c), - IncludeUnlisted: true, // allow stream by ID even when track is unlisted + IncludeUnlisted: true, }, }) if err != nil { From 6b0212b59de4c3c08430b714a9e066a91255e1cc Mon Sep 17 00:00:00 2001 From: Dylan Jeffers Date: Fri, 13 Mar 2026 14:32:39 -0700 Subject: [PATCH 3/3] Fix test --- api/v1_track_remixing_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/v1_track_remixing_test.go b/api/v1_track_remixing_test.go index 4e26d65f..e5fa39cc 100644 --- a/api/v1_track_remixing_test.go +++ b/api/v1_track_remixing_test.go @@ -1,6 +1,7 @@ package api import ( + "context" "testing" "api.audius.co/database" @@ -93,6 +94,9 @@ func TestV1TrackRemixing(t *testing.T) { database.Seed(app.pool.Replicas[0], fixtures) + _, err := app.pool.Replicas[0].Exec(context.Background(), `UPDATE tracks SET is_unlisted = true WHERE track_id = 2`) + assert.NoError(t, err) + status, body := testGet(t, app, "/v1/full/tracks/"+trashid.MustEncodeHashID(10)+"/remixing") assert.Equal(t, 200, status)