Song queue #258
@@ -352,11 +352,22 @@ pub mod endpoint {
|
||||
)]
|
||||
pub async fn download_queued_song(
|
||||
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) {
|
||||
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) => {
|
||||
let by = axum::body::Bytes::from(data);
|
||||
let mut response = by.into_response();
|
||||
@@ -374,6 +385,14 @@ pub mod endpoint {
|
||||
|
||||
(axum::http::StatusCode::OK, response)
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
axum::response::Response::default(),
|
||||
)
|
||||
}
|
||||
},
|
||||
Err(_err) => (
|
||||
axum::http::StatusCode::BAD_REQUEST,
|
||||
axum::response::Response::default(),
|
||||
|
||||
+15
-7
@@ -974,8 +974,9 @@ mod tests {
|
||||
}
|
||||
let songpath = song.song_path().unwrap();
|
||||
|
||||
let raw_uri =
|
||||
String::from(soaricarus_api::callers::queue::endpoints::QUEUESONGUPDATE);
|
||||
let raw_uri = String::from(
|
||||
soaricarus_api::callers::queue::endpoints::QUEUESONGUPDATE,
|
||||
);
|
||||
let end_index = raw_uri.len() - 5;
|
||||
|
||||
let uri = format!(
|
||||
@@ -1992,7 +1993,10 @@ mod tests {
|
||||
|
||||
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
|
||||
.clone()
|
||||
@@ -2126,8 +2130,10 @@ mod tests {
|
||||
|
||||
let (id, _, _, _) = test_data::song_id().await.unwrap();
|
||||
|
||||
let uri =
|
||||
super::util::format_url_with_value(soaricarus_api::callers::endpoints::DOWNLOADSONG, &id)
|
||||
let uri = super::util::format_url_with_value(
|
||||
soaricarus_api::callers::endpoints::DOWNLOADSONG,
|
||||
&id,
|
||||
)
|
||||
.await;
|
||||
|
||||
match app
|
||||
@@ -2303,8 +2309,10 @@ mod tests {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let uri =
|
||||
super::util::format_url_with_value(soaricarus_api::callers::endpoints::DELETESONG, &id)
|
||||
let uri = super::util::format_url_with_value(
|
||||
soaricarus_api::callers::endpoints::DELETESONG,
|
||||
&id,
|
||||
)
|
||||
.await;
|
||||
|
||||
match app
|
||||
|
||||
+5
-15
@@ -1,20 +1,10 @@
|
||||
|
||||
|
||||
pub mod maze {
|
||||
pub fn get_config() -> labyrinth::config::Config {
|
||||
|
||||
let s3_endpoint_url =
|
||||
sienvy::environment::get_env("S3_ENDPOINT_URL");
|
||||
let bucket_name =
|
||||
sienvy::environment::get_env("S3_BUCKET_NAME");
|
||||
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",
|
||||
);
|
||||
let s3_endpoint_url = sienvy::environment::get_env("S3_ENDPOINT_URL");
|
||||
let bucket_name = sienvy::environment::get_env("S3_BUCKET_NAME");
|
||||
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 {
|
||||
url: s3_endpoint_url.value,
|
||||
|
||||
Reference in New Issue
Block a user