diff --git a/src/callers/song.rs b/src/callers/song.rs index f8ee210..a4c4856 100644 --- a/src/callers/song.rs +++ b/src/callers/song.rs @@ -84,6 +84,14 @@ pub mod request { pub song_queue_id: uuid::Uuid, } } + + pub mod link_user_id { + #[derive(Debug, serde::Deserialize, serde::Serialize)] + pub struct Request { + pub song_queue_id: uuid::Uuid, + pub user_id: uuid::Uuid, + } + } } pub mod response { @@ -142,6 +150,14 @@ pub mod response { pub data: Vec, } } + + pub mod link_user_id { + #[derive(Debug, Default, serde::Deserialize, serde::Serialize)] + pub struct Response { + pub message: String, + pub data: Vec, + } + } } // TODO: Might make a distinction between year and date in a song's tag at some point @@ -616,6 +632,20 @@ pub mod endpoint { (StatusCode::OK, Json(response)) } + pub async fn link_user_id(axum::Extension(pool): axum::Extension, axum::Json(payload): axum::Json) -> (axum::http::StatusCode, axum::Json) { + let mut response = super::response::link_user_id::Response::default(); + + match super::song_queue::get_song_queue(&pool, &payload.song_queue_id).await { + Ok(song_queue) => { + (axum::http::StatusCode::OK, axum::Json(response)) + } + Err(err) => { + response.message = err.to_string(); + (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) + } + } + } + pub async fn fetch_queue_song( axum::Extension(pool): axum::Extension, ) -> (