Update queued song status #63
@@ -458,10 +458,19 @@ impl CommitManager {
|
|||||||
.link_queued_song_to_queued_coverart(token, &queued_song_id, &id)
|
.link_queued_song_to_queued_coverart(token, &queued_song_id, &id)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(_) => {
|
Ok(_) => match up
|
||||||
println!("Queued coverart Id: {id:?}");
|
.update_queued_song_status(token, &queued_song_id, "ready")
|
||||||
println!("Linked queued song to queued coverart");
|
.await
|
||||||
}
|
{
|
||||||
|
Ok(_) => {
|
||||||
|
println!("Queued coverart Id: {id:?}");
|
||||||
|
println!("Linked queued song to queued coverart");
|
||||||
|
println!("Queued status updated");
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
return Err(std::io::Error::other(err.to_string()));
|
||||||
|
}
|
||||||
|
},
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return Err(std::io::Error::other(err.to_string()));
|
return Err(std::io::Error::other(err.to_string()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -300,6 +300,38 @@ impl Upload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn update_queued_song_status(
|
||||||
|
&self,
|
||||||
|
token: &icarus_models::token::AccessToken,
|
||||||
|
queued_song_id: &uuid::Uuid,
|
||||||
|
status: &str,
|
||||||
|
) -> Result<(), reqwest::Error> {
|
||||||
|
let endpoint = String::from("api/v2/song/queue");
|
||||||
|
let url = format!("{}/{endpoint}", self.api.url);
|
||||||
|
|
||||||
|
let mut headers = reqwest::header::HeaderMap::new();
|
||||||
|
let (auth, auth_val) = syncers::common::auth_header(token).await;
|
||||||
|
headers.insert(auth, auth_val);
|
||||||
|
|
||||||
|
let payload = serde_json::json!({
|
||||||
|
"id": queued_song_id,
|
||||||
|
"status": status
|
||||||
|
});
|
||||||
|
|
||||||
|
let client = reqwest::Client::builder().build().unwrap();
|
||||||
|
|
||||||
|
match client
|
||||||
|
.patch(url)
|
||||||
|
.headers(headers)
|
||||||
|
.json(&payload)
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(_) => Ok(()),
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn init_form(
|
fn init_form(
|
||||||
&self,
|
&self,
|
||||||
song: &icarus_models::song::Song,
|
song: &icarus_models::song::Song,
|
||||||
|
|||||||
Reference in New Issue
Block a user