diff --git a/src/admin_graphql.rs b/src/admin_graphql.rs index 3fbdcb7..e6b1792 100644 --- a/src/admin_graphql.rs +++ b/src/admin_graphql.rs @@ -64,10 +64,7 @@ async fn seaography_handler( } /// Jobs GraphQL POST handler for job management -async fn jobs_handler( - State(state): State>, - req: GraphQLRequest, -) -> GraphQLResponse { +async fn jobs_handler(State(state): State>, req: GraphQLRequest) -> GraphQLResponse { state.schema.execute(req.into_inner()).await.into() } diff --git a/src/jobs.rs b/src/jobs.rs index e5b2234..80a3c4c 100644 --- a/src/jobs.rs +++ b/src/jobs.rs @@ -2,7 +2,10 @@ use crate::entities; use crate::errors::CrabError; use crate::storage; use chrono::Utc; -use sea_orm::{ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, IntoActiveModel, QueryFilter, Set}; +use sea_orm::{ + ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, IntoActiveModel, QueryFilter, + Set, +}; use tokio_cron_scheduler::{Job, JobScheduler}; use tracing::{error, info}; @@ -27,21 +30,15 @@ pub async fn init_scheduler(db: DatabaseConnection) -> Result { info!("Cleaned up {} expired sessions", count); if let Some(id) = execution_id { - let _ = complete_job_execution(&db, id, true, None, Some(count as i64)) - .await; + let _ = + complete_job_execution(&db, id, true, None, Some(count as i64)).await; } } Err(e) => { error!("Failed to cleanup expired sessions: {}", e); if let Some(id) = execution_id { - let _ = complete_job_execution( - &db, - id, - false, - Some(e.to_string()), - None, - ) - .await; + let _ = + complete_job_execution(&db, id, false, Some(e.to_string()), None).await; } } } @@ -69,21 +66,15 @@ pub async fn init_scheduler(db: DatabaseConnection) -> Result { info!("Cleaned up {} expired refresh tokens", count); if let Some(id) = execution_id { - let _ = complete_job_execution(&db, id, true, None, Some(count as i64)) - .await; + let _ = + complete_job_execution(&db, id, true, None, Some(count as i64)).await; } } Err(e) => { error!("Failed to cleanup expired refresh tokens: {}", e); if let Some(id) = execution_id { - let _ = complete_job_execution( - &db, - id, - false, - Some(e.to_string()), - None, - ) - .await; + let _ = + complete_job_execution(&db, id, false, Some(e.to_string()), None).await; } } } @@ -176,7 +167,10 @@ pub async fn trigger_job_manually( match result { Ok(count) => { - info!("Manually triggered job {} completed: {} records", job_name, count); + info!( + "Manually triggered job {} completed: {} records", + job_name, count + ); complete_job_execution(db, execution_id, true, None, Some(count as i64)).await?; } Err(e) => { diff --git a/src/settings.rs b/src/settings.rs index 66c061e..2eb2afc 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -116,7 +116,8 @@ impl Settings { } // Environment overrides: BARYCENTER__SERVER__PORT=9090, etc. - builder = builder.add_source(config::Environment::with_prefix("BARYCENTER").separator("__")); + builder = + builder.add_source(config::Environment::with_prefix("BARYCENTER").separator("__")); let cfg = builder.build().into_diagnostic()?; let mut s: Settings = cfg.try_deserialize().into_diagnostic()?; diff --git a/src/storage.rs b/src/storage.rs index e15d40a..3c61312 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -423,11 +423,7 @@ pub async fn consume_auth_code( ) -> Result, CrabError> { use entities::auth_code::{Column, Entity}; - if let Some(model) = Entity::find() - .filter(Column::Code.eq(code)) - .one(db) - .await? - { + if let Some(model) = Entity::find().filter(Column::Code.eq(code)).one(db).await? { let now = Utc::now().timestamp(); if model.consumed != 0 || now > model.expires_at { return Ok(None); diff --git a/src/user_sync.rs b/src/user_sync.rs index ef341a3..f5d65e8 100644 --- a/src/user_sync.rs +++ b/src/user_sync.rs @@ -45,13 +45,7 @@ pub async fn sync_users_from_file(db: &DatabaseConnection, file_path: &str) -> R // Read and parse JSON file let content = fs::read_to_string(file_path) .into_diagnostic() - .map_err(|e| { - miette::miette!( - "Failed to read users file at '{}': {}", - file_path, - e - ) - })?; + .map_err(|e| miette::miette!("Failed to read users file at '{}': {}", file_path, e))?; let users_file: UsersFile = serde_json::from_str(&content) .into_diagnostic() @@ -165,7 +159,9 @@ async fn sync_user(db: &DatabaseConnection, user_def: &UserDefinition) -> Result let user = storage::get_user_by_username(db, &user_def.username) .await .into_diagnostic()? - .ok_or_else(|| miette::miette!("User not found after creation: {}", user_def.username))?; + .ok_or_else(|| { + miette::miette!("User not found after creation: {}", user_def.username) + })?; storage::set_property(db, &user.subject, key, value) .await diff --git a/src/web.rs b/src/web.rs index 71c6f90..4708581 100644 --- a/src/web.rs +++ b/src/web.rs @@ -105,7 +105,10 @@ pub async fn serve( .route("/.well-known/openid-configuration", get(discovery)) .route("/.well-known/jwks.json", get(jwks_handler)) .route("/connect/register", post(register_client)) - .route("/properties/{owner}/{key}", get(get_property).put(set_property)) + .route( + "/properties/{owner}/{key}", + get(get_property).put(set_property), + ) .route("/federation/trust-anchors", get(trust_anchors)) .route("/login", get(login_page).post(login_submit)) .route("/logout", get(logout)) @@ -149,7 +152,10 @@ pub async fn serve( .await .into_diagnostic()?; tracing::info!(%admin_addr, "Admin GraphQL API listening"); - tracing::info!("GraphQL Playground available at http://{}/admin/playground", admin_addr); + tracing::info!( + "GraphQL Playground available at http://{}/admin/playground", + admin_addr + ); tokio::spawn(async move { axum::serve(admin_listener, admin_router) @@ -1191,7 +1197,9 @@ async fn set_property( None => { return ( StatusCode::UNAUTHORIZED, - Json(json!({"error": "missing_token", "error_description": "Bearer token required"})), + Json( + json!({"error": "missing_token", "error_description": "Bearer token required"}), + ), ) .into_response(); }