Compare commits
2
Commits
884753b996
...
dca14d4ff0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dca14d4ff0
|
||
|
|
f341ee94e5
|
@@ -1,4 +1,4 @@
|
|||||||
name: Rust CI
|
name: soaricarus_api CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|||||||
Generated
+13
-13
@@ -1038,17 +1038,6 @@ dependencies = [
|
|||||||
"tower-service",
|
"tower-service",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "icarus_meta"
|
|
||||||
version = "0.6.1"
|
|
||||||
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_meta.git?tag=v0.6.1#946c46a23b387323c20720cd78bbac3c34595854"
|
|
||||||
dependencies = [
|
|
||||||
"imghdr",
|
|
||||||
"infer",
|
|
||||||
"lofty",
|
|
||||||
"rand 0.10.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icu_collections"
|
name = "icu_collections"
|
||||||
version = "2.2.0"
|
version = "2.2.0"
|
||||||
@@ -2141,6 +2130,17 @@ version = "0.3.9"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214"
|
checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "simeta"
|
||||||
|
version = "0.6.1"
|
||||||
|
source = "git+ssh://git@git.kundeng.us/phoenix/simeta.git?tag=v0.6.1-main-b690995806-680#b6909958064b1a3a4bffd6cbc0f6e12b95477e68"
|
||||||
|
dependencies = [
|
||||||
|
"imghdr",
|
||||||
|
"infer",
|
||||||
|
"lofty",
|
||||||
|
"rand 0.10.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "simodels"
|
name = "simodels"
|
||||||
version = "0.11.3"
|
version = "0.11.3"
|
||||||
@@ -2183,14 +2183,13 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "soaricarus"
|
name = "soaricarus_api"
|
||||||
version = "0.5.2"
|
version = "0.5.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"axum-extra",
|
"axum-extra",
|
||||||
"common-multipart-rfc7578",
|
"common-multipart-rfc7578",
|
||||||
"futures",
|
"futures",
|
||||||
"icarus_meta",
|
|
||||||
"josekit",
|
"josekit",
|
||||||
"jsonwebtoken",
|
"jsonwebtoken",
|
||||||
"mime_guess",
|
"mime_guess",
|
||||||
@@ -2198,6 +2197,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sienvy",
|
"sienvy",
|
||||||
|
"simeta",
|
||||||
"simodels",
|
"simodels",
|
||||||
"sqlx",
|
"sqlx",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "soaricarus"
|
name = "soaricarus_api"
|
||||||
version = "0.5.2"
|
version = "0.5.2"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.95"
|
rust-version = "1.95"
|
||||||
@@ -24,7 +24,7 @@ jsonwebtoken = { version = "10.3.0", features = ["rust_crypto"] }
|
|||||||
josekit = { version = "0.10.3" }
|
josekit = { version = "0.10.3" }
|
||||||
utoipa = { version = "5.5.0", features = ["axum_extras"] }
|
utoipa = { version = "5.5.0", features = ["axum_extras"] }
|
||||||
utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] }
|
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" }
|
simeta = { git = "ssh://git@git.kundeng.us/phoenix/simeta.git", tag = "v0.6.1-main-b690995806-680" }
|
||||||
simodels = { git = "ssh://git@git.kundeng.us/phoenix/simodels.git", tag = "v0.11.3-main-fe9d101bd0-111" }
|
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" }
|
sienvy = { git = "ssh://git@git.kundeng.us/phoenix/sienvy.git", tag = "v0.8.0-main-d06c8fdf49-006" }
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -6,7 +6,7 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
ssh: ["default"]
|
ssh: ["default"]
|
||||||
container_name: icarus
|
container_name: soaricarus
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
env_file:
|
env_file:
|
||||||
@@ -15,7 +15,7 @@ services:
|
|||||||
main_db:
|
main_db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
networks:
|
networks:
|
||||||
- icarus-network
|
- soaricarus-network
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
# --- Web API auth ---
|
# --- Web API auth ---
|
||||||
@@ -64,9 +64,9 @@ services:
|
|||||||
container_name: soaricarus_db
|
container_name: soaricarus_db
|
||||||
environment:
|
environment:
|
||||||
# These MUST match the user, password, and database name in the DATABASE_URL above
|
# These MUST match the user, password, and database name in the DATABASE_URL above
|
||||||
POSTGRES_USER: ${POSTGRES_MAIN_USER:-icarus}
|
POSTGRES_USER: ${POSTGRES_MAIN_USER:-soaricarus}
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_MAIN_PASSWORD:-password}
|
POSTGRES_PASSWORD: ${POSTGRES_MAIN_PASSWORD:-password}
|
||||||
POSTGRES_DB: ${POSTGRES_MAIN_DB:-icarus_db}
|
POSTGRES_DB: ${POSTGRES_MAIN_DB:-soaricarus_db}
|
||||||
volumes:
|
volumes:
|
||||||
# Persist database data using a named volume
|
# Persist database data using a named volume
|
||||||
- postgres_data:/var/lib/postgresql
|
- postgres_data:/var/lib/postgresql
|
||||||
@@ -83,7 +83,7 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- soaricarus-network
|
- soaricarus-network
|
||||||
|
|
||||||
# --- icarus web auth api db ---
|
# --- soaricarus web auth api db ---
|
||||||
auth_db:
|
auth_db:
|
||||||
image: postgres:18.4-alpine
|
image: postgres:18.4-alpine
|
||||||
container_name: soaricarus_auth_db
|
container_name: soaricarus_auth_db
|
||||||
|
|||||||
@@ -70,17 +70,17 @@ pub mod endpoint {
|
|||||||
Ok(song) => {
|
Ok(song) => {
|
||||||
let directory = sienvy::environment::get_root_directory().value;
|
let directory = sienvy::environment::get_root_directory().value;
|
||||||
let file_type =
|
let file_type =
|
||||||
icarus_meta::detection::coverart::file_type_from_data(&data).unwrap();
|
simeta::detection::coverart::file_type_from_data(&data).unwrap();
|
||||||
let coverart_type = if file_type.file_type
|
let coverart_type = if file_type.file_type
|
||||||
== icarus_meta::detection::coverart::constants::JPEG_TYPE
|
== simeta::detection::coverart::constants::JPEG_TYPE
|
||||||
{
|
{
|
||||||
simodels::types::CoverArtType::JpegExtension
|
simodels::types::CoverArtType::JpegExtension
|
||||||
} else if file_type.file_type
|
} else if file_type.file_type
|
||||||
== icarus_meta::detection::coverart::constants::JPG_TYPE
|
== simeta::detection::coverart::constants::JPG_TYPE
|
||||||
{
|
{
|
||||||
simodels::types::CoverArtType::JpgExtension
|
simodels::types::CoverArtType::JpgExtension
|
||||||
} else if file_type.file_type
|
} else if file_type.file_type
|
||||||
== icarus_meta::detection::coverart::constants::PNG_TYPE
|
== simeta::detection::coverart::constants::PNG_TYPE
|
||||||
{
|
{
|
||||||
simodels::types::CoverArtType::PngExtension
|
simodels::types::CoverArtType::PngExtension
|
||||||
} else {
|
} else {
|
||||||
@@ -201,18 +201,18 @@ pub mod endpoint {
|
|||||||
Ok(coverart) => match simodels::coverart::io::to_data(&coverart) {
|
Ok(coverart) => match simodels::coverart::io::to_data(&coverart) {
|
||||||
Ok(data) => {
|
Ok(data) => {
|
||||||
let (file_type, img_type) =
|
let (file_type, img_type) =
|
||||||
match icarus_meta::detection::coverart::file_type_from_data(&data) {
|
match simeta::detection::coverart::file_type_from_data(&data) {
|
||||||
Ok(file_type) => {
|
Ok(file_type) => {
|
||||||
if file_type.file_type
|
if file_type.file_type
|
||||||
== icarus_meta::detection::coverart::constants::JPEG_TYPE
|
== simeta::detection::coverart::constants::JPEG_TYPE
|
||||||
{
|
{
|
||||||
(file_type, simodels::types::CoverArtType::JpegExtension)
|
(file_type, simodels::types::CoverArtType::JpegExtension)
|
||||||
} else if file_type.file_type
|
} else if file_type.file_type
|
||||||
== icarus_meta::detection::coverart::constants::JPG_TYPE
|
== simeta::detection::coverart::constants::JPG_TYPE
|
||||||
{
|
{
|
||||||
(file_type, simodels::types::CoverArtType::JpgExtension)
|
(file_type, simodels::types::CoverArtType::JpgExtension)
|
||||||
} else if file_type.file_type
|
} else if file_type.file_type
|
||||||
== icarus_meta::detection::coverart::constants::PNG_TYPE
|
== simeta::detection::coverart::constants::PNG_TYPE
|
||||||
{
|
{
|
||||||
(file_type, simodels::types::CoverArtType::PngExtension)
|
(file_type, simodels::types::CoverArtType::PngExtension)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -102,9 +102,9 @@ pub mod response {
|
|||||||
mod helper {
|
mod helper {
|
||||||
pub fn is_coverart_file_type_valid(file_type: &String) -> bool {
|
pub fn is_coverart_file_type_valid(file_type: &String) -> bool {
|
||||||
let valid_file_types = vec![
|
let valid_file_types = vec![
|
||||||
String::from(icarus_meta::detection::coverart::constants::JPEG_TYPE),
|
String::from(simeta::detection::coverart::constants::JPEG_TYPE),
|
||||||
String::from(icarus_meta::detection::coverart::constants::JPG_TYPE),
|
String::from(simeta::detection::coverart::constants::JPG_TYPE),
|
||||||
String::from(icarus_meta::detection::coverart::constants::PNG_TYPE),
|
String::from(simeta::detection::coverart::constants::PNG_TYPE),
|
||||||
];
|
];
|
||||||
|
|
||||||
for valid_file_type in valid_file_types {
|
for valid_file_type in valid_file_types {
|
||||||
@@ -150,8 +150,7 @@ pub mod endpoint {
|
|||||||
let content_type = field.content_type().unwrap().to_string();
|
let content_type = field.content_type().unwrap().to_string();
|
||||||
let data = field.bytes().await.unwrap();
|
let data = field.bytes().await.unwrap();
|
||||||
let raw_data = data.to_vec();
|
let raw_data = data.to_vec();
|
||||||
let file_type =
|
let file_type = match simeta::detection::coverart::file_type_from_data(&raw_data) {
|
||||||
match icarus_meta::detection::coverart::file_type_from_data(&raw_data) {
|
|
||||||
Ok(file_type) => file_type,
|
Ok(file_type) => file_type,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Error: {err:?}");
|
eprintln!("Error: {err:?}");
|
||||||
@@ -318,8 +317,7 @@ pub mod endpoint {
|
|||||||
) -> (axum::http::StatusCode, axum::response::Response) {
|
) -> (axum::http::StatusCode, axum::response::Response) {
|
||||||
match repo::coverart::get_coverart_queue_data_with_id(&pool, &id).await {
|
match repo::coverart::get_coverart_queue_data_with_id(&pool, &id).await {
|
||||||
Ok(data) => {
|
Ok(data) => {
|
||||||
let file_type =
|
let file_type = simeta::detection::coverart::file_type_from_data(&data).unwrap();
|
||||||
icarus_meta::detection::coverart::file_type_from_data(&data).unwrap();
|
|
||||||
let bytes = axum::body::Bytes::from(data);
|
let bytes = axum::body::Bytes::from(data);
|
||||||
let mut response = bytes.into_response();
|
let mut response = bytes.into_response();
|
||||||
let headers = response.headers_mut();
|
let headers = response.headers_mut();
|
||||||
@@ -329,16 +327,12 @@ pub mod endpoint {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let coverart_type = if file_type.file_type
|
let coverart_type = if file_type.file_type
|
||||||
== icarus_meta::detection::coverart::constants::JPEG_TYPE
|
== simeta::detection::coverart::constants::JPEG_TYPE
|
||||||
{
|
{
|
||||||
simodels::types::CoverArtType::JpegExtension
|
simodels::types::CoverArtType::JpegExtension
|
||||||
} else if file_type.file_type
|
} else if file_type.file_type == simeta::detection::coverart::constants::JPG_TYPE {
|
||||||
== icarus_meta::detection::coverart::constants::JPG_TYPE
|
|
||||||
{
|
|
||||||
simodels::types::CoverArtType::JpgExtension
|
simodels::types::CoverArtType::JpgExtension
|
||||||
} else if file_type.file_type
|
} else if file_type.file_type == simeta::detection::coverart::constants::PNG_TYPE {
|
||||||
== icarus_meta::detection::coverart::constants::PNG_TYPE
|
|
||||||
{
|
|
||||||
simodels::types::CoverArtType::PngExtension
|
simodels::types::CoverArtType::PngExtension
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -97,9 +97,9 @@ pub mod response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn is_song_valid(data: &[u8]) -> Result<bool, std::io::Error> {
|
pub async fn is_song_valid(data: &[u8]) -> Result<bool, std::io::Error> {
|
||||||
match icarus_meta::detection::song::file_type_from_data(data) {
|
match simeta::detection::song::file_type_from_data(data) {
|
||||||
Ok(file_type) => {
|
Ok(file_type) => {
|
||||||
if file_type.file_type == icarus_meta::detection::song::constants::FLAC_TYPE {
|
if file_type.file_type == simeta::detection::song::constants::FLAC_TYPE {
|
||||||
Ok(true)
|
Ok(true)
|
||||||
} else {
|
} else {
|
||||||
Ok(false)
|
Ok(false)
|
||||||
|
|||||||
+4
-4
@@ -149,8 +149,8 @@ mod tests {
|
|||||||
pub fn token_fields() -> (String, String, String) {
|
pub fn token_fields() -> (String, String, String) {
|
||||||
(
|
(
|
||||||
String::from("What a twist!"),
|
String::from("What a twist!"),
|
||||||
String::from("icarus_test"),
|
String::from("soaricarus_test"),
|
||||||
String::from("icarus"),
|
String::from("soaricarus"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,7 +289,7 @@ mod tests {
|
|||||||
.uri(uri)
|
.uri(uri)
|
||||||
.header(
|
.header(
|
||||||
axum::http::header::CONTENT_TYPE,
|
axum::http::header::CONTENT_TYPE,
|
||||||
icarus_meta::detection::song::constants::mime::FLAC,
|
simeta::detection::song::constants::mime::FLAC,
|
||||||
)
|
)
|
||||||
.header(
|
.header(
|
||||||
axum::http::header::AUTHORIZATION,
|
axum::http::header::AUTHORIZATION,
|
||||||
@@ -306,7 +306,7 @@ mod tests {
|
|||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||||
let mut form = MultipartForm::default();
|
let mut form = MultipartForm::default();
|
||||||
let _ = form.add_file(
|
let _ = form.add_file(
|
||||||
icarus_meta::detection::coverart::constants::JPEG_TYPE,
|
simeta::detection::coverart::constants::JPEG_TYPE,
|
||||||
"tests/I/Coverart-1.jpg",
|
"tests/I/Coverart-1.jpg",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user