Various linting changes
All checks were successful
Run Tests on Code / run-tests (push) Successful in 0s
All checks were successful
Run Tests on Code / run-tests (push) Successful in 0s
This commit is contained in:
parent
75eefab02c
commit
12938d1ee4
5 changed files with 18 additions and 22 deletions
|
@ -225,8 +225,6 @@ async fn main() {
|
||||||
Url::new("v3-L", concat!(api_base_3!(), "/openapi.json")),
|
Url::new("v3-L", concat!(api_base_3!(), "/openapi.json")),
|
||||||
];
|
];
|
||||||
|
|
||||||
let is_alive: Arc<AtomicBool> = Arc::new(AtomicBool::new(true));
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let db_auth_tokens = config.auth.clone();
|
let db_auth_tokens = config.auth.clone();
|
||||||
let pool = PgPool::connect(dotenv!("DATABASE_URL")).await.unwrap();
|
let pool = PgPool::connect(dotenv!("DATABASE_URL")).await.unwrap();
|
||||||
|
@ -256,7 +254,7 @@ async fn main() {
|
||||||
abort()
|
abort()
|
||||||
});
|
});
|
||||||
|
|
||||||
let server = HttpServer::new(move || {
|
let _ = HttpServer::new(move || {
|
||||||
App::new()
|
App::new()
|
||||||
.app_data(web::Data::new(AppState { db: pool.clone(), auth_tokens: db_auth_tokens.clone() }))
|
.app_data(web::Data::new(AppState { db: pool.clone(), auth_tokens: db_auth_tokens.clone() }))
|
||||||
.wrap(Logger::default())
|
.wrap(Logger::default())
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::{db, AppState};
|
use crate::{db, AppState};
|
||||||
use actix_web::web::Json;
|
|
||||||
use actix_web::{delete, get, post, put, web, HttpRequest, HttpResponse, Responder};
|
use actix_web::{delete, get, post, put, web, HttpRequest, HttpResponse, Responder};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
@ -9,7 +8,7 @@ use sqlx::QueryBuilder;
|
||||||
|
|
||||||
pub(crate) mod schemas;
|
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()
|
req.headers().get("x-api-key")?.to_str().ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,18 +89,18 @@ async fn get_user(
|
||||||
Err(_) => return HttpResponse::InternalServerError().finish(),
|
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);
|
user_permissions.insert("game_permissions".to_string(), user.game_permissions);
|
||||||
permissions.insert("empire_permissions".to_string(), user.empire_permissions);
|
user_permissions.insert("empire_permissions".to_string(), user.empire_permissions);
|
||||||
permissions.insert("data_permissions".to_string(), user.data_permissions);
|
user_permissions.insert("data_permissions".to_string(), user.data_permissions);
|
||||||
permissions.insert("user_permissions".to_string(), user.user_permissions);
|
user_permissions.insert("user_permissions".to_string(), user.user_permissions);
|
||||||
|
|
||||||
let return_data = schemas::User {
|
let return_data = schemas::User {
|
||||||
user_token: user.token,
|
user_token: user.token,
|
||||||
discord_handle: user.discord_id,
|
discord_handle: user.discord_id,
|
||||||
profile_picture: user.picture_url,
|
profile_picture: user.picture_url,
|
||||||
permissions: permissions
|
permissions: user_permissions
|
||||||
};
|
};
|
||||||
|
|
||||||
return HttpResponse::Ok().json(return_data);
|
return HttpResponse::Ok().json(return_data);
|
||||||
|
@ -290,17 +289,17 @@ pub(crate) async fn update_user(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
user_permissions.insert("game_permissions".to_string(), user.game_permissions);
|
||||||
permissions.insert("empire_permissions".to_string(), user.empire_permissions);
|
user_permissions.insert("empire_permissions".to_string(), user.empire_permissions);
|
||||||
permissions.insert("data_permissions".to_string(), user.data_permissions);
|
user_permissions.insert("data_permissions".to_string(), user.data_permissions);
|
||||||
permissions.insert("user_permissions".to_string(), user.user_permissions);
|
user_permissions.insert("user_permissions".to_string(), user.user_permissions);
|
||||||
|
|
||||||
let return_data = schemas::User {
|
let return_data = schemas::User {
|
||||||
user_token: user.token,
|
user_token: user.token,
|
||||||
discord_handle: user.discord_id,
|
discord_handle: user.discord_id,
|
||||||
profile_picture: user.picture_url,
|
profile_picture: user.picture_url,
|
||||||
permissions: permissions
|
permissions: user_permissions
|
||||||
};
|
};
|
||||||
return HttpResponse::Ok().json(return_data);
|
return HttpResponse::Ok().json(return_data);
|
||||||
} else {
|
} else {
|
||||||
|
@ -348,7 +347,7 @@ pub(crate) async fn delete_user(
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(e) => {
|
Err(_) => {
|
||||||
return HttpResponse::InternalServerError().finish();
|
return HttpResponse::InternalServerError().finish();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use utoipa::{IntoParams, ToSchema};
|
use utoipa::{ToSchema};
|
||||||
use crate::v3::schemas::ChellarisGameLegacy;
|
|
||||||
|
|
||||||
// DB Permission Enums
|
// DB Permission Enums
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ fn verify_auth(token: Option<&str>, data: &AppState) -> schemas::AuthReturn {
|
||||||
return auth_return;
|
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()
|
req.headers().get("x-api-key")?.to_str().ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{collections::HashMap, hash::Hash};
|
use std::{collections::HashMap};
|
||||||
|
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
use utoipa::{ToSchema, IntoParams};
|
use utoipa::{ToSchema, IntoParams};
|
||||||
|
|
Reference in a new issue