diff --git a/src/callers/metadata.rs b/src/callers/metadata.rs index 93bc5bf..253023f 100644 --- a/src/callers/metadata.rs +++ b/src/callers/metadata.rs @@ -46,36 +46,8 @@ pub mod request { pub song_queue_id: Option, } } - - pub mod create_metadata { - #[derive(Debug, serde::Deserialize, serde::Serialize)] - pub struct Request { - pub title: String, - pub artist: String, - pub album_artist: String, - pub album: String, - pub genre: String, - pub date: String, - pub track: i32, - pub disc: i32, - pub track_count: i32, - pub disc_count: i32, - pub duration: i32, - } - - impl Request { - pub fn is_valid(&self) -> bool { - !self.title.is_empty() || !self.artist.is_empty() || !self.album_artist.is_empty() - || !self.album.is_empty() || !self.genre.is_empty() || !self.date.is_empty() - || self.track > 0 || self.disc > 0 || self.track_count > 0 || self.disc_count > 0 - || self.duration > 0 - } - } - } } -// TODO: Might make a distinction between year and date in a song's tag at some point - pub mod response { use serde::{Deserialize, Serialize}; @@ -94,13 +66,6 @@ pub mod response { pub data: Vec, } } - - pub mod create_metadata { - #[derive(Default, serde::Deserialize, serde::Serialize)] - pub struct Response { - pub message: String, - } - } } pub mod metadata_queue { @@ -232,9 +197,6 @@ pub mod metadata_queue { } } -pub mod metadata { -} - pub mod endpoint { use axum::{Json, http::StatusCode}; @@ -309,19 +271,4 @@ pub mod endpoint { }, } } - - // TODO: Implement - pub async fn create_metadata( - axum::Extension(pool): axum::Extension, - axum::Json(payload): axum::Json, - ) -> (axum::http::StatusCode, axum::Json) { - let mut response = super::response::create_metadata::Response::default(); - - if payload.is_valid() { - (axum::http::StatusCode::OK, axum::Json(response)) - } else { - response.message = String::from("Request body is not valid"); - (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) - } - } } diff --git a/src/callers/song.rs b/src/callers/song.rs index b4ddeef..9210fee 100644 --- a/src/callers/song.rs +++ b/src/callers/song.rs @@ -13,6 +13,32 @@ pub mod request { pub status: String, } } + + pub mod create_metadata { + #[derive(Debug, serde::Deserialize, serde::Serialize)] + pub struct Request { + pub title: String, + pub artist: String, + pub album_artist: String, + pub album: String, + pub genre: String, + pub date: String, + pub track: i32, + pub disc: i32, + pub track_count: i32, + pub disc_count: i32, + pub duration: i32, + } + + impl Request { + pub fn is_valid(&self) -> bool { + !self.title.is_empty() || !self.artist.is_empty() || !self.album_artist.is_empty() + || !self.album.is_empty() || !self.genre.is_empty() || !self.date.is_empty() + || self.track > 0 || self.disc > 0 || self.track_count > 0 || self.disc_count > 0 + || self.duration > 0 + } + } + } } pub mod response { @@ -55,8 +81,17 @@ pub mod response { pub data: Vec>, } } + + pub mod create_metadata { + #[derive(Default, serde::Deserialize, serde::Serialize)] + pub struct Response { + pub message: String, + } + } } +// TODO: Might make a distinction between year and date in a song's tag at some point + pub mod status { pub const PENDING: &str = "pending"; pub const PROCESSING: &str = "processing"; @@ -456,4 +491,19 @@ pub mod endpoint { (axum::http::StatusCode::NOT_FOUND, axum::Json(response)) } } + + // TODO: Implement + pub async fn create_metadata( + axum::Extension(pool): axum::Extension, + axum::Json(payload): axum::Json, + ) -> (axum::http::StatusCode, axum::Json) { + let mut response = super::response::create_metadata::Response::default(); + + if payload.is_valid() { + (axum::http::StatusCode::OK, axum::Json(response)) + } else { + response.message = String::from("Request body is not valid"); + (axum::http::StatusCode::BAD_REQUEST, axum::Json(response)) + } + } }