diff --git a/src/callers/coverart.rs b/src/callers/coverart.rs index 15de43a..478b749 100644 --- a/src/callers/coverart.rs +++ b/src/callers/coverart.rs @@ -1,9 +1,28 @@ +pub mod request { + + pub mod link { + #[derive(Debug, Default, serde::Deserialize, serde::Serialize)] + pub struct Request { + pub coverart_id: uuid::Uuid, + pub song_queue_id: uuid::Uuid, + } + } +} + pub mod response { #[derive(Debug, Default, serde::Deserialize, serde::Serialize)] pub struct Response { pub message: String, pub data: Vec, } + + pub mod link { + #[derive(Debug, Default, serde::Deserialize, serde::Serialize)] + pub struct Response { + pub message: String, + pub data: Vec, + } + } } mod db { @@ -33,6 +52,10 @@ mod db { Err(_err) => Err(sqlx::Error::RowNotFound), } } + + pub async fn update(pool: &sqlx::PgPool, coverart_id: &uuid::Uuid, song_queue_id: &uuid::Uuid,) -> Result { + Ok(0) + } } pub mod endpoint { @@ -80,4 +103,23 @@ pub mod endpoint { } } } + + pub async fn link( + axum::Extension(pool): axum::Extension, + axum::Json(payload): axum::Json, + ) -> (axum::http::StatusCode, axum::Json,) { + let mut response = super::response::link::Response::default(); + let coverart_id = payload.coverart_id; + let song_queue_id = payload.song_queue_id; + + match super::db::update(&pool, &coverart_id, &song_queue_id).await { + Ok(o) => { + (axum::http::StatusCode::OK, axum::Json(response)) + } + Err(err) => { + response.message = err.to_string(); + (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) + } + } + } } diff --git a/src/callers/mod.rs b/src/callers/mod.rs index 55d2907..de9b756 100644 --- a/src/callers/mod.rs +++ b/src/callers/mod.rs @@ -8,4 +8,5 @@ pub mod endpoints { pub const NEXTQUEUESONG: &str = "/api/v2/song/queue/next"; pub const QUEUEMETADATA: &str = "/api/v2/song/metadata/queue"; pub const QUEUECOVERART: &str = "/api/v2/coverart/queue"; + pub const QUEUECOVERARTLINK: &str = "/api/v2/coverart/queue/link"; } diff --git a/src/main.rs b/src/main.rs index d7ff00c..74a9000 100644 --- a/src/main.rs +++ b/src/main.rs @@ -58,7 +58,7 @@ async fn main() { } pub mod init { - use axum::routing::{get, post}; + use axum::routing::{get, patch, post}; use std::time::Duration; use tower_http::timeout::TimeoutLayer; @@ -89,6 +89,10 @@ pub mod init { crate::callers::endpoints::QUEUECOVERART, post(crate::callers::coverart::endpoint::queue), ) + .route( + crate::callers::endpoints::QUEUECOVERARTLINK, + patch(crate::callers::coverart::endpoint::link), + ) } pub async fn app() -> axum::Router {