mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew.git
synced 2025-05-13 11:37:33 -05:00
cargo clippy
This commit is contained in:
parent
b21deaee5f
commit
2a4d927a41
11 changed files with 30 additions and 36 deletions
|
@ -1,4 +1,4 @@
|
||||||
FROM docker.io/library/debian:latest as builder
|
FROM docker.io/library/debian:latest AS builder
|
||||||
|
|
||||||
# First - build
|
# First - build
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ pub fn get_args() -> Args {
|
||||||
pub fn get_data_path(file_name: &str) -> String {
|
pub fn get_data_path(file_name: &str) -> String {
|
||||||
let args = get_args();
|
let args = get_args();
|
||||||
let mut path = args.path;
|
let mut path = args.path;
|
||||||
while path.ends_with("/") {
|
while path.ends_with('/') {
|
||||||
path.pop();
|
path.pop();
|
||||||
}
|
}
|
||||||
fs::create_dir_all(&path).unwrap();
|
fs::create_dir_all(&path).unwrap();
|
||||||
|
@ -209,5 +209,5 @@ async fn set_running(running: bool) {
|
||||||
|
|
||||||
async fn get_running() -> bool {
|
async fn get_running() -> bool {
|
||||||
let result = lock_onto_mutex!(RUNNING);
|
let result = lock_onto_mutex!(RUNNING);
|
||||||
return *result;
|
*result
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ fn not_found(headers: &HeaderMap) -> HttpResponse {
|
||||||
"server_time": global::timestamp(),
|
"server_time": global::timestamp(),
|
||||||
"message": ""
|
"message": ""
|
||||||
};
|
};
|
||||||
return global::send(rv, 0, &headers)
|
global::send(rv, 0, headers)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn api_req(req: HttpRequest, body: String) -> HttpResponse {
|
async fn api_req(req: HttpRequest, body: String) -> HttpResponse {
|
||||||
|
@ -171,11 +171,11 @@ pub async fn request(req: HttpRequest, body: String) -> HttpResponse {
|
||||||
let args = crate::get_args();
|
let args = crate::get_args();
|
||||||
let headers = req.headers();
|
let headers = req.headers();
|
||||||
if args.hidden && req.path().starts_with("/api/webui/") {
|
if args.hidden && req.path().starts_with("/api/webui/") {
|
||||||
return not_found(&headers);
|
return not_found(headers);
|
||||||
}
|
}
|
||||||
if headers.get("aoharu-asset-version").is_none() && req.path().starts_with("/api") && !req.path().starts_with("/api/webui") {
|
if headers.get("aoharu-asset-version").is_none() && req.path().starts_with("/api") && !req.path().starts_with("/api/webui") {
|
||||||
if args.hidden {
|
if args.hidden {
|
||||||
return not_found(&headers);
|
return not_found(headers);
|
||||||
} else {
|
} else {
|
||||||
return webui::main(req);
|
return webui::main(req);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,7 @@ fn do_reinforce(user: &mut JsonValue, body: &JsonValue, exp_id: &str, money_mult
|
||||||
data["amount"] = (data["amount"].as_i64().unwrap() - money).into();
|
data["amount"] = (data["amount"].as_i64().unwrap() - money).into();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if evolve {
|
if evolve && !databases::CHARACTER_CHATS[card["master_card_id"].to_string()]["50"].is_empty() {
|
||||||
if !databases::CHARACTER_CHATS[card["master_card_id"].to_string()]["50"].is_empty() {
|
|
||||||
let chat = &databases::CHARACTER_CHATS[card["master_card_id"].to_string()]["50"];
|
let chat = &databases::CHARACTER_CHATS[card["master_card_id"].to_string()]["50"];
|
||||||
let mission_id = databases::MISSION_REWARD[chat[0].to_string()]["value"].as_i64().unwrap();
|
let mission_id = databases::MISSION_REWARD[chat[0].to_string()]["value"].as_i64().unwrap();
|
||||||
|
|
||||||
|
@ -47,7 +46,6 @@ fn do_reinforce(user: &mut JsonValue, body: &JsonValue, exp_id: &str, money_mult
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,7 @@ async fn get_clearrate_json() -> JsonValue {
|
||||||
let new = get_json();
|
let new = get_json();
|
||||||
result.replace(new.clone());
|
result.replace(new.clone());
|
||||||
}
|
}
|
||||||
return rv;
|
rv
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn clearrate(_req: HttpRequest) -> Option<JsonValue> {
|
pub async fn clearrate(_req: HttpRequest) -> Option<JsonValue> {
|
||||||
|
|
|
@ -60,7 +60,7 @@ fn get_random_song() -> JsonValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn switch_music(event: &mut JsonValue, index: i32) {
|
fn switch_music(event: &mut JsonValue, index: i32) {
|
||||||
if index > 5 || index < 1 {
|
if !(1..=5).contains(&index) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,5 +109,5 @@ pub async fn get_scores_json() -> JsonValue {
|
||||||
let new = get_json();
|
let new = get_json();
|
||||||
result.replace(new.clone());
|
result.replace(new.clone());
|
||||||
}
|
}
|
||||||
return rv;
|
rv
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,27 +27,23 @@ pub fn get_asset_hash(asset_version: String, android: bool) -> String {
|
||||||
} else {
|
} else {
|
||||||
ASSET_HASH_ANDROID_JP.to_string()
|
ASSET_HASH_ANDROID_JP.to_string()
|
||||||
}
|
}
|
||||||
} else {
|
} else if args.jp_ios_asset_hash != String::new() {
|
||||||
if args.jp_ios_asset_hash != String::new() {
|
|
||||||
args.jp_ios_asset_hash
|
args.jp_ios_asset_hash
|
||||||
} else {
|
} else {
|
||||||
ASSET_HASH_IOS_JP.to_string()
|
ASSET_HASH_IOS_JP.to_string()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else if android {
|
} else if android {
|
||||||
if args.en_android_asset_hash != String::new() {
|
if args.en_android_asset_hash != String::new() {
|
||||||
args.en_android_asset_hash
|
args.en_android_asset_hash
|
||||||
} else {
|
} else {
|
||||||
ASSET_HASH_ANDROID.to_string()
|
ASSET_HASH_ANDROID.to_string()
|
||||||
}
|
}
|
||||||
} else {
|
} else if args.en_ios_asset_hash != String::new() {
|
||||||
if args.en_ios_asset_hash != String::new() {
|
|
||||||
args.en_ios_asset_hash
|
args.en_ios_asset_hash
|
||||||
} else {
|
} else {
|
||||||
ASSET_HASH_IOS.to_string()
|
ASSET_HASH_IOS.to_string()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pub fn create_token() -> String {
|
pub fn create_token() -> String {
|
||||||
format!("{}", Uuid::now_v7())
|
format!("{}", Uuid::now_v7())
|
||||||
|
|
|
@ -356,7 +356,7 @@ pub fn migration_password_register(req: HttpRequest, body: String) -> HttpRespon
|
||||||
|
|
||||||
pub fn get_protocol() -> String {
|
pub fn get_protocol() -> String {
|
||||||
let args = crate::get_args();
|
let args = crate::get_args();
|
||||||
if args.https == true {
|
if args.https {
|
||||||
return String::from("https");
|
return String::from("https");
|
||||||
}
|
}
|
||||||
String::from("http")
|
String::from("http")
|
||||||
|
|
|
@ -325,7 +325,7 @@ async fn npps4_req(sha_id: String) -> Option<JsonValue> {
|
||||||
let args = crate::get_args();
|
let args = crate::get_args();
|
||||||
|
|
||||||
let mut host = args.npps4;
|
let mut host = args.npps4;
|
||||||
while host.ends_with("/") {
|
while host.ends_with('/') {
|
||||||
host.pop();
|
host.pop();
|
||||||
}
|
}
|
||||||
let url = format!("{}/ewexport?sha1={}", host, sha_id);
|
let url = format!("{}/ewexport?sha1={}", host, sha_id);
|
||||||
|
@ -334,7 +334,7 @@ async fn npps4_req(sha_id: String) -> Option<JsonValue> {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let response = client.get(url);
|
let response = client.get(url);
|
||||||
let response_body = response.send().await.ok()?.text().await.ok()?;
|
let response_body = response.send().await.ok()?.text().await.ok()?;
|
||||||
Some(json::parse(&response_body).ok()?)
|
json::parse(&response_body).ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clean_sif_data(current: &JsonValue) -> JsonValue {
|
fn clean_sif_data(current: &JsonValue) -> JsonValue {
|
||||||
|
|
10
src/sql.rs
10
src/sql.rs
|
@ -41,12 +41,12 @@ impl SQLite {
|
||||||
pub fn lock_and_select(&self, command: &str, args: &[&dyn ToSql]) -> Result<String, rusqlite::Error> {
|
pub fn lock_and_select(&self, command: &str, args: &[&dyn ToSql]) -> Result<String, rusqlite::Error> {
|
||||||
let conn = lock_onto_mutex!(self.engine);
|
let conn = lock_onto_mutex!(self.engine);
|
||||||
let mut stmt = conn.prepare(command)?;
|
let mut stmt = conn.prepare(command)?;
|
||||||
return stmt.query_row(args, |row| {
|
stmt.query_row(args, |row| {
|
||||||
match row.get::<usize, i64>(0) {
|
match row.get::<usize, i64>(0) {
|
||||||
Ok(val) => Ok(val.to_string()),
|
Ok(val) => Ok(val.to_string()),
|
||||||
Err(_) => row.get(0)
|
Err(_) => row.get(0)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
pub fn lock_and_select_all(&self, command: &str, args: &[&dyn ToSql]) -> Result<JsonValue, rusqlite::Error> {
|
pub fn lock_and_select_all(&self, command: &str, args: &[&dyn ToSql]) -> Result<JsonValue, rusqlite::Error> {
|
||||||
let conn = lock_onto_mutex!(self.engine);
|
let conn = lock_onto_mutex!(self.engine);
|
||||||
|
@ -65,12 +65,12 @@ impl SQLite {
|
||||||
Err(_) => rv.push(res).unwrap()
|
Err(_) => rv.push(res).unwrap()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return Ok(rv);
|
Ok(rv)
|
||||||
}
|
}
|
||||||
pub fn get_live_data(&self, id: i64) -> Result<Live, rusqlite::Error> {
|
pub fn get_live_data(&self, id: i64) -> Result<Live, rusqlite::Error> {
|
||||||
let conn = lock_onto_mutex!(self.engine);
|
let conn = lock_onto_mutex!(self.engine);
|
||||||
let mut stmt = conn.prepare("SELECT * FROM lives WHERE live_id=?1")?;
|
let mut stmt = conn.prepare("SELECT * FROM lives WHERE live_id=?1")?;
|
||||||
return stmt.query_row(params!(id), |row| {
|
stmt.query_row(params!(id), |row| {
|
||||||
Ok(Live {
|
Ok(Live {
|
||||||
live_id: row.get(0)?,
|
live_id: row.get(0)?,
|
||||||
normal_failed: row.get(1)?,
|
normal_failed: row.get(1)?,
|
||||||
|
@ -82,7 +82,7 @@ impl SQLite {
|
||||||
master_failed: row.get(7)?,
|
master_failed: row.get(7)?,
|
||||||
master_pass: row.get(8)?,
|
master_pass: row.get(8)?,
|
||||||
})
|
})
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
pub fn create_store_v2(&self, table: &str) {
|
pub fn create_store_v2(&self, table: &str) {
|
||||||
self.lock_and_exec(table, params!());
|
self.lock_and_exec(table, params!());
|
||||||
|
|
Loading…
Add table
Reference in a new issue