2024-02-23 15:59:55 +00:00
|
|
|
use json;
|
|
|
|
use json::object;
|
|
|
|
use crate::router::global;
|
|
|
|
use crate::encryption;
|
2024-02-23 19:28:44 +00:00
|
|
|
use actix_web::{HttpResponse, HttpRequest, http::header::HeaderValue};
|
|
|
|
use crate::router::userdata;
|
2024-02-23 15:59:55 +00:00
|
|
|
|
|
|
|
pub fn asset_hash(_req: HttpRequest, body: String) -> HttpResponse {
|
|
|
|
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
|
|
|
if body["asset_version"].to_string() != global::ASSET_VERSION {
|
|
|
|
println!("Warning! Asset version is not what was expected. (Did the app update?)");
|
|
|
|
}
|
|
|
|
let resp = object!{
|
|
|
|
"code": 0,
|
|
|
|
"server_time": global::timestamp(),
|
|
|
|
"data": {
|
|
|
|
"asset_hash": global::ASSET_HASH
|
|
|
|
}
|
|
|
|
};
|
|
|
|
global::send(resp)
|
|
|
|
}
|
2024-02-23 19:28:44 +00:00
|
|
|
|
|
|
|
pub fn start(req: HttpRequest, body: String) -> HttpResponse {
|
|
|
|
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
|
|
|
if body["asset_version"].to_string() != global::ASSET_VERSION {
|
|
|
|
println!("Warning! Asset version is not what was expected. (Did the app update?)");
|
|
|
|
}
|
|
|
|
let blank_header = HeaderValue::from_static("");
|
|
|
|
let key = req.headers().get("a6573cbe").unwrap_or(&blank_header).to_str().unwrap_or("");
|
2024-02-27 02:50:11 +00:00
|
|
|
let mut user = userdata::get_acc(key);
|
2024-02-23 19:28:44 +00:00
|
|
|
|
|
|
|
user["user"]["last_login_time"] = global::timestamp().into();
|
|
|
|
user["stamina"]["last_updated_time"] = global::timestamp().into();
|
|
|
|
|
2024-02-27 02:50:11 +00:00
|
|
|
userdata::save_acc(key, user);
|
2024-02-23 19:28:44 +00:00
|
|
|
|
|
|
|
let resp = object!{
|
|
|
|
"code": 0,
|
|
|
|
"server_time": global::timestamp(),
|
|
|
|
"data": {
|
|
|
|
"asset_hash": global::ASSET_HASH,
|
|
|
|
"token": hex::encode("Hello") //what is this?
|
|
|
|
}
|
|
|
|
};
|
|
|
|
global::send(resp)
|
|
|
|
}
|