refactor: drop the dead REST play-queue sync

POST /queues answers every create with the placeholder id 000000000000000000000000
and GET /queues lists nothing, so publishing the queue never reached another
device. Remove create_queue/update_queue_position, QueueContext, the
QueueStarted/QueueMoved effects and the app's server_queue state.

Yandex's apps sync through Ynison instead, but Ynison answers this account
with 503 "temporary unavailable" (code 500140000) and the phone app offers no
device handoff, so there is no working replacement yet.
This commit is contained in:
Yuriy Panov committed 2026-10-15 21:55:24 +06:00
1 parent 52ad4a2e90
commit 24aa41e8fb
7 files changed
+4 -159

No files matched your search

+1 -49
View File
@@ -6,7 +6,7 @@ use crate::library::{
AlbumPage, AlbumSummary, ArtistPage, ArtistSummary, LibraryPlaylists, PlaylistId, PlaylistPage,
PlaylistSummary,
};
use crate::edit::{LikedIds, Lyrics, QueueContext};
use crate::edit::{LikedIds, Lyrics};
use crate::discover::{ChartEntry, Genre, Home, SearchKind, SearchResults};
use crate::models::{Stream, Track, best_variant, file_info_stream};
use crate::wave::{PlayReport, Station, WaveBatch, WaveEvent, WaveSettings, iso_millis, numeric_id};
@@ -61,11 +61,6 @@ fn recent_track_ids(history: &yamuse::models::MusicHistory, limit: usize) -> Vec
.collect()
}
/// A queue id, unless it's the all-zero placeholder Yandex returns for a queue it didn't keep.
fn real_queue_id(id: Option<String>) -> Option<String> {
id.filter(|id| !id.is_empty() && !id.bytes().all(|b| b == b'0'))
}
/// The signed-in user as the UI needs them.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Account {
@@ -688,41 +683,6 @@ impl YmClient {
Ok(None)
}
// ---- Server queue ----
/// Publishes what's playing so other devices can continue it. Returns the queue id,
/// or `None` when Yandex didn't keep the queue.
///
/// Yandex now answers every create with the placeholder id `000000000000000000000000`
/// and lists no queues afterwards, whatever device header is sent (a stable
/// `device_id` was tried): the phone apps sync through Ynison instead. The
/// placeholder is dropped so no position updates go to a queue that doesn't exist.
pub async fn create_queue(&self, context: &QueueContext, tracks: &[Track], current: usize) -> Result<Option<String>> {
let tracks: Vec<serde_json::Value> = tracks
.iter()
.map(|t| {
serde_json::json!({
"trackId": t.id.split(':').next().unwrap_or(&t.id),
"albumId": t.album.as_ref().map(|a| a.id.to_string()).unwrap_or_default(),
"from": "musyx-desktop",
})
})
.collect();
let body = serde_json::json!({
"context": context.to_json(),
"tracks": tracks,
"currentIndex": current,
"from": "musyx-desktop",
"isInteractive": true,
});
Ok(real_queue_id(self.inner.create_queue(&body, None).await?))
}
pub async fn update_queue_position(&self, queue_id: &str, index: usize) -> Result<()> {
self.inner.update_queue_position(queue_id, index as i64, None).await?;
Ok(())
}
/// Downloads an image (covers are a few kilobytes).
pub async fn image(&self, url: &str) -> Result<Vec<u8>> {
Ok(yamuse::download::Downloader::new(self.inner.transport(), [url.to_owned()])
@@ -798,14 +758,6 @@ mod tests {
assert_eq!(recent_track_ids(&history, 10).len(), 4);
}
#[test]
fn placeholder_queue_ids_are_dropped() {
assert_eq!(real_queue_id(Some("000000000000000000000000".into())), None);
assert_eq!(real_queue_id(Some(String::new())), None);
assert_eq!(real_queue_id(None), None);
assert_eq!(real_queue_id(Some("6702a1f0c3".into())).as_deref(), Some("6702a1f0c3"));
}
#[test]
fn anonymous_status_is_not_an_account() {
assert!(Account::from_status(status(r#"{"account":{"now":"2026-10-15"}}"#)).is_none());
-31
View File
@@ -89,31 +89,6 @@ fn parse_stamp(s: &str) -> Option<Duration> {
Some(Duration::from_millis((min * 60 + whole) * 1000 + millis))
}
/// Where a server queue's tracks come from; other devices show it as "Playing from…".
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum QueueContext {
Album(i64),
Playlist(PlaylistId),
Artist(i64),
/// Liked tracks.
MyMusic,
/// Search results, the chart, anything else.
Various,
}
impl QueueContext {
pub(crate) fn to_json(&self) -> serde_json::Value {
let (kind, id) = match self {
QueueContext::Album(id) => ("album", id.to_string()),
QueueContext::Playlist(p) => ("playlist", format!("{}:{}", p.owner, p.kind)),
QueueContext::Artist(id) => ("artist", id.to_string()),
QueueContext::MyMusic => ("my_music", String::new()),
QueueContext::Various => ("various", String::new()),
};
serde_json::json!({ "type": kind, "id": id, "description": "" })
}
}
#[cfg(test)]
mod tests {
use super::*;
@@ -147,10 +122,4 @@ mod tests {
assert_eq!(parse_stamp("00:01.1234"), None);
}
#[test]
fn queue_contexts_match_the_api_shape() {
let p = QueueContext::Playlist(PlaylistId { owner: 9, kind: 3 }).to_json();
assert_eq!(p, serde_json::json!({"type": "playlist", "id": "9:3", "description": ""}));
assert_eq!(QueueContext::MyMusic.to_json()["type"], "my_music");
}
}
+1 -1
View File
@@ -24,5 +24,5 @@ pub use wave::{
Character, Language, MY_WAVE, Mood, PlayReport, Station, WaveBatch, WaveEvent, WaveSettings,
};
pub use discover::{BestMatch, ChartEntry, Genre, Home, Personal, SearchKind, SearchResults, Totals};
pub use edit::{LikedIds, LyricLine, Lyrics, QueueContext};
pub use edit::{LikedIds, LyricLine, Lyrics};
pub use error::{Error, Result};