Tutorial though live (live end not done)
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
use json;
|
||||
use json::object;
|
||||
use crate::router::global;
|
||||
use crate::encryption;
|
||||
use actix_web::{HttpResponse, HttpRequest, http::header::HeaderValue};
|
||||
use crate::router::userdata;
|
||||
|
||||
@ -18,3 +19,28 @@ pub fn user(req: HttpRequest) -> HttpResponse {
|
||||
};
|
||||
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("");
|
||||
|
||||
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 id = (body["master_character_id"].as_i32().unwrap() * 10000) + 7; //todo - is this alwasy the case?
|
||||
user["user"]["favorite_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_pure_master_card_id"] = id.into();
|
||||
user["user"]["master_title_ids"][0] = id.into();
|
||||
|
||||
userdata::save_acc(key, uid, user.clone());
|
||||
|
||||
let resp = object!{
|
||||
"code": 0,
|
||||
"server_time": global::timestamp(),
|
||||
"data": user["user"].clone()
|
||||
};
|
||||
global::send(resp)
|
||||
}
|
||||
|
Reference in New Issue
Block a user