Song queue #258

Merged
phoenix merged 14 commits from song_queue into main 2026-08-13 15:27:32 -04:00
3 changed files with 67 additions and 50 deletions
Showing only changes of commit c8d13d5097 - Show all commits
+22 -3
View File
@@ -352,11 +352,22 @@ pub mod endpoint {
)] )]
pub async fn download_queued_song( pub async fn download_queued_song(
axum::Extension(pool): axum::Extension<sqlx::PgPool>, axum::Extension(pool): axum::Extension<sqlx::PgPool>,
axum::extract::Path(id): axum::extract::Path<uuid::Uuid>, axum::extract::Path(song_queue_id): axum::extract::Path<uuid::Uuid>,
) -> (axum::http::StatusCode, axum::response::Response) { ) -> (axum::http::StatusCode, axum::response::Response) {
println!("Id: {id}"); println!("Id: {song_queue_id}");
match repo::song::get_data(&pool, &id).await { let lab_config = crate::util::maze::get_config();
let lr = labyrinth::Labyrinth { config: lab_config };
/*
let data = labyrinth::Data {
raw_data: copied_raw_data,
..Default::default()
};
*/
match repo::data::get_with_song_queue_id(&pool, &song_queue_id).await {
Ok((id, file_key, _bucket, _region, _)) => match lr.download(&file_key).await {
Ok(data) => { Ok(data) => {
let by = axum::body::Bytes::from(data); let by = axum::body::Bytes::from(data);
let mut response = by.into_response(); let mut response = by.into_response();
@@ -374,6 +385,14 @@ pub mod endpoint {
(axum::http::StatusCode::OK, response) (axum::http::StatusCode::OK, response)
} }
Err(err) => {
eprintln!("Error: {err:?}");
(
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
axum::response::Response::default(),
)
}
},
Err(_err) => ( Err(_err) => (
axum::http::StatusCode::BAD_REQUEST, axum::http::StatusCode::BAD_REQUEST,
axum::response::Response::default(), axum::response::Response::default(),
+15 -7
View File
@@ -974,8 +974,9 @@ mod tests {
} }
let songpath = song.song_path().unwrap(); let songpath = song.song_path().unwrap();
let raw_uri = let raw_uri = String::from(
String::from(soaricarus_api::callers::queue::endpoints::QUEUESONGUPDATE); soaricarus_api::callers::queue::endpoints::QUEUESONGUPDATE,
);
let end_index = raw_uri.len() - 5; let end_index = raw_uri.len() - 5;
let uri = format!( let uri = format!(
@@ -1992,7 +1993,10 @@ mod tests {
let id = test_data::coverart_id().await.unwrap(); let id = test_data::coverart_id().await.unwrap();
let uri = format!("{}?id={id}", soaricarus_api::callers::endpoints::GETCOVERART); let uri = format!(
"{}?id={id}",
soaricarus_api::callers::endpoints::GETCOVERART
);
match app match app
.clone() .clone()
@@ -2126,8 +2130,10 @@ mod tests {
let (id, _, _, _) = test_data::song_id().await.unwrap(); let (id, _, _, _) = test_data::song_id().await.unwrap();
let uri = let uri = super::util::format_url_with_value(
super::util::format_url_with_value(soaricarus_api::callers::endpoints::DOWNLOADSONG, &id) soaricarus_api::callers::endpoints::DOWNLOADSONG,
&id,
)
.await; .await;
match app match app
@@ -2303,8 +2309,10 @@ mod tests {
.await .await
.unwrap(); .unwrap();
let uri = let uri = super::util::format_url_with_value(
super::util::format_url_with_value(soaricarus_api::callers::endpoints::DELETESONG, &id) soaricarus_api::callers::endpoints::DELETESONG,
&id,
)
.await; .await;
match app match app
+5 -15
View File
@@ -1,20 +1,10 @@
pub mod maze { pub mod maze {
pub fn get_config() -> labyrinth::config::Config { pub fn get_config() -> labyrinth::config::Config {
let s3_endpoint_url = sienvy::environment::get_env("S3_ENDPOINT_URL");
let s3_endpoint_url = let bucket_name = sienvy::environment::get_env("S3_BUCKET_NAME");
sienvy::environment::get_env("S3_ENDPOINT_URL"); let region = sienvy::environment::get_env("GARAGE_S3_REGION");
let bucket_name = let access_key_id = sienvy::environment::get_env("GARAGE_DEFAULT_ACCESS_KEY");
sienvy::environment::get_env("S3_BUCKET_NAME"); let secret_key = sienvy::environment::get_env("GARAGE_DEFAULT_SECRET_KEY");
let region =
sienvy::environment::get_env("GARAGE_S3_REGION");
let access_key_id = sienvy::environment::get_env(
"GARAGE_DEFAULT_ACCESS_KEY",
);
let secret_key = sienvy::environment::get_env(
"GARAGE_DEFAULT_SECRET_KEY",
);
labyrinth::config::Config { labyrinth::config::Config {
url: s3_endpoint_url.value, url: s3_endpoint_url.value,