Cleanup imports

This commit is contained in:
Ethan O'Brien 2024-05-04 14:59:33 -05:00
parent 1cec98a01e
commit 8f5f32a17e
26 changed files with 89 additions and 343 deletions

View file

@ -1,6 +1,7 @@
mod encryption;
mod router;
mod sql;
use json::object;
use actix_web::{
App,

View file

@ -1,8 +1,9 @@
use json::{object, array, JsonValue};
use actix_web::{HttpResponse, HttpRequest};
use crate::router::userdata;
use crate::router::global;
use crate::encryption;
use actix_web::{HttpResponse, HttpRequest};
use crate::router::userdata;
fn do_reinforce(user: &mut JsonValue, body: &JsonValue, exp_id: &str, money_multiplier: i64, evolve: bool) -> JsonValue {
for (i, data) in user["card_list"].members().enumerate() {

View file

@ -1,9 +1,8 @@
use json;
use json::object;
use crate::router::global;
//use crate::encryption;
use actix_web::{HttpResponse, HttpRequest};
use crate::router::userdata;
use crate::router::global;
pub fn home(req: HttpRequest, body: String) -> HttpResponse {
let key = global::get_login(req.headers(), &body);

View file

@ -1,12 +1,13 @@
use json::{object, array, JsonValue};
use crate::router::global;
use actix_web::{HttpResponse, HttpRequest};
use rusqlite::params;
use std::sync::Mutex;
use lazy_static::lazy_static;
use std::thread;
use lazy_static::lazy_static;
use crate::encryption;
use crate::sql::SQLite;
use crate::router::global;
lazy_static! {
static ref DATABASE: SQLite = SQLite::new("live_statistics.db", setup_tables);

View file

@ -1,8 +1,8 @@
use json;
use json::{object};
use json::object;
use actix_web::{HttpResponse, HttpRequest};
use crate::router::global;
use crate::encryption;
use actix_web::{HttpResponse, HttpRequest};
pub fn error(_req: HttpRequest, body: String) -> HttpResponse {
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();

View file

@ -1,8 +1,7 @@
use json;
use json::object;
use crate::router::global;
use actix_web::{HttpResponse, HttpRequest};
//use crate::router::userdata;
use crate::router::global;
pub fn event(_req: HttpRequest, _body: String) -> HttpResponse {

View file

@ -1,10 +1,11 @@
use crate::encryption;
use json::{JsonValue, object};
use crate::router::global;
use crate::router::userdata;
use actix_web::{HttpResponse, HttpRequest};
use lazy_static::lazy_static;
use crate::router::global;
use crate::router::userdata;
use crate::encryption;
lazy_static! {
static ref EXCHANGE_LIST: JsonValue = {
let mut info = object!{};

View file

@ -1,8 +1,9 @@
use json::{object, array};
use crate::router::global;
use actix_web::{HttpResponse, HttpRequest};
use crate::router::userdata;
use crate::encryption;
use crate::router::global;
pub fn friend(req: HttpRequest, body: String) -> HttpResponse {
let key = global::get_login(req.headers(), &body);

View file

@ -1,17 +1,18 @@
use json::{object, JsonValue, array};
use crate::encryption;
use actix_web::{
HttpResponse,
http::header::{HeaderValue, HeaderMap}
};
use crate::router::gree;
use std::time::{SystemTime, UNIX_EPOCH};
use base64::{Engine as _, engine::general_purpose};
use crate::router::userdata;
use lazy_static::lazy_static;
use rand::Rng;
use uuid::Uuid;
use crate::encryption;
use crate::router::userdata;
use crate::router::gree;
pub const ASSET_VERSION: &str = "cb87bc1468c8631a262ff65b2960470b";
pub const ASSET_HASH_ANDROID: &str = "4715e873031ae4abc3c625e2bd8c935b";
pub const ASSET_HASH_IOS: &str = "466d4616d14a8d8a842de06426e084c2";

View file

@ -1,5 +1,4 @@
use crate::router::global;
use actix_web::{HttpResponse, HttpRequest, http::header::HeaderValue, http::header::ContentType, http::header::HeaderMap};
use actix_web::{HttpResponse, HttpRequest, http::header::{HeaderValue, ContentType, HeaderMap}};
use base64::{Engine as _, engine::general_purpose};
use std::collections::HashMap;
use std::env;
@ -7,11 +6,6 @@ use sha1::Sha1;
use substring::Substring;
use json::{object, JsonValue};
use hmac::{Hmac, Mac};
use crate::router::userdata;
use crate::encryption;
use crate::router::user::{code_to_uid, uid_to_code};
use crate::sql::SQLite;
use rusqlite::params;
use lazy_static::lazy_static;
@ -20,6 +14,12 @@ use openssl::rsa::Rsa;
use openssl::hash::MessageDigest;
use openssl::sign::Verifier;
use crate::router::global;
use crate::router::userdata;
use crate::encryption;
use crate::router::user::{code_to_uid, uid_to_code};
use crate::sql::SQLite;
lazy_static! {
static ref DATABASE: SQLite = SQLite::new("gree.db", setup_tables);
}

View file

@ -1,8 +1,9 @@
use json::{object, array, JsonValue};
use actix_web::{HttpResponse, HttpRequest};
use crate::router::userdata;
use crate::router::global;
use crate::encryption;
use actix_web::{HttpResponse, HttpRequest};
use crate::router::userdata;
pub fn preset(req: HttpRequest, body: String) -> HttpResponse {
let key = global::get_login(req.headers(), &body);

View file

@ -1,11 +1,12 @@
use json::{object, array, JsonValue};
use actix_web::{HttpResponse, HttpRequest};
use rand::Rng;
use lazy_static::lazy_static;
use crate::router::global;
use crate::encryption;
use actix_web::{HttpResponse, HttpRequest};
use crate::router::userdata;
use rand::Rng;
use crate::router::clear_rate::live_completed;
use lazy_static::lazy_static;
use crate::router::userdata;
pub fn retire(_req: HttpRequest, body: String) -> HttpResponse {
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();

View file

@ -1,14 +1,11 @@
use json;
use json::{object, array, JsonValue};
use crate::router::global;
//use crate::encryption;
use actix_web::{HttpResponse, HttpRequest};
use crate::router::userdata;
use lazy_static::lazy_static;
//First time login handler
use crate::router::global;
use crate::router::userdata;
pub fn dummy(req: HttpRequest, body: String) -> HttpResponse {
//let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
let key = global::get_login(req.headers(), &body);
let user = userdata::get_acc(&key);
@ -54,7 +51,6 @@ pub fn get_login_bonus_info(id: i64) -> JsonValue {
}
pub fn bonus(req: HttpRequest, body: String) -> HttpResponse {
//let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
let key = global::get_login(req.headers(), &body);
let user = userdata::get_acc(&key);
let mut user_home = userdata::get_acc_home(&key);
@ -92,7 +88,6 @@ pub fn bonus(req: HttpRequest, body: String) -> HttpResponse {
} else {
to_send = array![];
}
// println!("{}", json::stringify(to_send.clone()));
userdata::save_acc_home(&key, user_home);

View file

@ -1,12 +1,12 @@
use json;
use json::{array, object, JsonValue};
use crate::router::global;
use crate::encryption;
use actix_web::{HttpResponse, HttpRequest};
use crate::router::userdata;
use lazy_static::lazy_static;
use rand::Rng;
use crate::router::global;
use crate::encryption;
use crate::router::userdata;
lazy_static! {
static ref CARDS: JsonValue = {
let mut cardz = object!{};

View file

@ -1,8 +1,7 @@
use json;
use json::object;
use crate::router::global;
use actix_web::{HttpResponse, HttpRequest};
use crate::router::userdata;
use crate::router::{global, userdata};
use crate::encryption;
pub fn mission(req: HttpRequest) -> HttpResponse {

View file

@ -1,8 +1,8 @@
use json;
use json::object;
use crate::router::global;
use actix_web::{HttpResponse, HttpRequest};
use crate::router::global;
//todo
pub fn reward(_req: HttpRequest) -> HttpResponse {

View file

@ -1,10 +1,9 @@
use json;
use json::object;
use crate::router::global;
use actix_web::{HttpResponse, HttpRequest};
use crate::router::global;
pub fn purchase(_req: HttpRequest) -> HttpResponse {
let resp = object!{
"code": 0,
"server_time": global::timestamp(),
@ -38,240 +37,3 @@ pub fn purchase(_req: HttpRequest) -> HttpResponse {
};
global::send(resp)
}
/*
resp.data = {
"product_list": [
{
"product_id": "com.bushiroad.global.lovelive.sif2.google.promo.4199",
"name": "6000 Love Gems",
"description": "6000 Paid Love Gems",
"thumbnail_url": null,
"charge_gem": 6000,
"free_gem": 0,
"campaign_type": 2,
"campaign_mode": 5,
"priority": 1,
"price": "34.99",
"currency_code": "USD",
"formatted_price": "USD$34.99",
"consumable": 0,
"limited_count": 2,
"product_type": 0,
"amenity_label": null,
"ticket_valid_days": null,
"ticket_issuing_gem": null,
"start_datetime": "2024-02-01 00:00:00",
"end_datetime": "2024-02-29 23:59:59",
"total_gem": 6000
},
{
"product_id": "com.bushiroad.global.lovelive.sif2.google.promo.8499",
"name": "13000 Love Gems",
"description": "13000 Paid Love Gems",
"thumbnail_url": null,
"charge_gem": 13000,
"free_gem": 0,
"campaign_type": 2,
"campaign_mode": 5,
"priority": 2,
"price": "69.99",
"currency_code": "USD",
"formatted_price": "USD$69.99",
"consumable": 0,
"limited_count": 2,
"product_type": 0,
"amenity_label": null,
"ticket_valid_days": null,
"ticket_issuing_gem": null,
"start_datetime": "2024-02-01 00:00:00",
"end_datetime": "2024-02-29 23:59:59",
"total_gem": 13000
},
{
"product_id": "com.bushiroad.global.lovelive.sif2.google.gem.299",
"name": "140 Love Gems",
"description": "140 Paid Love Gems",
"thumbnail_url": null,
"charge_gem": 140,
"free_gem": 0,
"campaign_type": 0,
"campaign_mode": 0,
"priority": 11,
"price": "0.99",
"currency_code": "USD",
"formatted_price": "USD$0.99",
"consumable": 1,
"limited_count": 0,
"product_type": 0,
"amenity_label": null,
"ticket_valid_days": null,
"ticket_issuing_gem": null,
"start_datetime": null,
"end_datetime": null,
"total_gem": 140
},
{
"product_id": "com.bushiroad.global.lovelive.sif2.google.gem.499",
"name": "430 Love Gems",
"description": "420 Paid Love Gems + 10 Free LoveGems",
"thumbnail_url": null,
"charge_gem": 420,
"free_gem": 10,
"campaign_type": 0,
"campaign_mode": 0,
"priority": 12,
"price": "2.99",
"currency_code": "USD",
"formatted_price": "USD$2.99",
"consumable": 1,
"limited_count": 0,
"product_type": 0,
"amenity_label": null,
"ticket_valid_days": null,
"ticket_issuing_gem": null,
"start_datetime": null,
"end_datetime": null,
"total_gem": 430
},
{
"product_id": "com.bushiroad.global.lovelive.sif2.google.gem.899",
"name": "910 Love Gems",
"description": "870 Paid Love Gems + 40 Free LoveGems",
"thumbnail_url": null,
"charge_gem": 870,
"free_gem": 40,
"campaign_type": 0,
"campaign_mode": 0,
"priority": 13,
"price": "6.99",
"currency_code": "USD",
"formatted_price": "USD$6.99",
"consumable": 1,
"limited_count": 0,
"product_type": 0,
"amenity_label": null,
"ticket_valid_days": null,
"ticket_issuing_gem": null,
"start_datetime": null,
"end_datetime": null,
"total_gem": 910
},
{
"product_id": "com.bushiroad.global.lovelive.sif2.google.gem.1299",
"name": "1380 Love Gems",
"description": "1310 Paid Love Gems + 70 Free LoveGems",
"thumbnail_url": null,
"charge_gem": 1310,
"free_gem": 70,
"campaign_type": 0,
"campaign_mode": 0,
"priority": 14,
"price": "9.99",
"currency_code": "USD",
"formatted_price": "USD$9.99",
"consumable": 1,
"limited_count": 0,
"product_type": 0,
"amenity_label": null,
"ticket_valid_days": null,
"ticket_issuing_gem": null,
"start_datetime": null,
"end_datetime": null,
"total_gem": 1380
},
{
"product_id": "com.bushiroad.global.lovelive.sif2.google.gem.2499",
"name": "2700 Love Gems",
"description": "2530 Paid Love Gems + 170 Free LoveGems",
"thumbnail_url": null,
"charge_gem": 2530,
"free_gem": 170,
"campaign_type": 0,
"campaign_mode": 0,
"priority": 15,
"price": "19.99",
"currency_code": "USD",
"formatted_price": "USD$19.99",
"consumable": 1,
"limited_count": 0,
"product_type": 0,
"amenity_label": null,
"ticket_valid_days": null,
"ticket_issuing_gem": null,
"start_datetime": null,
"end_datetime": null,
"total_gem": 2700
},
{
"product_id": "com.bushiroad.global.lovelive.sif2.google.gem.4199",
"name": "4800 Love Gems",
"description": "4460 Paid Love Gems + 340 Free LoveGems",
"thumbnail_url": null,
"charge_gem": 4460,
"free_gem": 340,
"campaign_type": 0,
"campaign_mode": 0,
"priority": 16,
"price": "34.99",
"currency_code": "USD",
"formatted_price": "USD$34.99",
"consumable": 1,
"limited_count": 0,
"product_type": 0,
"amenity_label": null,
"ticket_valid_days": null,
"ticket_issuing_gem": null,
"start_datetime": null,
"end_datetime": null,
"total_gem": 4800
},
{
"product_id": "com.bushiroad.global.lovelive.sif2.google.gem.6499",
"name": "7500 Love Gems",
"description": "6730 Paid Love Gems + 770 Free LoveGems",
"thumbnail_url": null,
"charge_gem": 6730,
"free_gem": 770,
"campaign_type": 0,
"campaign_mode": 0,
"priority": 17,
"price": "49.99",
"currency_code": "USD",
"formatted_price": "USD$49.99",
"consumable": 1,
"limited_count": 0,
"product_type": 0,
"amenity_label": null,
"ticket_valid_days": null,
"ticket_issuing_gem": null,
"start_datetime": null,
"end_datetime": null,
"total_gem": 7500
},
{
"product_id": "com.bushiroad.global.lovelive.sif2.google.gem.8499",
"name": "10100 Love Gems",
"description": "8910 Paid Love Gems + 1190 Free LoveGems",
"thumbnail_url": null,
"charge_gem": 8910,
"free_gem": 1190,
"campaign_type": 0,
"campaign_mode": 0,
"priority": 18,
"price": "69.99",
"currency_code": "USD",
"formatted_price": "USD$69.99",
"consumable": 1,
"limited_count": 0,
"product_type": 0,
"amenity_label": null,
"ticket_valid_days": null,
"ticket_issuing_gem": null,
"start_datetime": null,
"end_datetime": null,
"total_gem": 10100
}
]
}
*/

View file

@ -1,8 +1,9 @@
use crate::encryption;
use json::object;
use actix_web::{HttpResponse, HttpRequest};
use crate::router::global;
use crate::router::userdata;
use actix_web::{HttpResponse, HttpRequest};
use crate::encryption;
pub fn events(_req: HttpRequest) -> HttpResponse {
let resp = object!{

View file

@ -1,10 +1,9 @@
use crate::encryption;
use json::object;
use crate::router::global;
use json::JsonValue;
use json::{object, JsonValue};
use actix_web::{HttpResponse, HttpRequest};
use lazy_static::lazy_static;
use crate::router::userdata;
use crate::router::{userdata, global};
use crate::encryption;
lazy_static! {
static ref SHOP_INFO: JsonValue = {

View file

@ -1,12 +1,10 @@
use json;
use json::object;
use crate::router::global;
use crate::encryption;
use json::{JsonValue, object};
use actix_web::{HttpResponse, HttpRequest, http::header::HeaderValue};
use crate::router::userdata;
pub fn asset_hash(req: HttpRequest, body: String) -> HttpResponse {
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
use crate::encryption;
use crate::router::{userdata, global};
fn get_asset_hash(req: &HttpRequest, body: &JsonValue) -> String {
if body["asset_version"].to_string() != global::ASSET_VERSION && body["asset_version"].to_string() != global::ASSET_VERSION_JP {
println!("Warning! Asset version is not what was expected. (Did the app update?)");
}
@ -28,12 +26,17 @@ pub fn asset_hash(req: HttpRequest, body: String) -> HttpResponse {
global::ASSET_HASH_IOS
}
};
return hash.to_string();
}
pub fn asset_hash(req: HttpRequest, body: String) -> HttpResponse {
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
let resp = object!{
"code": 0,
"server_time": global::timestamp(),
"data": {
"asset_hash": hash
"asset_hash": get_asset_hash(&req, &body)
}
};
global::send(resp)
@ -42,33 +45,11 @@ pub fn asset_hash(req: HttpRequest, body: String) -> HttpResponse {
pub fn start(req: HttpRequest, body: String) -> HttpResponse {
let key = global::get_login(req.headers(), &body);
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
if body["asset_version"].to_string() != global::ASSET_VERSION && body["asset_version"].to_string() != global::ASSET_VERSION_JP {
println!("Warning! Asset version is not what was expected. (Did the app update?)");
}
let mut user = userdata::get_acc(&key);
println!("Signin from uid: {}", user["user"]["id"].clone());
user["user"]["last_login_time"] = global::timestamp().into();
user["stamina"]["last_updated_time"] = global::timestamp().into();
let blank_header = HeaderValue::from_static("");
let platform = req.headers().get("aoharu-platform").unwrap_or(&blank_header).to_str().unwrap_or("");
let android = !platform.to_lowercase().contains("iphone");
let hash = if body["asset_version"].to_string() == global::ASSET_VERSION_JP {
if android {
global::ASSET_HASH_ANDROID_JP
} else {
global::ASSET_HASH_IOS_JP
}
} else {
if android {
global::ASSET_HASH_ANDROID
} else {
global::ASSET_HASH_IOS
}
};
userdata::save_acc(&key, user);
@ -76,7 +57,7 @@ pub fn start(req: HttpRequest, body: String) -> HttpResponse {
"code": 0,
"server_time": global::timestamp(),
"data": {
"asset_hash": hash,
"asset_hash": get_asset_hash(&req, &body),
"token": hex::encode("Hello") //what is this?
}
};

View file

@ -1,12 +1,9 @@
use json;
use json::object;
use crate::router::global;
//use crate::encryption;
use actix_web::{HttpResponse, HttpRequest};
//use crate::router::userdata;
use crate::router::global;
pub fn read(_req: HttpRequest, _body: String) -> HttpResponse {
let resp = object!{
"code": 0,
"server_time": global::timestamp(),

View file

@ -1,9 +1,8 @@
use json;
use json::object;
use crate::router::global;
use crate::encryption;
use actix_web::{HttpResponse, HttpRequest};
use crate::router::userdata;
use crate::router::{userdata, global};
use crate::encryption;
pub fn tutorial(req: HttpRequest, body: String) -> HttpResponse {
let key = global::get_login(req.headers(), &body);

View file

@ -1,11 +1,10 @@
use json;
use json::{array, object, JsonValue};
use crate::router::global;
use crate::encryption;
use actix_web::{HttpResponse, HttpRequest};
use crate::router::userdata;
use lazy_static::lazy_static;
use crate::encryption;
use crate::router::{userdata, global};
pub fn deck(req: HttpRequest, body: String) -> HttpResponse {
let key = global::get_login(req.headers(), &body);
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();

View file

@ -1,10 +1,11 @@
use rusqlite::params;
use lazy_static::lazy_static;
use json::{JsonValue, array, object};
use crate::router::global;
use rand::Rng;
use sha2::{Digest, Sha256};
use base64::{Engine as _, engine::general_purpose};
use crate::router::global;
use crate::sql::SQLite;
lazy_static! {

View file

@ -1,5 +1,11 @@
use actix_web::{HttpResponse, HttpRequest, http::header::HeaderValue, http::header::ContentType};
use actix_web::{
HttpResponse,
HttpRequest,
http::header::HeaderValue,
http::header::ContentType
};
use json::object;
use crate::router::userdata;
use crate::router::global;

View file

@ -1,6 +1,7 @@
use rusqlite::{Connection, params, ToSql};
use std::sync::Mutex;
use json::{JsonValue, array};
use crate::router::clear_rate::Live;
pub struct SQLite {