Compare commits

...

4 Commits

Author SHA1 Message Date
b8bbd66fd3 tsk-41: Service now works
Some checks failed
Rust Build / Check (pull_request) Successful in 33s
Rust Build / Rustfmt (pull_request) Failing after 33s
Rust Build / Test Suite (pull_request) Successful in 36s
Rust Build / Clippy (pull_request) Successful in 1m12s
Rust Build / build (pull_request) Successful in 46s
2025-08-14 18:57:28 -04:00
aa93e6cc4a tsk-41: Added auth header to the appropriate request calls 2025-08-14 18:48:33 -04:00
7e9392ef1f tsk-41: Updated env files 2025-08-14 18:23:56 -04:00
88ae596ae1 tsk-41: icarus_envy version bump 2025-08-14 18:20:28 -04:00
9 changed files with 28 additions and 15 deletions

View File

@@ -1,4 +1,5 @@
ROOT_DIRECTORY=/home/songparser/mydata
ICARUS_BASE_API_URL=http://localhost:3000
ICARUS_AUTH_BASE_API_URL=http://localhost:3001
SECRET_KEY=iUOo1fxshf3y1tUGn1yU8l9raPApHCdinW0VdCHdRFEjqhR3Bf02aZzsKbLtaDFH
SERVICE_PASSPHRASE=iUOo1fxshf3y1tUGn1yU8l9raPApHCdinW0VdCHdRFEjqhR3Bf02aZzsKbLtaDFH

View File

@@ -1,4 +1,5 @@
ROOT_DIRECTORY=/home/songparser/mydata
ICARUS_BASE_API_URL=http://localhost:3000
ICARUS_AUTH_BASE_API_URL=http://localhost:3001
SECRET_KEY=iUOo1fxshf3y1tUGn1yU8l9raPApHCdinW0VdCHdRFEjqhR3Bf02aZzsKbLtaDFH
SERVICE_PASSPHRASE=iUOo1fxshf3y1tUGn1yU8l9raPApHCdinW0VdCHdRFEjqhR3Bf02aZzsKbLtaDFH

4
Cargo.lock generated
View File

@@ -516,8 +516,8 @@ dependencies = [
[[package]]
name = "icarus_envy"
version = "0.3.1"
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_envy.git?tag=v0.3.1-main-3cd42dab6b-006#3cd42dab6b2503609883f5f57ad3508755c34a2e"
version = "0.3.2"
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_envy.git?tag=v0.3.2-18-d498f60046-006#d498f600468c7e5fcf03a640f8c5b9476765fe96"
dependencies = [
"const_format",
"dotenvy",

View File

@@ -15,4 +15,4 @@ uuid = { version = "1.17.0", features = ["v4", "serde"] }
rand = { version = "0.9.1" }
icarus_meta = { git = "ssh://git@git.kundeng.us/phoenix/icarus_meta.git", tag = "v0.3.0" }
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.5.5-devel-bd793db08e-111" }
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.3.1-main-3cd42dab6b-006" }
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.3.2-18-d498f60046-006" }

View File

@@ -3,7 +3,7 @@ pub async fn fetch_next_queue_item(app: &crate::config::App) -> Result<reqwest::
let fetch_endpoint = String::from("api/v2/song/queue/next");
let api_url = format!("{}/{fetch_endpoint}", app.uri);
let (key, header) = auth_header(app).await;
println!("Header: {header:?}");
client.get(api_url).header(key, header)
.send().await
}
@@ -43,7 +43,8 @@ pub mod fetch_song_queue_data {
let client = reqwest::Client::new();
let endpoint = String::from("api/v2/song/queue");
let api_url = format!("{}/{endpoint}/{id}", app.uri);
client.get(api_url).send().await
let (key, header) = super::auth_header(app).await;
client.get(api_url).header(key, header).send().await
}
}
@@ -56,9 +57,11 @@ pub mod get_metadata_queue {
let client = reqwest::Client::new();
let endpoint = String::from("api/v2/song/metadata/queue");
let api_url = format!("{}/{endpoint}", app.uri);
let (key, header) = super::auth_header(app).await;
client
.get(api_url)
.query(&[("song_queue_id", song_queue_id)])
.header(key, header)
.send()
.await
}
@@ -108,9 +111,11 @@ pub mod get_coverart_queue {
let client = reqwest::Client::new();
let endpoint = String::from("api/v2/coverart/queue");
let api_url = format!("{}/{endpoint}", app.uri);
let (key, header) = super::auth_header(app).await;
client
.get(api_url)
.query(&[("song_queue_id", song_queue_id)])
.header(key, header)
.send()
.await
}
@@ -123,7 +128,8 @@ pub mod get_coverart_queue {
let client = reqwest::Client::new();
let endpoint = String::from("api/v2/coverart/queue/data");
let api_url = format!("{}/{endpoint}/{coverart_queue_id}", app.uri);
client.get(api_url).send().await
let (key, header) = super::auth_header(app).await;
client.get(api_url).header(key, header).send().await
}
pub mod response {

View File

@@ -1,5 +1,6 @@
#[derive(Default, Debug)]
pub struct App {
pub uri: String,
pub auth_uri: String,
pub token: icarus_models::login_result::LoginResult
}

View File

@@ -15,6 +15,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// let app_base_url = icarus_envy::environment::get_icarus_base_api_url().await;
let mut app = config::App {
uri: icarus_envy::environment::get_icarus_base_api_url().await,
auth_uri: icarus_envy::environment::get_icarus_auth_base_api_url().await,
// token: auth::get_token(&app).await,
..Default::default()
};
@@ -59,8 +60,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
if !empty {
println!("Queue is not empty");
println!("SongQueueItem: {song_queue_item:?}");
// TODO: For now, focus on making sure the token is valid before you get here
continue;
let song_queue_id = song_queue_item.data[0].id;
let user_id = song_queue_item.data[0].user_id;
@@ -118,7 +117,7 @@ mod auth {
pub async fn get_token(app: &crate::config::App) -> Result<icarus_models::login_result::LoginResult, std::io::Error> {
let client = reqwest::Client::new();
let endpoint = String::from("api/v2/service/login");
let api_url = format!("{}/{endpoint}", app.uri);
let api_url = format!("{}/{endpoint}", app.auth_uri);
let payload = serde_json::json!({
"passphrase": icarus_envy::environment::get_service_passphrase().await,
@@ -155,7 +154,7 @@ mod auth {
pub async fn get_refresh_token(app: &crate::config::App, login_result: &icarus_models::login_result::LoginResult) -> Result<icarus_models::login_result::LoginResult, std::io::Error> {
let client = reqwest::Client::new();
let endpoint = String::from("api/v2/token/refresh");
let api_url = format!("{}/{endpoint}", app.uri);
let api_url = format!("{}/{endpoint}", app.auth_uri);
let payload = serde_json::json!({
"access_token": login_result.token

View File

@@ -30,8 +30,9 @@ pub mod create_song {
let client = reqwest::Client::builder().build()?;
let url = format!("{}/api/v2/song", app.uri);
let (key, header) = crate::api::auth_header(app).await;
let request = client.post(url).json(&payload);
let request = client.post(url).json(&payload).header(key, header);
request.send().await
}
@@ -55,7 +56,8 @@ pub mod create_coverart {
let client = reqwest::Client::builder().build()?;
let url = format!("{}/api/v2/coverart", app.uri);
let payload = get_payload(song_id, coverart_queue_id);
let request = client.post(url).json(&payload);
let (key, header) = crate::api::auth_header(app).await;
let request = client.post(url).json(&payload).header(key, header);
request.send().await
}
@@ -88,7 +90,8 @@ pub mod wipe_data {
let payload = serde_json::json!({
"song_queue_id": song_queue_id
});
let request = client.patch(url).json(&payload);
let (key, header) = crate::api::auth_header(app).await;
let request = client.patch(url).json(&payload).header(key, header);
request.send().await
}
@@ -112,7 +115,8 @@ pub mod wipe_data {
let payload = serde_json::json!({
"coverart_queue_id": coverart_queue_id
});
let request = client.patch(url).json(&payload);
let (key, header) = crate::api::auth_header(app).await;
let request = client.patch(url).json(&payload).header(key, header);
request.send().await
}

View File

@@ -18,7 +18,8 @@ pub async fn update_queued_song(
let url = format!("{}/api/v2/song/queue/{song_queue_id}", app.uri);
println!("Url: {url:?}");
let request = client.patch(url).multipart(form);
let (key, header) = crate::api::auth_header(app).await;
let request = client.patch(url).multipart(form).header(key, header);
let response = request.send().await?;