From e0d6cbcbf5d146dd491b95d57cab08b2d3c03a67 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Wed, 29 Oct 2025 14:41:31 -0400 Subject: [PATCH] tsk-213: Added check for updating queued song --- src/callers/queue/song.rs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/callers/queue/song.rs b/src/callers/queue/song.rs index 6c1fbd5..097081a 100644 --- a/src/callers/queue/song.rs +++ b/src/callers/queue/song.rs @@ -411,15 +411,28 @@ pub mod endpoint { ); let raw_data: Vec = data.to_vec(); - match repo::song::update(&pool, &raw_data, &id).await { - Ok(_) => { - response.message = String::from("Successful"); - response.data.push(id); - (axum::http::StatusCode::OK, axum::Json(response)) + match super::is_song_valid(&raw_data).await { + Ok(valid) => { + if valid { + match repo::song::update(&pool, &raw_data, &id).await { + Ok(_) => { + response.message = String::from(super::super::super::response::SUCCESSFUL); + response.data.push(id); + (axum::http::StatusCode::OK, axum::Json(response)) + } + Err(err) => { + response.message = err.to_string(); + (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) + } + } + } else { + response.message = String::from("Invalid song type"); + return (axum::http::StatusCode::INTERNAL_SERVER_ERROR, axum::Json(response)) + } } Err(err) => { response.message = err.to_string(); - (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) + return (axum::http::StatusCode::INTERNAL_SERVER_ERROR, axum::Json(response)); } } } else {