Add synced listening history

This commit is contained in:
Ultradesu
2026-07-27 23:16:03 +01:00
parent 845df4e031
commit 232c171aac
13 changed files with 498 additions and 236 deletions
+30
View File
@@ -229,6 +229,36 @@ impl Federation {
}
}
pub async fn prepare_discovered_content_with_progress<F>(
self: &std::sync::Arc<Self>,
content_id: &str,
progress: F,
) -> Result<PreparedTrack>
where
F: FnMut(DownloadProgress) + Send,
{
let content_id =
music_dht::normalize_content_id(content_id).context("invalid content id")?;
let service = self.service().await?;
let outcome = service.search_content_id(&content_id).await?;
let item = outcome
.local_results
.into_iter()
.chain(outcome.network_results)
.find(|item| {
item.kind == music_dht::ItemKind::Track
&& item.content_id.as_deref() == Some(content_id.as_str())
})
.context("no peer currently advertises this content id")?;
self.prepare_content_with_progress(
&content_id,
&item.owner.to_string(),
&hex_encode(item.id.as_bytes()),
progress,
)
.await
}
pub async fn prepare_content_with_progress<F>(
self: &std::sync::Arc<Self>,
content_id: &str,