diff --git a/src/callers/queue/song.rs b/src/callers/queue/song.rs index 11ee342..85a1fd8 100644 --- a/src/callers/queue/song.rs +++ b/src/callers/queue/song.rs @@ -162,7 +162,6 @@ pub mod endpoint { if valid { match repo::song::insert( &pool, - &raw_data, &file_name, &crate::repo::queue::song::status::PENDING.to_string(), ) @@ -172,41 +171,22 @@ pub mod endpoint { results.push(queued_song); println!("Uploading to bucket"); - 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 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 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() }; + /* let filename = simodels::song::generate_filename( simodels::types::MusicType::FlacExtension, true, ) .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:?}"); match lr.upload(&file_path, &data).await { diff --git a/src/repo/queue/song.rs b/src/repo/queue/song.rs index 4b1577e..e3b9740 100644 --- a/src/repo/queue/song.rs +++ b/src/repo/queue/song.rs @@ -24,16 +24,14 @@ pub mod dbtype { pub async fn insert( pool: &sqlx::PgPool, - data: &Vec, filename: &String, status: &String, ) -> Result { let result = sqlx::query( 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(status) .fetch_one(pool) diff --git a/src/util/mod.rs b/src/util/mod.rs index e69de29..f87ee44 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -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, + } + } +}