Relay device-sync v4 and keep podcast queue items

Use the shared music_dht::device_sync types instead of private copies
(byte-identical for v3 content, checked against the 0.12.x types and a
golden fixture) and announce protocol 4, because every v4 element is
kept:

- podcast operations stay in the operation log and are relayed only to
  peers that reported v4; their registers and the podcast snapshot
  sections are merged with the shared rules into an opaque relay table
  and returned in this server's snapshots (m_0055);
- the browser bridge carries PlaybackTrack.source: items that are not
  library tracks keep the verbatim wire item, so podcast episodes and
  Jam placeholders survive the round trip; the player labels and skips
  them instead of dropping them;
- the typed queue is persisted in queue_items_json next to queue_json,
  which is still written for rollback (m_0054).

Peer versions come from self-reports (profile_protocol_version); relayed
profiles only raise them and DeviceProfileSet no longer stores this
server's constant. Invites carry the inviter's version and a
DeviceProfileSet announces v4 once. Handoffs of a podcast queue to a
device below v4 are refused with an update message, and its playback
commands are ignored while the queue has podcast items. Jam guests see
podcast items as private placeholders, which are mapped back on their
commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sanapachandClaude Opus 5.5 committed 2026-11-19 16:58:29 +02:00
1 parent 75c67026ac
commit b558cf381e
20 files changed
+3587 -653

No files matched your search

+14 -5
View File
@@ -1438,18 +1438,22 @@ async fn delete_entities(
}
}
// Playback queues contain local IDs rather than foreign keys.
let states: Vec<(i64, Option<i64>, String)> = sqlx::query_as(
"SELECT id,current_track_id,queue_json FROM furumusic__playback_state FOR UPDATE",
let states: Vec<(i64, Option<i64>, String, Option<serde_json::Value>)> = sqlx::query_as(
"SELECT id,current_track_id,queue_json,queue_items_json FROM furumusic__playback_state FOR UPDATE",
)
.fetch_all(&mut *conn)
.await?;
for (id, current, queue_json) in states {
for (id, current, queue_json, queue_items_json) in states {
let mut queue: Vec<i64> = serde_json::from_str(&queue_json).unwrap_or_default();
if !current.is_some_and(|id| deleted.tracks.contains(&id))
&& !queue.iter().any(|id| deleted.tracks.contains(id))
{
continue;
}
let mut typed = crate::player::queue_items::StoredQueue::from_columns(
queue_items_json.as_ref(),
&queue,
);
let before: String = sqlx::query_scalar(
"SELECT to_jsonb(t)::text FROM furumusic__playback_state t WHERE id=$1",
)
@@ -1457,12 +1461,16 @@ async fn delete_entities(
.fetch_one(&mut *conn)
.await?;
queue.retain(|id| !deleted.tracks.contains(id));
if let Some(typed) = &mut typed {
typed.retain_library(|id| !deleted.tracks.contains(&id), queue.clone());
}
let queue_items_json = typed.map(serde_json::to_value).transpose()?;
let current = current.filter(|id| !deleted.tracks.contains(id));
let position = current
.and_then(|id| queue.iter().position(|x| *x == id))
.unwrap_or(0) as i32;
let after: String = sqlx::query_scalar("UPDATE furumusic__playback_state SET current_track_id=$2,queue_json=$3,queue_position=$4,position_ms=CASE WHEN current_track_id IS DISTINCT FROM $2 THEN 0 ELSE position_ms END WHERE id=$1 RETURNING to_jsonb(furumusic__playback_state)::text")
.bind(id).bind(current).bind(serde_json::to_string(&queue)?).bind(position).fetch_one(&mut *conn).await?;
let after: String = sqlx::query_scalar("UPDATE furumusic__playback_state SET current_track_id=$2,queue_json=$3,queue_position=$4,queue_items_json=$5,position_ms=CASE WHEN current_track_id IS DISTINCT FROM $2 THEN 0 ELSE position_ms END WHERE id=$1 RETURNING to_jsonb(furumusic__playback_state)::text")
.bind(id).bind(current).bind(serde_json::to_string(&queue)?).bind(position).bind(queue_items_json).fetch_one(&mut *conn).await?;
archived.push(ArchivedRows {
table: "furumusic__playback_state".into(),
rows: serde_json::json!([serde_json::from_str::<serde_json::Value>(&before)?]),
@@ -1502,6 +1510,7 @@ async fn restore_deleted(conn: &mut PgConnection, archived: &[ArchivedRows]) ->
&[
"current_track_id",
"queue_json",
"queue_items_json",
"queue_position",
"position_ms",
]