mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew
synced 2026-08-26 15:02:18 +08:00
Move all encryption to a session handler
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
use jzon::{object, array, JsonValue};
|
||||
use actix_web::{web, HttpRequest, Responder};
|
||||
|
||||
use crate::router::{userdata, global, items, databases};
|
||||
use crate::encryption;
|
||||
use crate::router::{userdata, global, items, databases, Session};
|
||||
|
||||
pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
cfg.service(
|
||||
@@ -106,9 +105,7 @@ fn do_reinforce(user: &mut JsonValue, body: &JsonValue, exp_id: &str, money_mult
|
||||
object!{}
|
||||
}
|
||||
|
||||
async fn reinforce(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn reinforce(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let mut user = userdata::get_acc(&key);
|
||||
let mut clear_mission_ids = array![];
|
||||
|
||||
@@ -124,9 +121,7 @@ async fn reinforce(req: HttpRequest, body: String) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn skill_reinforce(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn skill_reinforce(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let mut user = userdata::get_acc(&key);
|
||||
let mut clear_mission_ids = array![];
|
||||
|
||||
@@ -142,9 +137,7 @@ async fn skill_reinforce(req: HttpRequest, body: String) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn evolve(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn evolve(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let mut user = userdata::get_acc(&key);
|
||||
let mut chats = userdata::get_acc_chats(&key);
|
||||
let mut missions = userdata::get_acc_missions(&key);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use jzon::{object, array, JsonValue};
|
||||
use actix_web::{web, HttpRequest, Responder};
|
||||
|
||||
use crate::router::{global, items, userdata, databases};
|
||||
use crate::encryption;
|
||||
use crate::router::{global, items, userdata, databases, Login, Session};
|
||||
|
||||
pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
cfg.service(
|
||||
@@ -38,8 +37,7 @@ pub fn add_chat_from_chapter_id(chapter_id: i64, chats: &mut JsonValue) -> bool
|
||||
add_chat(chapter["masterChatId"].as_i64().unwrap(), chapter["roomId"].as_i64().unwrap(), chats)
|
||||
}
|
||||
|
||||
async fn home(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
async fn home(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
let chats = userdata::get_acc_chats(&key);
|
||||
|
||||
let mut rooms = array![];
|
||||
@@ -55,13 +53,11 @@ async fn home(req: HttpRequest, body: String) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn start(req: HttpRequest, _body: String) -> impl Responder {
|
||||
async fn start(req: HttpRequest) -> impl Responder {
|
||||
global::api(&req, Some(object!{"select_talk_id_list":[],"get_item_list":[],"is_read":0}))
|
||||
}
|
||||
|
||||
async fn end(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn end(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let mut missions = userdata::get_acc_missions(&key);
|
||||
let mut chats = userdata::get_acc_chats(&key);
|
||||
|
||||
|
||||
@@ -4,9 +4,8 @@ use rusqlite::params;
|
||||
use std::sync::Mutex;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
use crate::encryption;
|
||||
use crate::sql::SQLite;
|
||||
use crate::router::{databases, global, userdata};
|
||||
use crate::router::{databases, global, userdata, Session};
|
||||
use crate::include_file;
|
||||
use crate::router::tools::guest;
|
||||
|
||||
@@ -255,9 +254,7 @@ pub async fn clearrate(req: HttpRequest) -> impl Responder {
|
||||
global::api(&req, Some(data))
|
||||
}
|
||||
|
||||
pub async fn ranking(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
pub async fn ranking(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let self_id = userdata::get_acc(&key)["user"]["id"].as_i64().unwrap();
|
||||
let live = body["master_live_id"].as_i64().unwrap();
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::sync::Mutex;
|
||||
|
||||
use crate::router::{global, userdata, webui};
|
||||
use crate::router::{global, userdata, webui, Login};
|
||||
use crate::database::custom_song as database;
|
||||
use crate::runtime::get_data_path;
|
||||
use crate::lock_onto_mutex;
|
||||
@@ -91,12 +91,11 @@ pub fn client_supports_custom_songs(req: &HttpRequest) -> bool {
|
||||
|
||||
// The catalog is filtered per requesting user: private songs only show for
|
||||
// their owner, shared songs for the owner plus their shared-user list
|
||||
async fn list(req: HttpRequest, body: String) -> impl Responder {
|
||||
async fn list(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
if disabled() {
|
||||
// As if the endpoint doesn't exist - the client treats this as feature-off
|
||||
return global::api(&req, None);
|
||||
}
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let uid = userdata::get_acc(&key)["user"]["id"].as_i64().unwrap();
|
||||
global::api(&req, Some(object!{
|
||||
"revision": database::get_revision(),
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
use jzon::object;
|
||||
use actix_web::{web, HttpRequest, Responder};
|
||||
|
||||
use crate::encryption;
|
||||
use crate::router::global;
|
||||
use crate::router::{global, Body};
|
||||
|
||||
pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
cfg.route("/debug/error", web::post().to(error));
|
||||
}
|
||||
|
||||
async fn error(req: HttpRequest, body: String) -> impl Responder {
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn error(req: HttpRequest, Body(body): Body) -> impl Responder {
|
||||
|
||||
println!("client error: {}", body["code"]);
|
||||
|
||||
|
||||
@@ -2,9 +2,8 @@ use jzon::{JsonValue, object, array};
|
||||
use actix_web::{web, HttpRequest, Responder};
|
||||
use rand::RngExt;
|
||||
|
||||
use crate::encryption;
|
||||
use crate::include_file;
|
||||
use crate::router::{userdata, global, databases};
|
||||
use crate::router::{userdata, global, databases, Body, Session};
|
||||
|
||||
// I believe(?) this is all?
|
||||
const STAR_EVENT_IDS: [u32; 3] = [127, 135, 139];
|
||||
@@ -114,12 +113,7 @@ fn init_star_event(event: &mut JsonValue) {
|
||||
switch_music(event, 5);
|
||||
}
|
||||
|
||||
async fn event(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
|
||||
let body = &encryption::decrypt_packet(&body).unwrap();
|
||||
let body = jzon::parse(&body).unwrap();
|
||||
|
||||
async fn event(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let master_event_id = body["master_event_id"].as_u32().unwrap();
|
||||
let mut event = get_event_data(&key, master_event_id);
|
||||
|
||||
@@ -162,12 +156,8 @@ async fn event(req: HttpRequest, body: String) -> impl Responder {
|
||||
global::api(&req, Some(event))
|
||||
}
|
||||
|
||||
async fn star_event(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
async fn star_event(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let user = userdata::get_acc(&key);
|
||||
|
||||
let body = &encryption::decrypt_packet(&body).unwrap();
|
||||
let body = jzon::parse(&body).unwrap();
|
||||
let master_event_id = body["master_event_id"].as_u32().unwrap();
|
||||
|
||||
let mut event = get_event_data(&key, master_event_id);
|
||||
@@ -187,11 +177,7 @@ async fn star_event(req: HttpRequest, body: String) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn change_target_music(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
|
||||
let body = &encryption::decrypt_packet(&body).unwrap();
|
||||
let body = jzon::parse(&body).unwrap();
|
||||
async fn change_target_music(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let master_event_id = body["master_event_id"].as_u32().unwrap();
|
||||
|
||||
let mut event = get_event_data(&key, master_event_id);
|
||||
@@ -205,11 +191,7 @@ async fn change_target_music(req: HttpRequest, body: String) -> impl Responder {
|
||||
global::api(&req, Some(event["star_event"].clone()))
|
||||
}
|
||||
|
||||
async fn set_member(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
|
||||
let body = &encryption::decrypt_packet(&body).unwrap();
|
||||
let body = jzon::parse(&body).unwrap();
|
||||
async fn set_member(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let master_event_id = body["master_event_id"].as_u32().unwrap();
|
||||
|
||||
let mut event = get_event_data(&key, master_event_id);
|
||||
@@ -240,9 +222,7 @@ fn get_rank(event: u32, user_id: u64) -> u32 {
|
||||
0
|
||||
}
|
||||
|
||||
async fn ranking(req: HttpRequest, body: String) -> impl Responder {
|
||||
let body = &encryption::decrypt_packet(&body).unwrap();
|
||||
let body = jzon::parse(&body).unwrap();
|
||||
async fn ranking(req: HttpRequest, Body(body): Body) -> impl Responder {
|
||||
let master_event_id = body["master_event_id"].as_u32().unwrap();
|
||||
let scores = crate::router::event_ranking::get_scores_json().await[master_event_id as usize].clone();
|
||||
let mut rv = array![];
|
||||
@@ -304,18 +284,14 @@ fn get_points(event_id: u32, user: &JsonValue) -> i64 {
|
||||
0
|
||||
}
|
||||
|
||||
fn event_live(req: &HttpRequest, body: String, skipped: bool) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body_temp = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
fn event_live(req: &HttpRequest, key: &str, body: &JsonValue, skipped: bool) -> Option<JsonValue> {
|
||||
let event_id = if skipped {
|
||||
body_temp["master_event_id"].as_u32().unwrap()
|
||||
body["master_event_id"].as_u32().unwrap()
|
||||
} else {
|
||||
crate::router::live::get_end_live_event_id(&key, &body_temp)?
|
||||
crate::router::live::get_end_live_event_id(key, body)?
|
||||
};
|
||||
|
||||
let mut resp = crate::router::live::live_end(req, &body, skipped);
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let mut resp = crate::router::live::live_end(req, key, body, skipped);
|
||||
let mut event = get_event_data(&key, event_id);
|
||||
let mut user = userdata::get_acc(&key);
|
||||
|
||||
@@ -380,10 +356,10 @@ fn event_live(req: &HttpRequest, body: String, skipped: bool) -> Option<JsonValu
|
||||
Some(resp)
|
||||
}
|
||||
|
||||
async fn event_end(req: HttpRequest, body: String) -> impl Responder {
|
||||
global::api(&req, event_live(&req, body, false))
|
||||
async fn event_end(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
global::api(&req, event_live(&req, &key, &body, false))
|
||||
}
|
||||
|
||||
async fn event_skip(req: HttpRequest, body: String) -> impl Responder {
|
||||
global::api(&req, event_live(&req, body, true))
|
||||
async fn event_skip(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
global::api(&req, event_live(&req, &key, &body, true))
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
use jzon::{object, array, JsonValue};
|
||||
use actix_web::{web, HttpRequest, Responder};
|
||||
|
||||
use crate::router::{global, userdata, items, databases};
|
||||
use crate::encryption;
|
||||
use crate::router::{global, userdata, items, databases, Login, Session};
|
||||
|
||||
pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
cfg.service(web::resource("/exchange").route(web::get().to(exchange)).route(web::post().to(exchange_post)));
|
||||
}
|
||||
|
||||
async fn exchange(req: HttpRequest) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), "");
|
||||
async fn exchange(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
let exchange = userdata::get_acc_exchange(&key);
|
||||
global::api(&req, Some(object!{
|
||||
"exchange_list": exchange
|
||||
@@ -34,9 +32,7 @@ fn exchange_updated_value_list(is_card: bool, granted_id: i64, consumed_id: i64,
|
||||
rv
|
||||
}
|
||||
|
||||
async fn exchange_post(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn exchange_post(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let mut user = userdata::get_acc(&key);
|
||||
let mut missions = userdata::get_acc_missions(&key);
|
||||
let mut chats = userdata::get_acc_chats(&key);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use jzon::{array, object};
|
||||
use actix_web::{web, HttpRequest, Responder};
|
||||
|
||||
use crate::router::{global, userdata};
|
||||
use crate::encryption;
|
||||
use crate::router::{global, userdata, Login, Session};
|
||||
use crate::router::tools::guest;
|
||||
|
||||
pub const FRIEND_LIMIT: usize = 40;
|
||||
@@ -21,9 +20,7 @@ pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
);
|
||||
}
|
||||
|
||||
async fn friend(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn friend(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let user_id = userdata::get_acc(&key)["user"]["id"].as_i64().unwrap();
|
||||
let friends = userdata::get_acc_friends(&key);
|
||||
|
||||
@@ -50,15 +47,13 @@ async fn friend(req: HttpRequest, body: String) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn ids(req: HttpRequest) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), "");
|
||||
async fn ids(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
let friends = userdata::get_acc_friends(&key);
|
||||
|
||||
global::api(&req, Some(friends))
|
||||
}
|
||||
|
||||
async fn recommend(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
async fn recommend(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
let user_id = userdata::get_acc(&key)["user"]["id"].as_i64().unwrap();
|
||||
let friends = userdata::get_acc_friends(&key);
|
||||
|
||||
@@ -83,9 +78,7 @@ async fn recommend(req: HttpRequest, body: String) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn search(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn search(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let friends = userdata::get_acc_friends(&key);
|
||||
|
||||
let uid = body["user_id"].as_i64().unwrap();
|
||||
@@ -98,9 +91,7 @@ async fn search(req: HttpRequest, body: String) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn request(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn request(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let user_id = userdata::get_acc(&key)["user"]["id"].as_i64().unwrap();
|
||||
let mut friends = userdata::get_acc_friends(&key);
|
||||
|
||||
@@ -116,9 +107,7 @@ async fn request(req: HttpRequest, body: String) -> impl Responder {
|
||||
global::api(&req, Some(array![]))
|
||||
}
|
||||
|
||||
async fn approve(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn approve(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let user_id = userdata::get_acc(&key)["user"]["id"].as_i64().unwrap();
|
||||
let mut friends = userdata::get_acc_friends(&key);
|
||||
|
||||
@@ -137,9 +126,7 @@ async fn approve(req: HttpRequest, body: String) -> impl Responder {
|
||||
global::api(&req, Some(array![]))
|
||||
}
|
||||
|
||||
async fn cancel(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn cancel(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let user_id = userdata::get_acc(&key)["user"]["id"].as_i64().unwrap();
|
||||
let mut friends = userdata::get_acc_friends(&key);
|
||||
|
||||
@@ -154,9 +141,7 @@ async fn cancel(req: HttpRequest, body: String) -> impl Responder {
|
||||
global::api(&req, Some(array![]))
|
||||
}
|
||||
|
||||
async fn delete(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn delete(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let user_id = userdata::get_acc(&key)["user"]["id"].as_i64().unwrap();
|
||||
let mut friends = userdata::get_acc_friends(&key);
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@ use jzon::{object, array, JsonValue};
|
||||
use actix_web::{web, HttpRequest, Responder};
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
use crate::router::{global, userdata, items};
|
||||
use crate::encryption;
|
||||
use crate::router::{global, userdata, items, Login, Session};
|
||||
|
||||
pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
cfg.service(
|
||||
@@ -14,9 +13,7 @@ pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
);
|
||||
}
|
||||
|
||||
async fn preset(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn preset(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let mut user = userdata::get_acc_home(&key);
|
||||
|
||||
for data in user["home"]["preset_setting"].members_mut() {
|
||||
@@ -41,8 +38,7 @@ fn check_gifts(user: &mut JsonValue) {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn gift_get(req: HttpRequest) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), "");
|
||||
pub async fn gift_get(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
let mut user = userdata::get_acc_home(&key);
|
||||
check_gifts(&mut user);
|
||||
|
||||
@@ -51,8 +47,7 @@ pub async fn gift_get(req: HttpRequest) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn preset_get(req: HttpRequest) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), "");
|
||||
async fn preset_get(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
let user = userdata::get_acc(&key);
|
||||
|
||||
global::api(&req, Some(object!{
|
||||
@@ -88,8 +83,7 @@ lazy_static! {
|
||||
};
|
||||
}
|
||||
|
||||
async fn home(req: HttpRequest) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), "");
|
||||
async fn home(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
let mut user = userdata::get_acc_home(&key);
|
||||
|
||||
check_gifts(&mut user);
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use jzon::{array, object, JsonValue};
|
||||
use rand::RngExt;
|
||||
use actix_web::{web, HttpRequest, Responder, http::header::{HeaderMap, HeaderValue}};
|
||||
use crate::encryption;
|
||||
|
||||
use crate::router::{userdata, global, databases};
|
||||
use crate::router::{userdata, global, databases, Session};
|
||||
|
||||
pub fn remove_gems(user: &mut JsonValue, amount: i64) {
|
||||
let mut amount = amount;
|
||||
@@ -557,9 +556,7 @@ pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
cfg.route("/item/use", web::post().to(use_item_req));
|
||||
}
|
||||
|
||||
async fn use_item_req(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn use_item_req(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let mut user = userdata::get_acc(&key);
|
||||
|
||||
let item = &databases::ITEM_INFO[body["id"].to_string()];
|
||||
|
||||
@@ -3,8 +3,7 @@ use actix_web::{web, HttpRequest, Responder};
|
||||
use rand::RngExt;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
use crate::router::{databases, global, items, userdata};
|
||||
use crate::encryption;
|
||||
use crate::router::{databases, global, items, userdata, Login, Session};
|
||||
use crate::router::clear_rate::live_completed;
|
||||
use crate::router::tools::guest;
|
||||
|
||||
@@ -25,9 +24,7 @@ pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
}
|
||||
|
||||
|
||||
async fn retire(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn retire(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
live_retire(&key, &body);
|
||||
if body["live_score"]["play_time"].as_i64().unwrap_or(0) > 5 {
|
||||
live_completed(body["master_live_id"].as_i64().unwrap(), body["level"].as_i32().unwrap(), true, 0, 0);
|
||||
@@ -39,9 +36,7 @@ async fn retire(req: HttpRequest, body: String) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn reward(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn reward(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let user = userdata::get_acc(&key);
|
||||
let live_id = body["master_live_id"].as_i64().unwrap();
|
||||
let cleared = get_clear_count(live_id, &user) > 0;
|
||||
@@ -85,8 +80,7 @@ fn random_number(lowest: usize, highest: usize) -> usize {
|
||||
rand::rng().random_range(lowest..highest + 1)
|
||||
}
|
||||
|
||||
async fn guest(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
async fn guest(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
let user_id = userdata::get_acc(&key)["user"]["id"].as_i64().unwrap();
|
||||
let friends = userdata::get_acc_friends(&key);
|
||||
let user = userdata::get_acc(&key);
|
||||
@@ -214,7 +208,7 @@ async fn guest(req: HttpRequest, body: String) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn mission(req: HttpRequest, _body: String) -> impl Responder {
|
||||
async fn mission(req: HttpRequest) -> impl Responder {
|
||||
//todo
|
||||
global::api(&req, Some(object!{
|
||||
"score_ranking": "",
|
||||
@@ -284,22 +278,17 @@ fn start_live(login_token: &str, body: &JsonValue) {
|
||||
userdata::save_server_data(login_token, server_data);
|
||||
}
|
||||
|
||||
async fn start(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn start(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
start_live(&key, &body);
|
||||
global::api(&req, Some(array![]))
|
||||
}
|
||||
|
||||
pub async fn event_start(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
pub async fn event_start(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
start_live(&key, &body);
|
||||
global::api(&req, Some(array![]))
|
||||
}
|
||||
|
||||
async fn continuee(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
async fn continuee(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
let mut user = userdata::get_acc(&key);
|
||||
|
||||
items::remove_gems(&mut user, 100);
|
||||
@@ -603,9 +592,7 @@ fn get_live_character_list(lp_used: i32, deck_id: i32, user: &mut JsonValue, mis
|
||||
rv
|
||||
}
|
||||
|
||||
pub fn live_end(req: &HttpRequest, body: &str, skipped: bool) -> JsonValue {
|
||||
let key = global::get_login(req.headers(), body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(body).unwrap()).unwrap();
|
||||
pub fn live_end(req: &HttpRequest, key: &str, body: &JsonValue, skipped: bool) -> JsonValue {
|
||||
let mut user2 = userdata::get_acc_home(&key);
|
||||
let mut user = userdata::get_acc(&key);
|
||||
let mut user_missions = userdata::get_acc_missions(&key);
|
||||
@@ -754,12 +741,12 @@ pub fn live_end(req: &HttpRequest, body: &str, skipped: bool) -> JsonValue {
|
||||
rv
|
||||
}
|
||||
|
||||
async fn end(req: HttpRequest, body: String) -> impl Responder {
|
||||
global::api(&req, Some(live_end(&req, &body, false)))
|
||||
async fn end(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
global::api(&req, Some(live_end(&req, &key, &body, false)))
|
||||
}
|
||||
|
||||
async fn skip(req: HttpRequest, body: String) -> impl Responder {
|
||||
global::api(&req, Some(live_end(&req, &body, true)))
|
||||
async fn skip(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
global::api(&req, Some(live_end(&req, &key, &body, true)))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use jzon::{object, array, JsonValue};
|
||||
use actix_web::{web, HttpRequest, Responder};
|
||||
|
||||
use crate::router::{global, userdata, items, databases};
|
||||
use crate::router::{global, userdata, items, databases, Login};
|
||||
|
||||
pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
cfg.route("/dummy/login", web::post().to(dummy));
|
||||
@@ -9,8 +9,7 @@ pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
cfg.route("/login_bonus/event", web::post().to(bonus_event));
|
||||
}
|
||||
|
||||
async fn dummy(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
async fn dummy(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
let user = userdata::get_acc(&key);
|
||||
|
||||
global::api(&req, Some(object!{
|
||||
@@ -53,8 +52,7 @@ fn do_bonus(user_home: &mut JsonValue, bonuses: &mut JsonValue) -> JsonValue {
|
||||
to_send
|
||||
}
|
||||
|
||||
async fn bonus(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
async fn bonus(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
let mut user_home = userdata::get_acc_home(&key);
|
||||
let mut user_missions = userdata::get_acc_missions(&key);
|
||||
|
||||
@@ -80,8 +78,7 @@ async fn bonus(req: HttpRequest, body: String) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn bonus_event(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
async fn bonus_event(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
let mut user_home = userdata::get_acc_home(&key);
|
||||
|
||||
let mut bonuses = userdata::get_acc_eventlogin(&key);
|
||||
|
||||
@@ -2,8 +2,7 @@ use jzon::{array, object, JsonValue};
|
||||
use actix_web::{web, HttpRequest, Responder};
|
||||
use rand::RngExt;
|
||||
|
||||
use crate::router::{global, userdata, items, databases};
|
||||
use crate::encryption;
|
||||
use crate::router::{global, userdata, items, databases, Body, Login, Session};
|
||||
|
||||
pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
cfg.service(
|
||||
@@ -13,8 +12,7 @@ pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
);
|
||||
}
|
||||
|
||||
async fn tutorial(req: HttpRequest, body: String) -> impl Responder {
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn tutorial(req: HttpRequest, Body(body): Body) -> impl Responder {
|
||||
|
||||
let id = body["master_character_id"].to_string();
|
||||
let user = &id[id.len() - 2..].parse::<i32>().unwrap();
|
||||
@@ -189,17 +187,14 @@ fn get_lottery_list(user: &JsonValue) -> JsonValue {
|
||||
rv
|
||||
}
|
||||
|
||||
async fn lottery(req: HttpRequest) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), "");
|
||||
async fn lottery(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
let user = userdata::get_acc(&key);
|
||||
global::api(&req, Some(object!{
|
||||
"lottery_list": get_lottery_list(&user)
|
||||
}))
|
||||
}
|
||||
|
||||
async fn lottery_post(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn lottery_post(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
//println!("lottery: {}", body);
|
||||
let mut user = userdata::get_acc(&key);
|
||||
let user2 = userdata::get_acc(&key);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use jzon::{array, object, JsonValue};
|
||||
use actix_web::{web, HttpRequest, Responder};
|
||||
|
||||
use crate::router::{global, userdata, items, databases};
|
||||
use crate::encryption;
|
||||
use crate::router::{global, userdata, items, databases, Login, Session};
|
||||
|
||||
pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
cfg.service(
|
||||
@@ -15,8 +14,7 @@ pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
|
||||
const VARIABLE_MISSIONS: [[i64; 2]; 5] = [[1153001, 1153019], [1105001, 1105017], [1101001, 1101030], [1121001, 1121019], [1112001, 1112033]];
|
||||
|
||||
async fn mission(req: HttpRequest) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), "");
|
||||
async fn mission(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
let user = userdata::get_acc(&key);
|
||||
let step = user["tutorial_step"].as_i64().unwrap_or(0);
|
||||
|
||||
@@ -36,11 +34,8 @@ async fn mission(req: HttpRequest) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn clear(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
|
||||
async fn clear(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let mut missions = userdata::get_acc_missions(&key);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
|
||||
let mut cleared = array![];
|
||||
for id in body["master_mission_ids"].members() {
|
||||
@@ -59,9 +54,7 @@ async fn clear(req: HttpRequest, body: String) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn receive(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn receive(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let uid = global::get_uid(req.headers());
|
||||
let now = global::timestamp();
|
||||
|
||||
|
||||
@@ -14,6 +14,6 @@ async fn reward(req: HttpRequest) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn reward_post(req: HttpRequest, _body: String) -> impl Responder {
|
||||
async fn reward_post(req: HttpRequest) -> impl Responder {
|
||||
global::api(&req, Some(array![]))
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use jzon::{array, object};
|
||||
use actix_web::{web, HttpRequest, Responder};
|
||||
|
||||
use crate::router::{global, userdata, items};
|
||||
use crate::encryption;
|
||||
use crate::router::{global, userdata, items, Session};
|
||||
|
||||
pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
cfg.service(
|
||||
@@ -18,9 +17,7 @@ async fn events(req: HttpRequest) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn serial_code(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn serial_code(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let mut user = userdata::get_acc_home(&key);
|
||||
|
||||
let mut itemz = array![];
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use jzon::{object};
|
||||
use actix_web::{web, HttpRequest, Responder};
|
||||
|
||||
use crate::router::{userdata, global, items, databases};
|
||||
use crate::encryption;
|
||||
use crate::router::{userdata, global, items, databases, Login, Session};
|
||||
|
||||
pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
cfg.service(
|
||||
@@ -12,8 +11,7 @@ pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
);
|
||||
}
|
||||
|
||||
async fn shop(req: HttpRequest) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), "");
|
||||
async fn shop(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
let user = userdata::get_acc(&key);
|
||||
|
||||
global::api(&req, Some(object!{
|
||||
@@ -21,9 +19,7 @@ async fn shop(req: HttpRequest) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn buy(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn buy(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let mut user = userdata::get_acc(&key);
|
||||
|
||||
let shop_item_id = body["master_shop_item_id"].as_i64().unwrap();
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use jzon::{JsonValue, object};
|
||||
use actix_web::{web, HttpRequest, Responder};
|
||||
|
||||
use crate::encryption;
|
||||
use crate::router::{userdata, global};
|
||||
use crate::router::{userdata, global, Body, Session};
|
||||
|
||||
pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
cfg.route("/start", web::post().to(start));
|
||||
@@ -25,8 +24,7 @@ fn get_asset_hash(req: &HttpRequest, body: &JsonValue) -> Option<String> {
|
||||
rv
|
||||
}
|
||||
|
||||
async fn asset_hash(req: HttpRequest, body: String) -> impl Responder {
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn asset_hash(req: HttpRequest, Body(body): Body) -> impl Responder {
|
||||
|
||||
match get_asset_hash(&req, &body) {
|
||||
Some(hash) => global::api(&req, Some(object!{
|
||||
@@ -36,9 +34,7 @@ async fn asset_hash(req: HttpRequest, body: String) -> impl Responder {
|
||||
}
|
||||
}
|
||||
|
||||
async fn start(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn start(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
|
||||
let Some(asset_hash) = get_asset_hash(&req, &body) else {
|
||||
return global::api_error(&req, global::RESULT_GAME_VERSION_UPDATED);
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
use jzon::{object};
|
||||
use actix_web::{web, HttpRequest, Responder};
|
||||
|
||||
use crate::encryption;
|
||||
use crate::router::{global, userdata, databases};
|
||||
use crate::router::{global, userdata, databases, Session};
|
||||
|
||||
pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
cfg.route("/story/read", web::post().to(read));
|
||||
}
|
||||
|
||||
async fn read(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn read(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let mut user = userdata::get_acc(&key);
|
||||
let part = body["master_story_part_id"].as_i64().unwrap();
|
||||
let master_id = databases::STORY[part.to_string()]["masterStoryId"].as_i64().unwrap();
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
use jzon::{array};
|
||||
use actix_web::{web, HttpRequest, Responder};
|
||||
|
||||
use crate::router::{userdata, global};
|
||||
use crate::encryption;
|
||||
use crate::router::{userdata, global, Session};
|
||||
|
||||
pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
cfg.route("/tutorial", web::post().to(tutorial));
|
||||
}
|
||||
|
||||
async fn tutorial(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn tutorial(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let mut user = userdata::get_acc(&key);
|
||||
|
||||
if user["tutorial_step"].as_i32().unwrap() < 130 {
|
||||
|
||||
@@ -2,8 +2,7 @@ use jzon::{array, object, JsonValue};
|
||||
use actix_web::{web, HttpRequest, Responder};
|
||||
use sha1::{Digest, Sha1};
|
||||
|
||||
use crate::encryption;
|
||||
use crate::router::{global, items, userdata};
|
||||
use crate::router::{global, items, userdata, Body, Login, Session};
|
||||
use crate::include_file;
|
||||
use crate::router::tools::guest;
|
||||
|
||||
@@ -26,9 +25,7 @@ pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
cfg.route("/album/sif", web::get().to(sif));
|
||||
}
|
||||
|
||||
async fn deck(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn deck(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let mut user = userdata::get_acc(&key);
|
||||
|
||||
for (i, data) in user["deck_list"].clone().members().enumerate() {
|
||||
@@ -59,8 +56,7 @@ async fn deck(req: HttpRequest, body: String) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn user(req: HttpRequest) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), "");
|
||||
async fn user(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
let mut user = userdata::get_acc(&key);
|
||||
|
||||
user["lottery_list"] = array![];
|
||||
@@ -74,9 +70,7 @@ async fn user(req: HttpRequest) -> impl Responder {
|
||||
global::api(&req, Some(user))
|
||||
}
|
||||
|
||||
pub async fn gift(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
pub async fn gift(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
|
||||
let mut user = userdata::get_acc_home(&key);
|
||||
let mut userr = userdata::get_acc(&key);
|
||||
@@ -132,9 +126,7 @@ pub async fn gift(req: HttpRequest, body: String) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn user_post(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn user_post(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
|
||||
let mut user = userdata::get_acc(&key);
|
||||
|
||||
@@ -181,8 +173,7 @@ async fn user_post(req: HttpRequest, body: String) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
pub async fn announcement(req: HttpRequest) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), "");
|
||||
pub async fn announcement(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
|
||||
let mut user = userdata::get_acc_home(&key);
|
||||
|
||||
@@ -195,8 +186,7 @@ pub async fn announcement(req: HttpRequest) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn get_migration_code(req: HttpRequest, body: String) -> impl Responder {
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn get_migration_code(req: HttpRequest, Body(body): Body) -> impl Responder {
|
||||
|
||||
let Some(user_id) = body["user_id"].as_i64() else { return global::api(&req, None); };
|
||||
let code = userdata::user::migration::get_acc_token(user_id);
|
||||
@@ -206,9 +196,7 @@ async fn get_migration_code(req: HttpRequest, body: String) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn register_password(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn register_password(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
|
||||
let user = userdata::get_acc(&key);
|
||||
|
||||
@@ -217,8 +205,7 @@ async fn register_password(req: HttpRequest, body: String) -> impl Responder {
|
||||
global::api(&req, Some(array![]))
|
||||
}
|
||||
|
||||
async fn verify_migration_code(req: HttpRequest, body: String) -> impl Responder {
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn verify_migration_code(req: HttpRequest, Body(body): Body) -> impl Responder {
|
||||
|
||||
let user = userdata::user::migration::get_acc_transfer(&body["migrationCode"].to_string(), &body["pass"].to_string());
|
||||
|
||||
@@ -235,8 +222,7 @@ async fn verify_migration_code(req: HttpRequest, body: String) -> impl Responder
|
||||
"free": data_user["gem"]["free"].clone()
|
||||
}))
|
||||
}
|
||||
async fn request_migration_code(req: HttpRequest, body: String) -> impl Responder {
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn request_migration_code(req: HttpRequest, Body(body): Body) -> impl Responder {
|
||||
|
||||
let user = userdata::user::migration::get_acc_transfer(&body["migrationCode"].to_string(), &body["pass"].to_string());
|
||||
|
||||
@@ -248,17 +234,14 @@ async fn request_migration_code(req: HttpRequest, body: String) -> impl Responde
|
||||
"twxuid": user["login_token"].to_string()
|
||||
}))
|
||||
}
|
||||
async fn migration(req: HttpRequest, body: String) -> impl Responder {
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn migration(req: HttpRequest, Body(body): Body) -> impl Responder {
|
||||
|
||||
let user = userdata::get_name_and_rank(body["user_id"].to_string().parse::<i64>().unwrap());
|
||||
|
||||
global::api(&req, Some(user))
|
||||
}
|
||||
|
||||
async fn detail(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn detail(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let friends = userdata::get_acc_friends(&key);
|
||||
|
||||
let mut user_detail_list = array![];
|
||||
@@ -272,8 +255,7 @@ async fn detail(req: HttpRequest, body: String) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn sif(req: HttpRequest) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), "");
|
||||
async fn sif(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
let mut user = userdata::get_acc(&key);
|
||||
let mut cards = userdata::get_acc_sif(&key);
|
||||
|
||||
@@ -291,7 +273,7 @@ async fn sif(req: HttpRequest) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn sifas_migrate(req: HttpRequest, _body: String) -> impl Responder {
|
||||
async fn sifas_migrate(req: HttpRequest) -> impl Responder {
|
||||
global::api(&req, Some(object!{
|
||||
"ss_migrate_status": 1,
|
||||
"user": null,
|
||||
@@ -342,10 +324,8 @@ fn clean_sif_data(current: &JsonValue) -> JsonValue {
|
||||
rv
|
||||
}
|
||||
|
||||
async fn sif_migrate(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
async fn sif_migrate(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let mut user = userdata::get_acc(&key);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
|
||||
let id = generate_passcode_sha1(body["sif_user_id"].to_string(), body["password"].to_string());
|
||||
let user_info = npps4_req(id).await;
|
||||
@@ -373,7 +353,7 @@ async fn sif_migrate(req: HttpRequest, body: String) -> impl Responder {
|
||||
|
||||
}
|
||||
|
||||
async fn getregisteredplatformlist(req: HttpRequest, _body: String) -> impl Responder {
|
||||
async fn getregisteredplatformlist(req: HttpRequest) -> impl Responder {
|
||||
global::api(&req, Some(object!{
|
||||
"google": 0,
|
||||
"apple": 0,
|
||||
@@ -381,9 +361,7 @@ async fn getregisteredplatformlist(req: HttpRequest, _body: String) -> impl Resp
|
||||
}))
|
||||
}
|
||||
|
||||
async fn initialize(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn initialize(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
|
||||
let mut user = userdata::get_acc(&key);
|
||||
let mut user2 = userdata::get_acc_home(&key);
|
||||
|
||||
Reference in New Issue
Block a user