feat(playlists): changes a phone queues offline are safe to send twice (#8023)
release / go (push) Successful in 1m59s
release / web (push) Successful in 1m23s
release / govulncheck (push) Successful in 22s
release / integration (push) Successful in 4m38s
release / android (push) Successful in 4m45s
release / Build signed APK (push) Successful in 5m22s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 17s
release / Verify release artifacts (tag releases only) (push) Skipped

- A new playlist can carry the client's own id; sending the create
  again finds the same list.
- Removing a song can name the song expected at that position; if
  another song is there now, nothing is removed (409 list_changed).
- A reorder can give the songs in their new order (track_ids); sending
  it again changes nothing.
- The playlist service tells the owner's clients about every change
  itself, so a change made from a Subsonic app refreshes the web and
  Android apps too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-26 10:22:40 -05:00
co-authored by Claude Opus 5.5
parent 1df91678ba
commit a77f3ae6ff
9 changed files with 421 additions and 88 deletions
+15 -2
View File
@@ -1,6 +1,10 @@
-- name: CreatePlaylist :one
INSERT INTO playlists (user_id, name, description, is_public)
VALUES ($1, $2, $3, $4)
-- id is the client's own id for the list, or NULL for a new one. A client
-- that made the list offline sends its id again on every retry, so an id
-- already taken inserts nothing and returns no row.
INSERT INTO playlists (id, user_id, name, description, is_public)
VALUES (COALESCE(sqlc.narg(id)::uuid, gen_random_uuid()), sqlc.arg(user_id), sqlc.arg(name), sqlc.arg(description), sqlc.arg(is_public))
ON CONFLICT (id) DO NOTHING
RETURNING *;
-- name: GetPlaylist :one
@@ -49,6 +53,15 @@ UPDATE playlists SET cover_path = $2, updated_at = now() WHERE id = $1;
DELETE FROM playlists WHERE id = $1
RETURNING id, cover_path;
-- name: ListPlaylistEntriesForUpdate :many
-- The track at each position, locking the rows while a reorder rewrites
-- them.
SELECT position, track_id
FROM playlist_tracks
WHERE playlist_id = $1
ORDER BY position
FOR UPDATE;
-- name: ListPlaylistTracks :many
-- Joined to tracks for the live track id (the service layer derives the
-- stream URL from it); LEFT JOIN preserves the row when track_id is NULL