tsk-211: Fix SQL error when checking queue (#217)
* tsk-211: Fixing error on getting queue item * tsk-211: Some cleanup * tsk-211: Cleanup * tsk-211: Updated readme * tsk-211: Version bump
This commit was merged in pull request #217.
This commit is contained in:
Generated
+1
-1
@@ -834,7 +834,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icarus"
|
name = "icarus"
|
||||||
version = "0.3.3"
|
version = "0.3.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"axum-extra",
|
"axum-extra",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "icarus"
|
name = "icarus"
|
||||||
version = "0.3.3"
|
version = "0.3.4"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.90"
|
rust-version = "1.90"
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ Web API for the Icarus project.
|
|||||||
|
|
||||||
|
|
||||||
### Requires
|
### Requires
|
||||||
`icarus_auth` v0.6.1
|
`icarus_auth` +v0.6.5
|
||||||
`songparser` v0.4.2
|
`songparser` +v0.4.8
|
||||||
|
|
||||||
### Compatible with
|
### Compatible with
|
||||||
`icarus-dm` v0.8.2
|
`icarus-dm` v0.8.4
|
||||||
|
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|||||||
+2
-10
@@ -67,8 +67,6 @@ pub async fn auth<B>(
|
|||||||
req: Request<axum::body::Body>,
|
req: Request<axum::body::Body>,
|
||||||
next: Next,
|
next: Next,
|
||||||
) -> Result<impl IntoResponse, (StatusCode, Json<ErrorResponse>)> {
|
) -> Result<impl IntoResponse, (StatusCode, Json<ErrorResponse>)> {
|
||||||
println!("Cookie: {cookie_jar:?}");
|
|
||||||
|
|
||||||
let token = cookie_jar
|
let token = cookie_jar
|
||||||
.get("token")
|
.get("token")
|
||||||
.map(|cookie| cookie.value().to_string())
|
.map(|cookie| cookie.value().to_string())
|
||||||
@@ -76,10 +74,7 @@ pub async fn auth<B>(
|
|||||||
req.headers()
|
req.headers()
|
||||||
.get(axum::http::header::AUTHORIZATION)
|
.get(axum::http::header::AUTHORIZATION)
|
||||||
.and_then(|auth_header| auth_header.to_str().ok())
|
.and_then(|auth_header| auth_header.to_str().ok())
|
||||||
.and_then(|auth_value| {
|
.and_then(|auth_value| auth_value.strip_prefix("Bearer ").map(String::from))
|
||||||
println!("Auth value: {auth_value:?}");
|
|
||||||
auth_value.strip_prefix("Bearer ").map(String::from)
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let token = token.ok_or_else(|| {
|
let token = token.ok_or_else(|| {
|
||||||
@@ -94,9 +89,8 @@ pub async fn auth<B>(
|
|||||||
|
|
||||||
let mut validation = Validation::new(jsonwebtoken::Algorithm::HS256);
|
let mut validation = Validation::new(jsonwebtoken::Algorithm::HS256);
|
||||||
validation.set_audience(&["icarus"]); // Must match exactly what's in the token
|
validation.set_audience(&["icarus"]); // Must match exactly what's in the token
|
||||||
let claims = decode::<UserClaims>(
|
let _claims = decode::<UserClaims>(
|
||||||
&token,
|
&token,
|
||||||
// TODO: Replace with code to get secret from env
|
|
||||||
&DecodingKey::from_secret(secret_key.as_ref()),
|
&DecodingKey::from_secret(secret_key.as_ref()),
|
||||||
&validation,
|
&validation,
|
||||||
)
|
)
|
||||||
@@ -110,7 +104,5 @@ pub async fn auth<B>(
|
|||||||
})?
|
})?
|
||||||
.claims;
|
.claims;
|
||||||
|
|
||||||
println!("Claims: {claims:?}");
|
|
||||||
|
|
||||||
Ok(next.run(req).await)
|
Ok(next.run(req).await)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,10 +97,7 @@ pub async fn get_most_recent_and_update(pool: &sqlx::PgPool) -> Result<SongQueue
|
|||||||
.bind(status::PROCESSING)
|
.bind(status::PROCESSING)
|
||||||
.bind(status::READY)
|
.bind(status::READY)
|
||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await;
|
||||||
.map_err(|e| {
|
|
||||||
eprintln!("Error inserting: {e}");
|
|
||||||
});
|
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(row) => {
|
Ok(row) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user