Add iOS jp asset hash

This commit is contained in:
Ethan O'Brien
2024-03-28 19:37:06 -05:00
parent f75c0a19e0
commit f6ef6031fc
2 changed files with 25 additions and 6 deletions

View File

@ -2,17 +2,27 @@ use json;
use json::object;
use crate::router::global;
use crate::encryption;
use actix_web::{HttpResponse, HttpRequest};
use actix_web::{HttpResponse, HttpRequest, http::header::HeaderValue};
use crate::router::userdata;
pub fn asset_hash(_req: HttpRequest, body: String) -> HttpResponse {
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 && body["asset_version"].to_string() != global::ASSET_VERSION_JP {
println!("Warning! Asset version is not what was expected. (Did the app update?)");
}
let blank_header = HeaderValue::from_static("");
let key = req.headers().get("aoharu-platform").unwrap_or(&blank_header).to_str().unwrap_or("");
let android = !key.to_lowercase().contains("iphone");
let hash = if body["asset_version"].to_string() == global::ASSET_VERSION_JP {
global::ASSET_HASH_JP
if android {
global::ASSET_HASH_ANDROID_JP
} else {
global::ASSET_HASH_IOS_JP
}
} else {
//todo - ios
global::ASSET_HASH
};
@ -37,8 +47,16 @@ pub fn start(req: HttpRequest, body: String) -> HttpResponse {
user["user"]["last_login_time"] = global::timestamp().into();
user["stamina"]["last_updated_time"] = global::timestamp().into();
let blank_header = HeaderValue::from_static("");
let key = req.headers().get("aoharu-platform").unwrap_or(&blank_header).to_str().unwrap_or("");
let android = !key.to_lowercase().contains("iphone");
let hash = if body["asset_version"].to_string() == global::ASSET_VERSION_JP {
global::ASSET_HASH_JP
if android {
global::ASSET_HASH_ANDROID_JP
} else {
global::ASSET_HASH_IOS_JP
}
} else {
global::ASSET_HASH
};