diff --git a/src/main.rs b/src/main.rs index a20207f..4f2b19b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,6 +21,9 @@ async fn dummy_login(req: HttpRequest, body: String) -> HttpResponse { router::l #[get("/api/user")] async fn user(req: HttpRequest) -> HttpResponse { router::user::user(req) } +#[post("/api/user")] +async fn user_post(req: HttpRequest, body: String) -> HttpResponse { router::user::user_post(req, body) } + #[post("/api/user/initialize")] async fn user_initialize(req: HttpRequest, body: String) -> HttpResponse { router::user::initialize(req, body) } @@ -89,6 +92,7 @@ async fn main() -> std::io::Result<()> { .service(home) .service(start_assethash) .service(user) + .service(user_post) .service(dummy_login) .default_service(web::route().to(log_unknown_request))) .bind(("0.0.0.0", 8080))? diff --git a/src/router/user.rs b/src/router/user.rs index c646279..fb00399 100644 --- a/src/router/user.rs +++ b/src/router/user.rs @@ -20,6 +20,31 @@ pub fn user(req: HttpRequest) -> HttpResponse { global::send(resp) } +pub fn user_post(req: HttpRequest, body: String) -> HttpResponse { + let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap(); + let blank_header = HeaderValue::from_static(""); + + let key = req.headers().get("a6573cbe").unwrap_or(&blank_header).to_str().unwrap_or(""); + let uid = req.headers().get("aoharu-user-id").unwrap_or(&blank_header).to_str().unwrap_or(""); + let mut user = userdata::get_acc(key, uid); + let user_2 = userdata::get_acc_home(key, uid); + + user["user"]["name"] = body["name"].clone(); + user["user"]["friend_request_disabled"] = body["friend_request_disabled"].clone(); + + userdata::save_acc(key, uid, user.clone()); + + let resp = object!{ + "code": 0, + "server_time": global::timestamp(), + "data": { + "user": user["user"].clone(), + "clear_mission_ids": user_2["clear_mission_ids"].clone() + } + }; + global::send(resp) +} + pub fn initialize(req: HttpRequest, body: String) -> HttpResponse { let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap(); let blank_header = HeaderValue::from_static(""); @@ -33,7 +58,20 @@ pub fn initialize(req: HttpRequest, body: String) -> HttpResponse { user["user"]["guest_smile_master_card_id"] = id.into(); user["user"]["guest_cool_master_card_id"] = id.into(); user["user"]["guest_pure_master_card_id"] = id.into(); - user["user"]["master_title_ids"][0] = id.into(); + + let id = body["master_character_id"].to_string(); + let userr = &id[id.len() - 2..].parse::().unwrap(); + let mut masterid = 3000000; + if id.starts_with("2") { + masterid += 9; //muse + } else if id.starts_with("3") { + masterid += 9 + 9; //aquors + } else if id.starts_with("4") { + masterid += 9 + 9 + 12; //nijigasaki + } + masterid += userr; + + user["user"]["master_title_ids"][0] = masterid.into(); userdata::save_acc(key, uid, user.clone());