Wipe data from song queue #35

Merged
phoenix merged 6 commits from wipe_data_from_song_queue into devel 2025-07-15 19:49:25 +00:00
2 changed files with 31 additions and 20 deletions
Showing only changes of commit 3b391067f9 - Show all commits

View File

@@ -31,9 +31,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
(coverart_queue_id, coverart_queue_path), (coverart_queue_id, coverart_queue_path),
)) => { )) => {
// TODO: Wipe data from song and coverart queues // TODO: Wipe data from song and coverart queues
match wipe_data_from_queues(&app_base_url, &song_queue_id, &coverart_queue_id).await { match wipe_data_from_queues(
Ok(_) => { &app_base_url,
} &song_queue_id,
&coverart_queue_id,
)
.await
{
Ok(_) => {}
Err(err) => { Err(err) => {
eprintln!("Error: {err:?}"); eprintln!("Error: {err:?}");
} }
@@ -58,20 +63,23 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
} }
} }
async fn wipe_data_from_queues(app_base_url: &String, song_queue_id: &uuid::Uuid, coverart_queue_id: &uuid::Uuid) -> Result<(), std::io::Error> { async fn wipe_data_from_queues(
app_base_url: &String,
song_queue_id: &uuid::Uuid,
coverart_queue_id: &uuid::Uuid,
) -> Result<(), std::io::Error> {
match the_rest::wipe_data::song_queue::wipe_data(app_base_url, song_queue_id).await { match the_rest::wipe_data::song_queue::wipe_data(app_base_url, song_queue_id).await {
Ok(response) => match response.json::<the_rest::wipe_data::song_queue::response::Response>().await { Ok(response) => match response
.json::<the_rest::wipe_data::song_queue::response::Response>()
.await
{
Ok(_resp) => { Ok(_resp) => {
println!("Wiped data from song queue"); println!("Wiped data from song queue");
Ok(()) Ok(())
} }
Err(err) => { Err(err) => Err(std::io::Error::other(err.to_string())),
Err(std::io::Error::other(err.to_string())) },
} Err(err) => Err(std::io::Error::other(err.to_string())),
}
Err(err) => {
Err(std::io::Error::other(err.to_string()))
}
} }
} }

View File

@@ -76,7 +76,10 @@ pub mod create_coverart {
pub mod wipe_data { pub mod wipe_data {
pub mod song_queue { pub mod song_queue {
pub async fn wipe_data(base_url: &String, song_queue_id: &uuid::Uuid) -> Result<reqwest::Response, reqwest::Error> { pub async fn wipe_data(
base_url: &String,
song_queue_id: &uuid::Uuid,
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::builder().build()?; let client = reqwest::Client::builder().build()?;
let url = format!("{base_url}/api/v2/song/queue/data/wipe"); let url = format!("{base_url}/api/v2/song/queue/data/wipe");
let payload = serde_json::json!({ let payload = serde_json::json!({