From 884753b9969017072bc00525414c08517e885bb2 Mon Sep 17 00:00:00 2001 From: phoenix Date: Sat, 18 Jul 2026 13:36:05 -0400 Subject: [PATCH] icarus_models -> simodels --- Cargo.lock | 30 +++++++++++++++--------------- Cargo.toml | 2 +- src/auth/mod.rs | 2 +- src/callers/coverart.rs | 31 ++++++++++++++----------------- src/callers/queue/coverart.rs | 9 ++++----- src/callers/song.rs | 22 ++++++++++------------ src/main.rs | 22 +++++++++++----------- src/repo/coverart.rs | 14 +++++++------- src/repo/song.rs | 20 +++++++++----------- 9 files changed, 72 insertions(+), 80 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 00b75df..dc5e512 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1049,20 +1049,6 @@ dependencies = [ "rand 0.10.2", ] -[[package]] -name = "icarus_models" -version = "0.11.3" -source = "git+ssh://git@git.kundeng.us/phoenix/icarus_models.git?tag=v0.11.3#859b0fb1b377370d8171e22e59893d86e41b258b" -dependencies = [ - "josekit", - "rand 0.10.2", - "serde", - "serde_json", - "time", - "utoipa", - "uuid", -] - [[package]] name = "icu_collections" version = "2.2.0" @@ -2155,6 +2141,20 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214" +[[package]] +name = "simodels" +version = "0.11.3" +source = "git+ssh://git@git.kundeng.us/phoenix/simodels.git?tag=v0.11.3-main-fe9d101bd0-111#fe9d101bd019f91fe8c99c29721ccb0e6e90c92c" +dependencies = [ + "josekit", + "rand 0.10.2", + "serde", + "serde_json", + "time", + "utoipa", + "uuid", +] + [[package]] name = "simple_asn1" version = "0.6.4" @@ -2191,7 +2191,6 @@ dependencies = [ "common-multipart-rfc7578", "futures", "icarus_meta", - "icarus_models", "josekit", "jsonwebtoken", "mime_guess", @@ -2199,6 +2198,7 @@ dependencies = [ "serde", "serde_json", "sienvy", + "simodels", "sqlx", "tempfile", "time", diff --git a/Cargo.toml b/Cargo.toml index b948787..a105e3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ josekit = { version = "0.10.3" } utoipa = { version = "5.5.0", features = ["axum_extras"] } utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] } icarus_meta = { git = "ssh://git@git.kundeng.us/phoenix/icarus_meta.git", tag = "v0.6.1" } -icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.11.3" } +simodels = { git = "ssh://git@git.kundeng.us/phoenix/simodels.git", tag = "v0.11.3-main-fe9d101bd0-111" } sienvy = { git = "ssh://git@git.kundeng.us/phoenix/sienvy.git", tag = "v0.8.0-main-d06c8fdf49-006" } [dev-dependencies] diff --git a/src/auth/mod.rs b/src/auth/mod.rs index 307e737..004603d 100644 --- a/src/auth/mod.rs +++ b/src/auth/mod.rs @@ -40,7 +40,7 @@ pub async fn auth( let mut validation = Validation::new(jsonwebtoken::Algorithm::HS256); validation.set_audience(&["icarus"]); // Must match exactly what's in the token - let _claims = decode::( + let _claims = decode::( &token, &DecodingKey::from_secret(secret_key.as_ref()), &validation, diff --git a/src/callers/coverart.rs b/src/callers/coverart.rs index 7522645..9a879b8 100644 --- a/src/callers/coverart.rs +++ b/src/callers/coverart.rs @@ -20,7 +20,7 @@ pub mod response { #[derive(Debug, Default, serde::Deserialize, serde::Serialize, utoipa::ToSchema)] pub struct Response { pub message: String, - pub data: Vec, + pub data: Vec, } } @@ -28,7 +28,7 @@ pub mod response { #[derive(Debug, Default, serde::Deserialize, serde::Serialize, utoipa::ToSchema)] pub struct Response { pub message: String, - pub data: Vec, + pub data: Vec, } } } @@ -74,15 +74,15 @@ pub mod endpoint { let coverart_type = if file_type.file_type == icarus_meta::detection::coverart::constants::JPEG_TYPE { - icarus_models::types::CoverArtType::JpegExtension + simodels::types::CoverArtType::JpegExtension } else if file_type.file_type == icarus_meta::detection::coverart::constants::JPG_TYPE { - icarus_models::types::CoverArtType::JpgExtension + simodels::types::CoverArtType::JpgExtension } else if file_type.file_type == icarus_meta::detection::coverart::constants::PNG_TYPE { - icarus_models::types::CoverArtType::PngExtension + simodels::types::CoverArtType::PngExtension } else { response.message = String::from("Invalid CoverArt type"); return ( @@ -91,13 +91,11 @@ pub mod endpoint { ); }; let filename = - icarus_models::coverart::generate_filename(coverart_type, true) - .unwrap(); + simodels::coverart::generate_filename(coverart_type, true).unwrap(); - let mut coverart = - icarus_models::coverart::init::init_coverart_dir_and_filename( - &directory, &filename, - ); + let mut coverart = simodels::coverart::init::init_coverart_dir_and_filename( + &directory, &filename, + ); coverart.title = song.album.clone(); coverart.file_type = file_type.file_type; coverart.data = data; @@ -200,7 +198,7 @@ pub mod endpoint { axum::extract::Path(id): axum::extract::Path, ) -> (axum::http::StatusCode, axum::response::Response) { match repo::coverart::get_coverart(&pool, &id).await { - Ok(coverart) => match icarus_models::coverart::io::to_data(&coverart) { + Ok(coverart) => match simodels::coverart::io::to_data(&coverart) { Ok(data) => { let (file_type, img_type) = match icarus_meta::detection::coverart::file_type_from_data(&data) { @@ -208,15 +206,15 @@ pub mod endpoint { if file_type.file_type == icarus_meta::detection::coverart::constants::JPEG_TYPE { - (file_type, icarus_models::types::CoverArtType::JpegExtension) + (file_type, simodels::types::CoverArtType::JpegExtension) } else if file_type.file_type == icarus_meta::detection::coverart::constants::JPG_TYPE { - (file_type, icarus_models::types::CoverArtType::JpgExtension) + (file_type, simodels::types::CoverArtType::JpgExtension) } else if file_type.file_type == icarus_meta::detection::coverart::constants::PNG_TYPE { - (file_type, icarus_models::types::CoverArtType::PngExtension) + (file_type, simodels::types::CoverArtType::PngExtension) } else { return ( axum::http::StatusCode::INTERNAL_SERVER_ERROR, @@ -235,8 +233,7 @@ pub mod endpoint { let bytes = axum::body::Bytes::from(data); let mut response = bytes.into_response(); let headers = response.headers_mut(); - let filename = - icarus_models::coverart::generate_filename(img_type, true).unwrap(); + let filename = simodels::coverart::generate_filename(img_type, true).unwrap(); headers.insert( axum::http::header::CONTENT_TYPE, file_type.mime.parse().unwrap(), diff --git a/src/callers/queue/coverart.rs b/src/callers/queue/coverart.rs index f333a94..01de867 100644 --- a/src/callers/queue/coverart.rs +++ b/src/callers/queue/coverart.rs @@ -331,23 +331,22 @@ pub mod endpoint { let coverart_type = if file_type.file_type == icarus_meta::detection::coverart::constants::JPEG_TYPE { - icarus_models::types::CoverArtType::JpegExtension + simodels::types::CoverArtType::JpegExtension } else if file_type.file_type == icarus_meta::detection::coverart::constants::JPG_TYPE { - icarus_models::types::CoverArtType::JpgExtension + simodels::types::CoverArtType::JpgExtension } else if file_type.file_type == icarus_meta::detection::coverart::constants::PNG_TYPE { - icarus_models::types::CoverArtType::PngExtension + simodels::types::CoverArtType::PngExtension } else { return ( axum::http::StatusCode::INTERNAL_SERVER_ERROR, axum::response::Response::default(), ); }; - let filename = - icarus_models::coverart::generate_filename(coverart_type, true).unwrap(); + let filename = simodels::coverart::generate_filename(coverart_type, true).unwrap(); headers.insert( axum::http::header::CONTENT_DISPOSITION, format!("attachment; filename=\"{filename}\"") diff --git a/src/callers/song.rs b/src/callers/song.rs index 935813d..1a2171c 100644 --- a/src/callers/song.rs +++ b/src/callers/song.rs @@ -36,8 +36,8 @@ pub mod request { || !self.song_queue_id.is_nil() } - pub fn to_song(&self) -> icarus_models::song::Song { - icarus_models::song::Song { + pub fn to_song(&self) -> simodels::song::Song { + simodels::song::Song { id: uuid::Uuid::nil(), title: self.title.clone(), artist: self.artist.clone(), @@ -71,7 +71,7 @@ pub mod response { #[derive(Debug, Default, serde::Deserialize, serde::Serialize, utoipa::ToSchema)] pub struct Response { pub message: String, - pub data: Vec, + pub data: Vec, } } @@ -79,15 +79,15 @@ pub mod response { #[derive(Debug, Default, serde::Deserialize, serde::Serialize, utoipa::ToSchema)] pub struct Response { pub message: String, - pub data: Vec, + pub data: Vec, } } pub mod delete_song { #[derive(Debug, Default, serde::Deserialize, serde::Serialize, utoipa::ToSchema)] pub struct SongAndCoverArt { - pub song: icarus_models::song::Song, - pub coverart: icarus_models::coverart::CoverArt, + pub song: simodels::song::Song, + pub coverart: simodels::coverart::CoverArt, } #[derive(Debug, Default, serde::Deserialize, serde::Serialize, utoipa::ToSchema)] @@ -134,11 +134,9 @@ pub mod endpoint { if payload.is_valid() { let mut song = payload.to_song(); - song.filename = icarus_models::song::generate_filename( - icarus_models::types::MusicType::FlacExtension, - true, - ) - .unwrap(); + song.filename = + simodels::song::generate_filename(simodels::types::MusicType::FlacExtension, true) + .unwrap(); song.directory = sienvy::environment::get_root_directory().value; match repo_queue::song::get_data(&pool, &payload.song_queue_id).await { @@ -340,7 +338,7 @@ pub mod endpoint { axum::extract::Path(id): axum::extract::Path, ) -> (axum::http::StatusCode, axum::response::Response) { match repo::song::get_song(&pool, &id).await { - Ok(song) => match icarus_models::song::io::to_data(&song) { + Ok(song) => match simodels::song::io::to_data(&song) { Ok(data) => { let bytes = axum::body::Bytes::from(data); let mut response = bytes.into_response(); diff --git a/src/main.rs b/src/main.rs index 13215d7..451f305 100644 --- a/src/main.rs +++ b/src/main.rs @@ -160,14 +160,14 @@ mod tests { let key: String = sienvy::environment::get_secret_main_key().value; let (message, issuer, audience) = token_fields(); - let token_resource = icarus_models::token::TokenResource { + let token_resource = simodels::token::TokenResource { message: message, issuer: issuer, audiences: vec![audience], id: TEST_USER_ID, }; - match icarus_models::token::create_token(&key, &token_resource, time::Duration::hours(1)) { + match simodels::token::create_token(&key, &token_resource, time::Duration::hours(1)) { Ok((access_token, _some_time)) => Ok(access_token), Err(err) => Err(err), } @@ -913,10 +913,10 @@ mod tests { let temp_file = tempfile::tempdir().expect("Could not create test directory"); let test_dir = String::from(temp_file.path().to_str().unwrap()); - let song = icarus_models::song::Song { + let song = simodels::song::Song { directory: test_dir, - filename: icarus_models::song::generate_filename( - icarus_models::types::MusicType::FlacExtension, + filename: simodels::song::generate_filename( + simodels::types::MusicType::FlacExtension, true, ) .unwrap(), @@ -2219,20 +2219,20 @@ mod tests { coverart_directory: &String, coverart_filename: &String, ) -> Result<(Vec, Vec), std::io::Error> { - let song = icarus_models::song::Song { + let song = simodels::song::Song { directory: song_directory.clone(), filename: song_filename.clone(), ..Default::default() }; - let coverart = icarus_models::coverart::CoverArt { + let coverart = simodels::coverart::CoverArt { directory: coverart_directory.clone(), filename: coverart_filename.clone(), ..Default::default() }; - match icarus_models::song::io::to_data(&song) { - Ok(song_data) => match icarus_models::coverart::io::to_data(&coverart) { + match simodels::song::io::to_data(&song) { + Ok(song_data) => match simodels::coverart::io::to_data(&coverart) { Ok(coverart_data) => Ok((song_data, coverart_data)), Err(err) => Err(err), }, @@ -2248,14 +2248,14 @@ mod tests { coverart_filename: &String, coverart_data: Vec, ) -> Result<(), std::io::Error> { - let song = icarus_models::song::Song { + let song = simodels::song::Song { directory: song_directory.clone(), filename: song_filename.clone(), data: song_data, ..Default::default() }; - let coverart = icarus_models::coverart::CoverArt { + let coverart = simodels::coverart::CoverArt { directory: coverart_directory.clone(), filename: coverart_filename.clone(), data: coverart_data, diff --git a/src/repo/coverart.rs b/src/repo/coverart.rs index bc6dfd7..09e7b6f 100644 --- a/src/repo/coverart.rs +++ b/src/repo/coverart.rs @@ -2,7 +2,7 @@ use sqlx::Row; pub async fn create( pool: &sqlx::PgPool, - coverart: &icarus_models::coverart::CoverArt, + coverart: &simodels::coverart::CoverArt, song_id: &uuid::Uuid, ) -> Result { let result = sqlx::query( @@ -36,7 +36,7 @@ pub async fn create( pub async fn get_coverart( pool: &sqlx::PgPool, id: &uuid::Uuid, -) -> Result { +) -> Result { let result = sqlx::query( r#" SELECT id, title, directory, filename, file_type, song_id FROM "coverart" WHERE id = $1; @@ -50,7 +50,7 @@ pub async fn get_coverart( }); match result { - Ok(row) => Ok(icarus_models::coverart::CoverArt { + Ok(row) => Ok(simodels::coverart::CoverArt { id: row .try_get("id") .map_err(|_e| sqlx::Error::RowNotFound) @@ -84,7 +84,7 @@ pub async fn get_coverart( pub async fn get_coverart_with_song_id( pool: &sqlx::PgPool, song_id: &uuid::Uuid, -) -> Result { +) -> Result { let result = sqlx::query( r#" SELECT id, title, directory, filename, file_type, song_id FROM "coverart" WHERE song_id = $1; @@ -98,7 +98,7 @@ pub async fn get_coverart_with_song_id( }); match result { - Ok(row) => Ok(icarus_models::coverart::CoverArt { + Ok(row) => Ok(simodels::coverart::CoverArt { id: row .try_get("id") .map_err(|_e| sqlx::Error::RowNotFound) @@ -132,7 +132,7 @@ pub async fn get_coverart_with_song_id( pub async fn delete_coverart( pool: &sqlx::PgPool, id: &uuid::Uuid, -) -> Result { +) -> Result { let result = sqlx::query( r#" DELETE FROM "coverart" @@ -148,7 +148,7 @@ pub async fn delete_coverart( }); match result { - Ok(row) => Ok(icarus_models::coverart::CoverArt { + Ok(row) => Ok(simodels::coverart::CoverArt { id: row .try_get("id") .map_err(|_e| sqlx::Error::RowNotFound) diff --git a/src/repo/song.rs b/src/repo/song.rs index 77d9561..fa70fd5 100644 --- a/src/repo/song.rs +++ b/src/repo/song.rs @@ -2,7 +2,7 @@ use sqlx::Row; pub async fn insert( pool: &sqlx::PgPool, - song: &icarus_models::song::Song, + song: &simodels::song::Song, ) -> Result<(time::OffsetDateTime, uuid::Uuid), sqlx::Error> { let result = sqlx::query( r#" @@ -52,7 +52,7 @@ pub async fn insert( pub async fn get_song( pool: &sqlx::PgPool, id: &uuid::Uuid, -) -> Result { +) -> Result { let result = sqlx::query( r#" SELECT * FROM "song" WHERE id = $1 @@ -72,7 +72,7 @@ pub async fn get_song( .map_err(|_e| sqlx::Error::RowNotFound) .unwrap(); - Ok(icarus_models::song::Song { + Ok(simodels::song::Song { id: row .try_get("id") .map_err(|_e| sqlx::Error::RowNotFound) @@ -145,9 +145,7 @@ pub async fn get_song( } } -pub async fn get_all_songs( - pool: &sqlx::PgPool, -) -> Result, sqlx::Error> { +pub async fn get_all_songs(pool: &sqlx::PgPool) -> Result, sqlx::Error> { let result = sqlx::query( r#" SELECT * FROM "song"; @@ -161,7 +159,7 @@ pub async fn get_all_songs( match result { Ok(rows) => { - let mut songs: Vec = Vec::new(); + let mut songs: Vec = Vec::new(); for row in rows { let date_created_time: time::OffsetDateTime = row @@ -169,7 +167,7 @@ pub async fn get_all_songs( .map_err(|_e| sqlx::Error::RowNotFound) .unwrap(); - let song = icarus_models::song::Song { + let song = simodels::song::Song { id: row .try_get("id") .map_err(|_e| sqlx::Error::RowNotFound) @@ -250,9 +248,9 @@ pub async fn get_all_songs( pub async fn delete_song( pool: &sqlx::PgPool, id: &uuid::Uuid, -) -> Result { +) -> Result { let result = sqlx::query( - // icarus_models::song::Song, + // simodels::song::Song, r#" DELETE FROM "song" WHERE id = $1 @@ -273,7 +271,7 @@ pub async fn delete_song( .map_err(|_e| sqlx::Error::RowNotFound) .unwrap(); - Ok(icarus_models::song::Song { + Ok(simodels::song::Song { id: row .try_get("id") .map_err(|_e| sqlx::Error::RowNotFound)