mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew.git
synced 2025-05-13 11:37:33 -05:00
Implement post /api/user endpoint
This commit is contained in:
parent
9f28840c77
commit
f20e948f16
2 changed files with 43 additions and 1 deletions
|
@ -21,6 +21,9 @@ async fn dummy_login(req: HttpRequest, body: String) -> HttpResponse { router::l
|
||||||
#[get("/api/user")]
|
#[get("/api/user")]
|
||||||
async fn user(req: HttpRequest) -> HttpResponse { router::user::user(req) }
|
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")]
|
#[post("/api/user/initialize")]
|
||||||
async fn user_initialize(req: HttpRequest, body: String) -> HttpResponse { router::user::initialize(req, body) }
|
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(home)
|
||||||
.service(start_assethash)
|
.service(start_assethash)
|
||||||
.service(user)
|
.service(user)
|
||||||
|
.service(user_post)
|
||||||
.service(dummy_login)
|
.service(dummy_login)
|
||||||
.default_service(web::route().to(log_unknown_request)))
|
.default_service(web::route().to(log_unknown_request)))
|
||||||
.bind(("0.0.0.0", 8080))?
|
.bind(("0.0.0.0", 8080))?
|
||||||
|
|
|
@ -20,6 +20,31 @@ pub fn user(req: HttpRequest) -> HttpResponse {
|
||||||
global::send(resp)
|
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 {
|
pub fn initialize(req: HttpRequest, body: String) -> HttpResponse {
|
||||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||||
let blank_header = HeaderValue::from_static("");
|
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_smile_master_card_id"] = id.into();
|
||||||
user["user"]["guest_cool_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"]["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::<i32>().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());
|
userdata::save_acc(key, uid, user.clone());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue