Various linting changes
All checks were successful
Run Tests on Code / run-tests (push) Successful in 0s

This commit is contained in:
Neshura 2023-12-12 20:49:39 +01:00
parent 75eefab02c
commit 12938d1ee4
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C
5 changed files with 18 additions and 22 deletions

View file

@ -225,8 +225,6 @@ async fn main() {
Url::new("v3-L", concat!(api_base_3!(), "/openapi.json")),
];
let is_alive: Arc<AtomicBool> = 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())

View file

@ -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<String, bool> = HashMap::new();
let mut user_permissions: HashMap<String, bool> = 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<String, bool> = 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<String, bool> = 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();
}
};

View file

@ -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

View file

@ -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()
}

View file

@ -1,4 +1,4 @@
use std::{collections::HashMap, hash::Hash};
use std::{collections::HashMap};
use serde::{Serialize, Deserialize};
use utoipa::{ToSchema, IntoParams};