diff --git a/src/main.rs b/src/main.rs index 51e8abb..e973a6d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -225,8 +225,6 @@ async fn main() { Url::new("v3-L", concat!(api_base_3!(), "/openapi.json")), ]; - let is_alive: Arc = Arc::new(AtomicBool::new(true)); - loop { let db_auth_tokens = config.auth.clone(); let pool = PgPool::connect(dotenv!("DATABASE_URL")).await.unwrap(); @@ -256,7 +254,7 @@ async fn main() { abort() }); - let server = HttpServer::new(move || { + let _ = HttpServer::new(move || { App::new() .app_data(web::Data::new(AppState { db: pool.clone(), auth_tokens: db_auth_tokens.clone() })) .wrap(Logger::default()) diff --git a/src/v1/mod.rs b/src/v1/mod.rs index ad7c47a..cddfbba 100644 --- a/src/v1/mod.rs +++ b/src/v1/mod.rs @@ -1,5 +1,4 @@ use crate::{db, AppState}; -use actix_web::web::Json; use actix_web::{delete, get, post, put, web, HttpRequest, HttpResponse, Responder}; use std::collections::HashMap; use std::ops::Deref; @@ -9,7 +8,7 @@ use sqlx::QueryBuilder; pub(crate) mod schemas; -fn get_auth_header<'a>(req: &'a HttpRequest) -> Option<&'a str> { +fn get_auth_header(req: &HttpRequest) -> Option<&str> { req.headers().get("x-api-key")?.to_str().ok() } @@ -90,18 +89,18 @@ async fn get_user( Err(_) => return HttpResponse::InternalServerError().finish(), }; - let mut permissions: HashMap = HashMap::new(); + let mut user_permissions: HashMap = HashMap::new(); - permissions.insert("game_permissions".to_string(), user.game_permissions); - permissions.insert("empire_permissions".to_string(), user.empire_permissions); - permissions.insert("data_permissions".to_string(), user.data_permissions); - permissions.insert("user_permissions".to_string(), user.user_permissions); + user_permissions.insert("game_permissions".to_string(), user.game_permissions); + user_permissions.insert("empire_permissions".to_string(), user.empire_permissions); + user_permissions.insert("data_permissions".to_string(), user.data_permissions); + user_permissions.insert("user_permissions".to_string(), user.user_permissions); let return_data = schemas::User { user_token: user.token, discord_handle: user.discord_id, profile_picture: user.picture_url, - permissions: permissions + permissions: user_permissions }; return HttpResponse::Ok().json(return_data); @@ -290,17 +289,17 @@ pub(crate) async fn update_user( }; } - let mut permissions: HashMap = HashMap::new(); - permissions.insert("game_permissions".to_string(), user.game_permissions); - permissions.insert("empire_permissions".to_string(), user.empire_permissions); - permissions.insert("data_permissions".to_string(), user.data_permissions); - permissions.insert("user_permissions".to_string(), user.user_permissions); + let mut user_permissions: HashMap = HashMap::new(); + user_permissions.insert("game_permissions".to_string(), user.game_permissions); + user_permissions.insert("empire_permissions".to_string(), user.empire_permissions); + user_permissions.insert("data_permissions".to_string(), user.data_permissions); + user_permissions.insert("user_permissions".to_string(), user.user_permissions); let return_data = schemas::User { user_token: user.token, discord_handle: user.discord_id, profile_picture: user.picture_url, - permissions: permissions + permissions: user_permissions }; return HttpResponse::Ok().json(return_data); } else { @@ -348,7 +347,7 @@ pub(crate) async fn delete_user( .await { Ok(_) => {} - Err(e) => { + Err(_) => { return HttpResponse::InternalServerError().finish(); } }; diff --git a/src/v1/schemas.rs b/src/v1/schemas.rs index e561cce..d6d9d65 100644 --- a/src/v1/schemas.rs +++ b/src/v1/schemas.rs @@ -1,7 +1,6 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; -use utoipa::{IntoParams, ToSchema}; -use crate::v3::schemas::ChellarisGameLegacy; +use utoipa::{ToSchema}; // DB Permission Enums diff --git a/src/v3/mod.rs b/src/v3/mod.rs index 9d904a3..f1c414c 100644 --- a/src/v3/mod.rs +++ b/src/v3/mod.rs @@ -31,7 +31,7 @@ fn verify_auth(token: Option<&str>, data: &AppState) -> schemas::AuthReturn { return auth_return; } -fn get_auth_header<'a>(req: &'a HttpRequest) -> Option<&'a str> { +fn get_auth_header(req: &HttpRequest) -> Option<&str> { req.headers().get("x-api-key")?.to_str().ok() } diff --git a/src/v3/schemas.rs b/src/v3/schemas.rs index 847bccc..709a7b2 100644 --- a/src/v3/schemas.rs +++ b/src/v3/schemas.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, hash::Hash}; +use std::{collections::HashMap}; use serde::{Serialize, Deserialize}; use utoipa::{ToSchema, IntoParams};