Song queue #258
@@ -162,7 +162,6 @@ pub mod endpoint {
|
|||||||
if valid {
|
if valid {
|
||||||
match repo::song::insert(
|
match repo::song::insert(
|
||||||
&pool,
|
&pool,
|
||||||
&raw_data,
|
|
||||||
&file_name,
|
&file_name,
|
||||||
&crate::repo::queue::song::status::PENDING.to_string(),
|
&crate::repo::queue::song::status::PENDING.to_string(),
|
||||||
)
|
)
|
||||||
@@ -172,41 +171,22 @@ pub mod endpoint {
|
|||||||
results.push(queued_song);
|
results.push(queued_song);
|
||||||
println!("Uploading to bucket");
|
println!("Uploading to bucket");
|
||||||
|
|
||||||
let s3_endpoint_url =
|
let lab_config = crate::util::maze::get_config();
|
||||||
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 lab_config = labyrinth::config::Config {
|
|
||||||
url: s3_endpoint_url.value,
|
|
||||||
bucket: bucket_name.value,
|
|
||||||
region: region.value,
|
|
||||||
access_key_id: access_key_id.value,
|
|
||||||
secret_key: secret_key.value,
|
|
||||||
};
|
|
||||||
|
|
||||||
println!("Labyrinth config: {lab_config:?}");
|
|
||||||
|
|
||||||
let lr = labyrinth::Labyrinth { config: lab_config };
|
let lr = labyrinth::Labyrinth { config: lab_config };
|
||||||
let data = labyrinth::Data {
|
let data = labyrinth::Data {
|
||||||
raw_data: copied_raw_data,
|
raw_data: copied_raw_data,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
let filename = simodels::song::generate_filename(
|
let filename = simodels::song::generate_filename(
|
||||||
simodels::types::MusicType::FlacExtension,
|
simodels::types::MusicType::FlacExtension,
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
println!("Filename: {filename:?}");
|
*/
|
||||||
let file_path = format!("queued/song/{filename}");
|
println!("Filename: {file_name:?}");
|
||||||
|
let file_path = format!("queued/song/{file_name}");
|
||||||
println!("Path: {file_path:?}");
|
println!("Path: {file_path:?}");
|
||||||
|
|
||||||
match lr.upload(&file_path, &data).await {
|
match lr.upload(&file_path, &data).await {
|
||||||
|
|||||||
@@ -24,16 +24,14 @@ pub mod dbtype {
|
|||||||
|
|
||||||
pub async fn insert(
|
pub async fn insert(
|
||||||
pool: &sqlx::PgPool,
|
pool: &sqlx::PgPool,
|
||||||
data: &Vec<u8>,
|
|
||||||
filename: &String,
|
filename: &String,
|
||||||
status: &String,
|
status: &String,
|
||||||
) -> Result<uuid::Uuid, sqlx::Error> {
|
) -> Result<uuid::Uuid, sqlx::Error> {
|
||||||
let result = sqlx::query(
|
let result = sqlx::query(
|
||||||
r#"
|
r#"
|
||||||
INSERT INTO "songQueue" (data, filename, status) VALUES($1, $2, $3) RETURNING id;
|
INSERT INTO "songQueue" (filename, status) VALUES($1, $2, $3) RETURNING id;
|
||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
.bind(data)
|
|
||||||
.bind(filename)
|
.bind(filename)
|
||||||
.bind(status)
|
.bind(status)
|
||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
|
||||||
|
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",
|
||||||
|
);
|
||||||
|
|
||||||
|
labyrinth::config::Config {
|
||||||
|
url: s3_endpoint_url.value,
|
||||||
|
bucket: bucket_name.value,
|
||||||
|
region: region.value,
|
||||||
|
access_key_id: access_key_id.value,
|
||||||
|
secret_key: secret_key.value,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user