mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew
synced 2026-07-12 00:32:20 +08:00
Move from json crate to jzon (json is no longer maintained)
This commit is contained in:
8
Cargo.lock
generated
8
Cargo.lock
generated
@@ -691,7 +691,7 @@ dependencies = [
|
||||
"include-flate-codegen",
|
||||
"include_dir",
|
||||
"jni",
|
||||
"json",
|
||||
"jzon",
|
||||
"lazy_static",
|
||||
"libflate",
|
||||
"md5",
|
||||
@@ -1197,10 +1197,10 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "json"
|
||||
version = "0.12.4"
|
||||
name = "jzon"
|
||||
version = "0.12.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd"
|
||||
checksum = "17ab85f84ca42c5ec520e6f3c9966ba1fd62909ce260f8837e248857d2560509"
|
||||
|
||||
[[package]]
|
||||
name = "language-tags"
|
||||
|
||||
@@ -8,7 +8,6 @@ actix-web = "4.13"
|
||||
rusqlite = { version = "0.38.0", features = ["bundled"] }
|
||||
clap = { version = "4.5.59", features = ["derive"]}
|
||||
base64 = "0.22.1"
|
||||
json = "0.12.4"
|
||||
rand = "0.10.0"
|
||||
lazy_static = "1.5.0"
|
||||
hex = "0.4.3"
|
||||
@@ -29,6 +28,7 @@ pem = "3.0.6"
|
||||
ureq = "3.2.0"
|
||||
mime_guess = "2.0.5"
|
||||
include_dir = "0.7.4"
|
||||
jzon = "0.12.5"
|
||||
|
||||
[target.aarch64-linux-android.dependencies]
|
||||
jni = { version = "0.21.0", features = ["invocation", "default"], optional = true }
|
||||
|
||||
@@ -34,7 +34,7 @@ use actix_web::{
|
||||
http::header::HeaderValue,
|
||||
http::header::HeaderMap
|
||||
};
|
||||
use json::{JsonValue, object};
|
||||
use jzon::{JsonValue, object};
|
||||
use crate::encryption;
|
||||
|
||||
fn unhandled(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{object, array, JsonValue};
|
||||
use jzon::{object, array, JsonValue};
|
||||
use actix_web::{HttpRequest};
|
||||
|
||||
use crate::router::{userdata, global, items, databases};
|
||||
@@ -54,7 +54,7 @@ fn do_reinforce(user: &mut JsonValue, body: &JsonValue, exp_id: &str, money_mult
|
||||
|
||||
pub fn reinforce(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let mut user = userdata::get_acc(&key);
|
||||
let mut clear_mission_ids = array![];
|
||||
|
||||
@@ -72,7 +72,7 @@ pub fn reinforce(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
|
||||
pub fn skill_reinforce(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let mut user = userdata::get_acc(&key);
|
||||
let mut clear_mission_ids = array![];
|
||||
|
||||
@@ -90,7 +90,7 @@ pub fn skill_reinforce(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
|
||||
pub fn evolve(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let mut user = userdata::get_acc(&key);
|
||||
let mut chats = userdata::get_acc_chats(&key);
|
||||
let mut missions = userdata::get_acc_missions(&key);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{object, array, JsonValue};
|
||||
use jzon::{object, array, JsonValue};
|
||||
use actix_web::{HttpRequest};
|
||||
|
||||
use crate::router::{global, items, userdata, databases};
|
||||
@@ -52,7 +52,7 @@ pub fn start(_req: HttpRequest, _body: String) -> Option<JsonValue> {
|
||||
|
||||
pub fn end(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let mut missions = userdata::get_acc_missions(&key);
|
||||
let mut chats = userdata::get_acc_chats(&key);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{object, array, JsonValue};
|
||||
use jzon::{object, array, JsonValue};
|
||||
use actix_web::{HttpRequest, HttpResponse, http::header::ContentType};
|
||||
use rusqlite::params;
|
||||
use std::sync::Mutex;
|
||||
@@ -74,7 +74,7 @@ fn update_live_score(id: i64, uid: i64, score: i64) {
|
||||
}
|
||||
|
||||
let info = DATABASE.lock_and_select("SELECT score_data FROM scores WHERE live_id=?1", params!(id)).unwrap_or(String::from("[]"));
|
||||
let scores = json::parse(&info).unwrap();
|
||||
let scores = jzon::parse(&info).unwrap();
|
||||
|
||||
let mut result = array![];
|
||||
let mut current = 0;
|
||||
@@ -110,9 +110,9 @@ fn update_live_score(id: i64, uid: i64, score: i64) {
|
||||
|
||||
if added {
|
||||
if DATABASE.lock_and_select("SELECT live_id FROM scores WHERE live_id=?1", params!(id)).is_ok() {
|
||||
DATABASE.lock_and_exec("UPDATE scores SET score_data=?1 WHERE live_id=?2", params!(json::stringify(result), id));
|
||||
DATABASE.lock_and_exec("UPDATE scores SET score_data=?1 WHERE live_id=?2", params!(jzon::stringify(result), id));
|
||||
} else {
|
||||
DATABASE.lock_and_exec("INSERT INTO scores (score_data, live_id) VALUES (?1, ?2)", params!(json::stringify(result), id));
|
||||
DATABASE.lock_and_exec("INSERT INTO scores (score_data, live_id) VALUES (?1, ?2)", params!(jzon::stringify(result), id));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,11 +225,11 @@ pub async fn clearrate(_req: HttpRequest) -> Option<JsonValue> {
|
||||
}
|
||||
|
||||
pub fn ranking(_req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let live = body["master_live_id"].as_i64().unwrap();
|
||||
|
||||
let info = DATABASE.lock_and_select("SELECT score_data FROM scores WHERE live_id=?1", params!(live)).unwrap_or(String::from("[]"));
|
||||
let scores = json::parse(&info).unwrap();
|
||||
let scores = jzon::parse(&info).unwrap();
|
||||
|
||||
let mut rank = array![];
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{array, object, JsonValue};
|
||||
use jzon::{array, object, JsonValue};
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
use crate::include_file;
|
||||
@@ -6,7 +6,7 @@ use crate::include_file;
|
||||
lazy_static! {
|
||||
pub static ref STORY: JsonValue = {
|
||||
let mut info = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/story_part.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/story_part.json")).unwrap();
|
||||
for data in items.members() {
|
||||
info[data["id"].to_string()] = data.clone();
|
||||
}
|
||||
@@ -14,7 +14,7 @@ lazy_static! {
|
||||
};
|
||||
pub static ref LOGIN_REWARDS: JsonValue = {
|
||||
let mut info = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/login_bonus_reward.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/login_bonus_reward.json")).unwrap();
|
||||
for data in items.members() {
|
||||
info[data["id"].to_string()] = data.clone();
|
||||
}
|
||||
@@ -22,7 +22,7 @@ lazy_static! {
|
||||
};
|
||||
pub static ref SHOP_INFO: JsonValue = {
|
||||
let mut info = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/shop_item.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/shop_item.json")).unwrap();
|
||||
for data in items.members() {
|
||||
info[data["id"].to_string()] = data.clone();
|
||||
}
|
||||
@@ -30,7 +30,7 @@ lazy_static! {
|
||||
};
|
||||
pub static ref CHATS: JsonValue = {
|
||||
let mut chats = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/chat_room.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/chat_room.json")).unwrap();
|
||||
for data in items.members() {
|
||||
if chats[data["masterChatId"].to_string()].is_null() {
|
||||
chats[data["masterChatId"].to_string()] = object!{};
|
||||
@@ -41,7 +41,7 @@ lazy_static! {
|
||||
};
|
||||
pub static ref CHAPTERS: JsonValue = {
|
||||
let mut chats = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/chat_chapter.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/chat_chapter.json")).unwrap();
|
||||
for data in items.members() {
|
||||
if chats[data["masterChatId"].to_string()].is_null() {
|
||||
chats[data["masterChatId"].to_string()] = object!{};
|
||||
@@ -52,7 +52,7 @@ lazy_static! {
|
||||
};
|
||||
pub static ref CHAPTERS_MASTER: JsonValue = {
|
||||
let mut chats = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/chat_chapter.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/chat_chapter.json")).unwrap();
|
||||
for data in items.members() {
|
||||
chats[data["chapterId"].to_string()] = data.clone();
|
||||
}
|
||||
@@ -60,7 +60,7 @@ lazy_static! {
|
||||
};
|
||||
pub static ref EXCHANGE_LIST: JsonValue = {
|
||||
let mut info = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/exchange_item.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/exchange_item.json")).unwrap();
|
||||
for data in items.members() {
|
||||
info[data["id"].to_string()] = data.clone();
|
||||
}
|
||||
@@ -68,7 +68,7 @@ lazy_static! {
|
||||
};
|
||||
pub static ref EXCHANGE_REWARD: JsonValue = {
|
||||
let mut info = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/exchange_item_reward.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/exchange_item_reward.json")).unwrap();
|
||||
for data in items.members() {
|
||||
info[data["id"].to_string()] = data.clone();
|
||||
}
|
||||
@@ -76,21 +76,21 @@ lazy_static! {
|
||||
};
|
||||
pub static ref LIVE_LIST: JsonValue = {
|
||||
let mut info = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/live.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/live.json")).unwrap();
|
||||
for data in items.members() {
|
||||
info[data["id"].to_string()] = data.clone();
|
||||
}
|
||||
info
|
||||
};
|
||||
pub static ref LIVES: JsonValue = {
|
||||
json::parse(&include_file!("src/router/databases/json/live.json")).unwrap()
|
||||
jzon::parse(&include_file!("src/router/databases/json/live.json")).unwrap()
|
||||
};
|
||||
pub static ref MISSION_DATA: JsonValue = {
|
||||
json::parse(&include_file!("src/router/databases/json/live_mission.json")).unwrap()
|
||||
jzon::parse(&include_file!("src/router/databases/json/live_mission.json")).unwrap()
|
||||
};
|
||||
pub static ref MISSION_COMBO_DATA: JsonValue = {
|
||||
let mut info = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/live_mission_combo.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/live_mission_combo.json")).unwrap();
|
||||
for data in items.members() {
|
||||
info[data["masterMusicId"].to_string()] = data.clone();
|
||||
}
|
||||
@@ -98,7 +98,7 @@ lazy_static! {
|
||||
};
|
||||
pub static ref MISSION_REWARD_DATA: JsonValue = {
|
||||
let mut info = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/live_mission_reward.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/live_mission_reward.json")).unwrap();
|
||||
for data in items.members() {
|
||||
info[data["id"].to_string()] = data.clone();
|
||||
}
|
||||
@@ -106,7 +106,7 @@ lazy_static! {
|
||||
};
|
||||
pub static ref CARD_LIST: JsonValue = {
|
||||
let mut info = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/card.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/card.json")).unwrap();
|
||||
for data in items.members() {
|
||||
info[data["id"].to_string()] = data.clone();
|
||||
}
|
||||
@@ -114,7 +114,7 @@ lazy_static! {
|
||||
};
|
||||
pub static ref LOTTERY_INFO: JsonValue = {
|
||||
let mut info = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/login_bonus.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/login_bonus.json")).unwrap();
|
||||
for data in items.members() {
|
||||
if info[data["id"].to_string()].is_null() {
|
||||
info[data["id"].to_string()] = object!{
|
||||
@@ -123,7 +123,7 @@ lazy_static! {
|
||||
};
|
||||
}
|
||||
}
|
||||
let days = json::parse(&include_file!("src/router/databases/json/login_bonus_reward_setting.json")).unwrap();
|
||||
let days = jzon::parse(&include_file!("src/router/databases/json/login_bonus_reward_setting.json")).unwrap();
|
||||
for data in days.members() {
|
||||
if info[data["masterLoginBonusId"].to_string()].is_null() {
|
||||
continue;
|
||||
@@ -138,8 +138,8 @@ lazy_static! {
|
||||
};
|
||||
pub static ref CARDS: JsonValue = {
|
||||
let mut cardz = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/lottery_item.json")).unwrap();
|
||||
let items_global = json::parse(&include_file!("src/router/databases/json/global/lottery_item.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/lottery_item.json")).unwrap();
|
||||
let items_global = jzon::parse(&include_file!("src/router/databases/json/global/lottery_item.json")).unwrap();
|
||||
for data in items.members() {
|
||||
if cardz[data["id"].to_string()].is_null() {
|
||||
cardz[data["id"].to_string()] = object!{};
|
||||
@@ -159,8 +159,8 @@ lazy_static! {
|
||||
pub static ref POOL: JsonValue = {
|
||||
let mut cardz = object!{};
|
||||
let mut i2 = array![];
|
||||
let items = json::parse(&include_file!("src/router/databases/json/lottery_item.json")).unwrap();
|
||||
let items_global = json::parse(&include_file!("src/router/databases/json/global/lottery_item.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/lottery_item.json")).unwrap();
|
||||
let items_global = jzon::parse(&include_file!("src/router/databases/json/global/lottery_item.json")).unwrap();
|
||||
for data in items.members() {
|
||||
if cardz[data["id"].to_string()].is_null() {
|
||||
cardz[data["id"].to_string()] = array![];
|
||||
@@ -182,8 +182,8 @@ lazy_static! {
|
||||
pub static ref RARITY: JsonValue = {
|
||||
let mut cardz = object!{};
|
||||
let mut i2 = array![];
|
||||
let items = json::parse(&include_file!("src/router/databases/json/lottery_rarity.json")).unwrap();
|
||||
let items_global = json::parse(&include_file!("src/router/databases/json/global/lottery_rarity.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/lottery_rarity.json")).unwrap();
|
||||
let items_global = jzon::parse(&include_file!("src/router/databases/json/global/lottery_rarity.json")).unwrap();
|
||||
for data in items.members() {
|
||||
if cardz[data["id"].to_string()].is_null() {
|
||||
cardz[data["id"].to_string()] = array![];
|
||||
@@ -204,8 +204,8 @@ lazy_static! {
|
||||
};
|
||||
pub static ref LOTTERY: JsonValue = {
|
||||
let mut cardz = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/lottery.json")).unwrap();
|
||||
let items_global = json::parse(&include_file!("src/router/databases/json/global/lottery.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/lottery.json")).unwrap();
|
||||
let items_global = jzon::parse(&include_file!("src/router/databases/json/global/lottery.json")).unwrap();
|
||||
for data in items.members() {
|
||||
cardz[data["id"].to_string()] = data.clone();
|
||||
}
|
||||
@@ -218,8 +218,8 @@ lazy_static! {
|
||||
};
|
||||
pub static ref PRICE: JsonValue = {
|
||||
let mut cardz = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/lottery_price.json")).unwrap();
|
||||
let items_global = json::parse(&include_file!("src/router/databases/json/global/lottery_price.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/lottery_price.json")).unwrap();
|
||||
let items_global = jzon::parse(&include_file!("src/router/databases/json/global/lottery_price.json")).unwrap();
|
||||
for data in items.members() {
|
||||
if cardz[data["id"].to_string()].is_null() {
|
||||
cardz[data["id"].to_string()] = object!{};
|
||||
@@ -238,7 +238,7 @@ lazy_static! {
|
||||
};
|
||||
pub static ref MISSION_LIST: JsonValue = {
|
||||
let mut info = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/mission.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/mission.json")).unwrap();
|
||||
for data in items.members() {
|
||||
info[data["id"].to_string()] = data.clone();
|
||||
}
|
||||
@@ -246,7 +246,7 @@ lazy_static! {
|
||||
};
|
||||
pub static ref CHARACTER_CHATS: JsonValue = {
|
||||
let mut info = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/mission.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/mission.json")).unwrap();
|
||||
for data in items.members() {
|
||||
if data["conditionValues"].len() != 1 || (data["conditionType"] != 50 && data["conditionType"] != 51) {
|
||||
continue;
|
||||
@@ -260,7 +260,7 @@ lazy_static! {
|
||||
};
|
||||
pub static ref MISSION_REWARD: JsonValue = {
|
||||
let mut info = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/mission_reward.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/mission_reward.json")).unwrap();
|
||||
for data in items.members() {
|
||||
info[data["id"].to_string()] = data.clone();
|
||||
}
|
||||
@@ -268,7 +268,7 @@ lazy_static! {
|
||||
};
|
||||
pub static ref ITEM_INFO: JsonValue = {
|
||||
let mut info = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/item.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/item.json")).unwrap();
|
||||
for data in items.members() {
|
||||
info[data["id"].to_string()] = data.clone();
|
||||
}
|
||||
@@ -276,7 +276,7 @@ lazy_static! {
|
||||
};
|
||||
pub static ref MUSIC: JsonValue = {
|
||||
let mut info = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/music.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/music.json")).unwrap();
|
||||
for live in LIVE_LIST.entries() {
|
||||
info[live.1["id"].to_string()] = loop {
|
||||
let mut val = object!{};
|
||||
@@ -293,7 +293,7 @@ lazy_static! {
|
||||
};
|
||||
pub static ref MUSIC_EN: JsonValue = {
|
||||
let mut info = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/global/music.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/global/music.json")).unwrap();
|
||||
for live in LIVE_LIST.entries() {
|
||||
info[live.1["id"].to_string()] = loop {
|
||||
let mut val = object!{};
|
||||
@@ -309,11 +309,11 @@ lazy_static! {
|
||||
info
|
||||
};
|
||||
pub static ref RANKS: JsonValue = {
|
||||
json::parse(&include_file!("src/router/databases/json/user_rank.json")).unwrap()
|
||||
jzon::parse(&include_file!("src/router/databases/json/user_rank.json")).unwrap()
|
||||
};
|
||||
pub static ref EVOLVE_COST: JsonValue = {
|
||||
let mut info = object!{};
|
||||
let items = json::parse(&include_file!("src/router/databases/json/card_evolve.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/databases/json/card_evolve.json")).unwrap();
|
||||
for data in items.members() {
|
||||
info[data["rarity"].to_string()] = data["price"].clone();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use json::{JsonValue, object};
|
||||
use jzon::{JsonValue, object};
|
||||
use actix_web::{HttpRequest};
|
||||
|
||||
use crate::encryption;
|
||||
|
||||
pub fn error(_req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
|
||||
println!("client error: {}", body["code"]);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{JsonValue, object, array};
|
||||
use jzon::{JsonValue, object, array};
|
||||
use actix_web::HttpRequest;
|
||||
use rand::RngExt;
|
||||
|
||||
@@ -20,7 +20,7 @@ fn get_event_data(key: &str, event_id: u32) -> JsonValue {
|
||||
}
|
||||
|
||||
if event[event_id.to_string()].is_empty() {
|
||||
event[event_id.to_string()] = json::parse(&include_file!("src/router/userdata/new_user_event.json")).unwrap();
|
||||
event[event_id.to_string()] = jzon::parse(&include_file!("src/router/userdata/new_user_event.json")).unwrap();
|
||||
if is_star_event {
|
||||
let mut ev = event[event_id.to_string()].clone();
|
||||
init_star_event(&mut ev);
|
||||
@@ -101,7 +101,7 @@ pub fn event(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
|
||||
let body = &encryption::decrypt_packet(&body).unwrap();
|
||||
let body = json::parse(&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);
|
||||
@@ -150,7 +150,7 @@ pub fn star_event(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let user = userdata::get_acc(&key);
|
||||
|
||||
let body = &encryption::decrypt_packet(&body).unwrap();
|
||||
let body = json::parse(&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);
|
||||
@@ -174,7 +174,7 @@ pub fn change_target_music(req: HttpRequest, body: String) -> Option<JsonValue>
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
|
||||
let body = &encryption::decrypt_packet(&body).unwrap();
|
||||
let body = json::parse(&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);
|
||||
@@ -192,7 +192,7 @@ pub fn set_member(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
|
||||
let body = &encryption::decrypt_packet(&body).unwrap();
|
||||
let body = json::parse(&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);
|
||||
@@ -225,7 +225,7 @@ fn get_rank(event: u32, user_id: u64) -> u32 {
|
||||
|
||||
pub async fn ranking(_req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let body = &encryption::decrypt_packet(&body).unwrap();
|
||||
let body = json::parse(&body).unwrap();
|
||||
let body = jzon::parse(&body).unwrap();
|
||||
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![];
|
||||
@@ -289,7 +289,7 @@ fn get_points(event_id: u32, user: &JsonValue) -> i64 {
|
||||
|
||||
pub fn event_live(req: HttpRequest, body: String, skipped: bool) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body_temp = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body_temp = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let event_id = if skipped {
|
||||
body_temp["master_event_id"].as_u32().unwrap()
|
||||
} else {
|
||||
@@ -298,7 +298,7 @@ pub fn event_live(req: HttpRequest, body: String, skipped: bool) -> Option<JsonV
|
||||
|
||||
let mut resp = crate::router::live::live_end(&req, &body, skipped);
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let mut event = get_event_data(&key, event_id);
|
||||
let mut user = userdata::get_acc(&key);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{object, array, JsonValue};
|
||||
use jzon::{object, array, JsonValue};
|
||||
use rusqlite::params;
|
||||
use std::sync::Mutex;
|
||||
use lazy_static::lazy_static;
|
||||
@@ -24,7 +24,7 @@ pub fn live_completed(event_id: u32, uid: i64, score: i64, star_level: i64) {
|
||||
}
|
||||
|
||||
let info = DATABASE.lock_and_select("SELECT score_data FROM scores WHERE event_id=?1", params!(event_id)).unwrap_or(String::from("[]"));
|
||||
let scores = json::parse(&info).unwrap();
|
||||
let scores = jzon::parse(&info).unwrap();
|
||||
|
||||
let mut result = array![];
|
||||
let mut current = 0;
|
||||
@@ -60,16 +60,16 @@ pub fn live_completed(event_id: u32, uid: i64, score: i64, star_level: i64) {
|
||||
|
||||
if added {
|
||||
if DATABASE.lock_and_select("SELECT score_data FROM scores WHERE event_id=?1", params!(event_id)).is_ok() {
|
||||
DATABASE.lock_and_exec("UPDATE scores SET score_data=?1 WHERE event_id=?2", params!(json::stringify(result), event_id));
|
||||
DATABASE.lock_and_exec("UPDATE scores SET score_data=?1 WHERE event_id=?2", params!(jzon::stringify(result), event_id));
|
||||
} else {
|
||||
DATABASE.lock_and_exec("INSERT INTO scores (score_data, event_id) VALUES (?1, ?2)", params!(json::stringify(result), event_id));
|
||||
DATABASE.lock_and_exec("INSERT INTO scores (score_data, event_id) VALUES (?1, ?2)", params!(jzon::stringify(result), event_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_raw_info(event: u32) -> JsonValue {
|
||||
let info = DATABASE.lock_and_select("SELECT score_data FROM scores WHERE event_id=?1", params!(event)).unwrap_or(String::from("[]"));
|
||||
json::parse(&info).unwrap()
|
||||
jzon::parse(&info).unwrap()
|
||||
}
|
||||
|
||||
fn get_json() -> JsonValue {
|
||||
@@ -77,7 +77,7 @@ fn get_json() -> JsonValue {
|
||||
let mut rv = object!{};
|
||||
for event in events.members() {
|
||||
rv[event.to_string()] = array![];
|
||||
let scores = json::parse(&DATABASE.lock_and_select("SELECT score_data FROM scores WHERE event_id=?1", params!(event.as_i64().unwrap())).unwrap()).unwrap();
|
||||
let scores = jzon::parse(&DATABASE.lock_and_select("SELECT score_data FROM scores WHERE event_id=?1", params!(event.as_i64().unwrap())).unwrap()).unwrap();
|
||||
|
||||
let mut i = 1;
|
||||
for score in scores.members() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{object, array, JsonValue};
|
||||
use jzon::{object, array, JsonValue};
|
||||
use actix_web::{HttpRequest};
|
||||
|
||||
use crate::router::{global, userdata, items, databases};
|
||||
@@ -10,7 +10,7 @@ pub fn exchange(_req: HttpRequest) -> Option<JsonValue> {
|
||||
|
||||
pub fn exchange_post(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let mut user = userdata::get_acc(&key);
|
||||
let mut missions = userdata::get_acc_missions(&key);
|
||||
let mut chats = userdata::get_acc_chats(&key);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{object, array, JsonValue};
|
||||
use jzon::{object, array, JsonValue};
|
||||
use actix_web::{HttpRequest};
|
||||
|
||||
use crate::router::{userdata, global};
|
||||
@@ -8,7 +8,7 @@ pub const FRIEND_LIMIT: usize = 40;
|
||||
|
||||
pub fn friend(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let user_id = userdata::get_acc(&key)["user"]["id"].as_i64().unwrap();
|
||||
let friends = userdata::get_acc_friends(&key);
|
||||
|
||||
@@ -70,7 +70,7 @@ pub fn recommend(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
|
||||
pub fn search(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let friends = userdata::get_acc_friends(&key);
|
||||
|
||||
let uid = body["user_id"].as_i64().unwrap();
|
||||
@@ -81,7 +81,7 @@ pub fn search(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
|
||||
pub fn request(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let user_id = userdata::get_acc(&key)["user"]["id"].as_i64().unwrap();
|
||||
let mut friends = userdata::get_acc_friends(&key);
|
||||
|
||||
@@ -99,7 +99,7 @@ pub fn request(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
|
||||
pub fn approve(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let user_id = userdata::get_acc(&key)["user"]["id"].as_i64().unwrap();
|
||||
let mut friends = userdata::get_acc_friends(&key);
|
||||
|
||||
@@ -120,7 +120,7 @@ pub fn approve(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
|
||||
pub fn cancel(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let user_id = userdata::get_acc(&key)["user"]["id"].as_i64().unwrap();
|
||||
let mut friends = userdata::get_acc_friends(&key);
|
||||
|
||||
@@ -137,7 +137,7 @@ pub fn cancel(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
|
||||
pub fn delete(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let user_id = userdata::get_acc(&key)["user"]["id"].as_i64().unwrap();
|
||||
let mut friends = userdata::get_acc_friends(&key);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{array, object, JsonValue};
|
||||
use jzon::{array, object, JsonValue};
|
||||
use actix_web::{
|
||||
HttpResponse,
|
||||
http::header::{HeaderValue, HeaderMap}
|
||||
@@ -168,14 +168,14 @@ pub fn set_time(current_time: u64, uid: i64, max: bool) -> u64 {
|
||||
}
|
||||
|
||||
pub fn send(mut data: JsonValue, uid: i64, headers: &HeaderMap) -> HttpResponse {
|
||||
//println!("{}", json::stringify(data.clone()));
|
||||
//println!("{}", jzon::stringify(data.clone()));
|
||||
data["server_time"] = set_time(data["server_time"].as_u64().unwrap_or(0), uid, true).into();
|
||||
|
||||
if !data["data"]["item_list"].is_empty() || !data["data"]["updated_value_list"]["item_list"].is_empty() {
|
||||
items::check_for_region(&mut data, headers);
|
||||
}
|
||||
|
||||
let encrypted = encryption::encrypt_packet(&json::stringify(data)).unwrap();
|
||||
let encrypted = encryption::encrypt_packet(&jzon::stringify(data)).unwrap();
|
||||
let resp = encrypted.into_bytes();
|
||||
|
||||
HttpResponse::Ok().body(resp)
|
||||
|
||||
@@ -3,7 +3,7 @@ use base64::{Engine as _, engine::general_purpose};
|
||||
use std::collections::HashMap;
|
||||
use sha1::Sha1;
|
||||
use substring::Substring;
|
||||
use json::{object, JsonValue};
|
||||
use jzon::{object, JsonValue};
|
||||
use hmac::{Hmac, Mac};
|
||||
use rusqlite::params;
|
||||
use lazy_static::lazy_static;
|
||||
@@ -125,7 +125,7 @@ fn send(req: HttpRequest, resp: JsonValue) -> HttpResponse {
|
||||
.insert_header(("Cache-Control", "must-revalidate, no-cache, no-store, private"))
|
||||
.insert_header(("Vary", "Authorization,Accept-Encoding"))
|
||||
.insert_header(("X-GREE-Authorization", gree_authorize(&req)))
|
||||
.body(json::stringify(resp))
|
||||
.body(jzon::stringify(resp))
|
||||
}
|
||||
|
||||
pub fn not_found() -> HttpResponse {
|
||||
@@ -139,11 +139,11 @@ pub fn not_found() -> HttpResponse {
|
||||
.insert_header(("Expires", "-1"))
|
||||
.insert_header(("Pragma", "no-cache"))
|
||||
.insert_header(("Cache-Control", "must-revalidate, no-cache, no-store, private"))
|
||||
.body(json::stringify(resp))
|
||||
.body(jzon::stringify(resp))
|
||||
}
|
||||
|
||||
pub fn initialize(req: HttpRequest, body: String) -> HttpResponse {
|
||||
let body = json::parse(&body).unwrap();
|
||||
let body = jzon::parse(&body).unwrap();
|
||||
let token = create_acc(&body["token"].to_string());
|
||||
|
||||
let app_id = "232610769078541";
|
||||
@@ -227,7 +227,7 @@ pub fn payment_ticket(req: HttpRequest) -> HttpResponse {
|
||||
}
|
||||
|
||||
pub fn migration_verify(req: HttpRequest, body: String) -> HttpResponse {
|
||||
let body = json::parse(&body).unwrap();
|
||||
let body = jzon::parse(&body).unwrap();
|
||||
let password = decrypt_transfer_password(&body["migration_password"].to_string());
|
||||
|
||||
let user = userdata::user::migration::get_acc_transfer(&body["migration_code"].to_string(), &password);
|
||||
@@ -254,7 +254,7 @@ pub fn migration_verify(req: HttpRequest, body: String) -> HttpResponse {
|
||||
}
|
||||
|
||||
pub fn migration(req: HttpRequest, body: String) -> HttpResponse {
|
||||
let body = json::parse(&body).unwrap();
|
||||
let body = jzon::parse(&body).unwrap();
|
||||
|
||||
let user = userdata::get_acc(&body["src_uuid"].to_string());
|
||||
//clear old token
|
||||
@@ -320,7 +320,7 @@ pub fn migration_code(req: HttpRequest) -> HttpResponse {
|
||||
}
|
||||
|
||||
pub fn migration_password_register(req: HttpRequest, body: String) -> HttpResponse {
|
||||
let body = json::parse(&body).unwrap();
|
||||
let body = jzon::parse(&body).unwrap();
|
||||
let mut uid = String::new();
|
||||
let blank_header = HeaderValue::from_static("");
|
||||
let auth_header = req.headers().get("Authorization").unwrap_or(&blank_header).to_str().unwrap_or("");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{object, array, JsonValue};
|
||||
use jzon::{object, array, JsonValue};
|
||||
use actix_web::{HttpRequest};
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::encryption;
|
||||
|
||||
pub fn preset(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let mut user = userdata::get_acc_home(&key);
|
||||
|
||||
for data in user["home"]["preset_setting"].members_mut() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{array, object, JsonValue};
|
||||
use jzon::{array, object, JsonValue};
|
||||
use rand::RngExt;
|
||||
use actix_web::{HttpRequest, http::header::{HeaderMap, HeaderValue}};
|
||||
use crate::encryption;
|
||||
@@ -513,7 +513,7 @@ pub fn completed_daily_mission(id: i64, missions: &mut JsonValue) -> JsonValue {
|
||||
|
||||
pub fn use_item_req(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let mut user = userdata::get_acc(&key);
|
||||
|
||||
let item = &databases::ITEM_INFO[body["id"].to_string()];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{object, array, JsonValue};
|
||||
use jzon::{object, array, JsonValue};
|
||||
use actix_web::{HttpRequest};
|
||||
use rand::RngExt;
|
||||
use lazy_static::lazy_static;
|
||||
@@ -9,7 +9,7 @@ use crate::router::clear_rate::live_completed;
|
||||
|
||||
pub fn retire(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
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);
|
||||
@@ -238,7 +238,7 @@ fn start_live(login_token: &str, body: &JsonValue) {
|
||||
|
||||
pub fn start(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
start_live(&key, &body);
|
||||
Some(array![])
|
||||
}
|
||||
@@ -532,7 +532,7 @@ fn get_live_character_list(lp_used: i32, deck_id: i32, user: &JsonValue, mission
|
||||
|
||||
pub fn live_end(req: &HttpRequest, body: &str, skipped: bool) -> JsonValue {
|
||||
let key = global::get_login(req.headers(), body);
|
||||
let body = json::parse(&encryption::decrypt_packet(body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(body).unwrap()).unwrap();
|
||||
let user2 = userdata::get_acc_home(&key);
|
||||
let mut user = userdata::get_acc(&key);
|
||||
let mut user_missions = userdata::get_acc_missions(&key);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{object, JsonValue};
|
||||
use jzon::{object, JsonValue};
|
||||
use actix_web::{HttpRequest};
|
||||
|
||||
pub fn location(_req: HttpRequest) -> Option<JsonValue> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{object, array, JsonValue};
|
||||
use jzon::{object, array, JsonValue};
|
||||
use actix_web::{HttpRequest};
|
||||
|
||||
use crate::router::{global, userdata, items, databases};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{array, object, JsonValue};
|
||||
use jzon::{array, object, JsonValue};
|
||||
use actix_web::{HttpRequest};
|
||||
use rand::RngExt;
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::router::{global, userdata, items, databases};
|
||||
use crate::encryption;
|
||||
|
||||
pub fn tutorial(_req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
|
||||
let id = body["master_character_id"].to_string();
|
||||
let user = &id[id.len() - 2..].parse::<i32>().unwrap();
|
||||
@@ -101,7 +101,7 @@ pub fn lottery(_req: HttpRequest) -> Option<JsonValue> {
|
||||
|
||||
pub fn lottery_post(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
//println!("lottery: {}", body);
|
||||
let mut user = userdata::get_acc(&key);
|
||||
let user2 = userdata::get_acc(&key);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{array, object, JsonValue};
|
||||
use jzon::{array, object, JsonValue};
|
||||
use actix_web::{HttpRequest};
|
||||
|
||||
use crate::router::{global, userdata, items, databases};
|
||||
@@ -17,7 +17,7 @@ pub fn clear(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
|
||||
let mut missions = userdata::get_acc_missions(&key);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
|
||||
for id in body["master_mission_ids"].members() {
|
||||
items::update_mission_status(id.as_i64().unwrap(), 0, true, true, 1, &mut missions);
|
||||
@@ -32,7 +32,7 @@ pub fn clear(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
|
||||
pub fn receive(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
|
||||
let mut missions = userdata::get_acc_missions(&key);
|
||||
let mut user = userdata::get_acc(&key);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{object, array, JsonValue};
|
||||
use jzon::{object, array, JsonValue};
|
||||
use actix_web::{HttpRequest};
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{object, JsonValue};
|
||||
use jzon::{object, JsonValue};
|
||||
use actix_web::{HttpRequest};
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{array, object, JsonValue};
|
||||
use jzon::{array, object, JsonValue};
|
||||
use actix_web::{HttpRequest};
|
||||
|
||||
use crate::router::{global, userdata, items};
|
||||
@@ -12,7 +12,7 @@ pub fn events(_req: HttpRequest) -> Option<JsonValue> {
|
||||
|
||||
pub fn serial_code(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let mut user = userdata::get_acc_home(&key);
|
||||
|
||||
let mut itemz = array![];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{object, JsonValue};
|
||||
use jzon::{object, JsonValue};
|
||||
use actix_web::{HttpRequest};
|
||||
|
||||
use crate::router::{userdata, global, items, databases};
|
||||
@@ -15,7 +15,7 @@ pub fn shop(req: HttpRequest) -> Option<JsonValue> {
|
||||
|
||||
pub fn buy(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let mut user = userdata::get_acc(&key);
|
||||
let user_home = userdata::get_acc_home(&key);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{JsonValue, object};
|
||||
use jzon::{JsonValue, object};
|
||||
use actix_web::{HttpRequest, http::header::HeaderValue};
|
||||
|
||||
use crate::encryption;
|
||||
@@ -17,7 +17,7 @@ fn get_asset_hash(req: &HttpRequest, body: &JsonValue) -> String {
|
||||
}
|
||||
|
||||
pub fn asset_hash(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
|
||||
Some(object!{
|
||||
"asset_hash": get_asset_hash(&req, &body)
|
||||
@@ -26,7 +26,7 @@ pub fn asset_hash(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
|
||||
pub fn start(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let mut user = userdata::get_acc(&key);
|
||||
|
||||
println!("Signin from uid: {}", user["user"]["id"].clone());
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{object, JsonValue};
|
||||
use jzon::{object, JsonValue};
|
||||
use actix_web::{HttpRequest};
|
||||
|
||||
use crate::encryption;
|
||||
@@ -6,7 +6,7 @@ use crate::router::{global, userdata, databases};
|
||||
|
||||
pub fn read(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
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,4 +1,4 @@
|
||||
use json::{array, JsonValue};
|
||||
use jzon::{array, JsonValue};
|
||||
use actix_web::{HttpRequest};
|
||||
|
||||
use crate::router::{userdata, global};
|
||||
@@ -6,7 +6,7 @@ use crate::encryption;
|
||||
|
||||
pub fn tutorial(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let mut user = userdata::get_acc(&key);
|
||||
|
||||
if user["tutorial_step"].as_i32().unwrap() < 130 {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use json::{array, object, JsonValue};
|
||||
use jzon::{array, object, JsonValue};
|
||||
use actix_web::{HttpRequest};
|
||||
use sha1::{Sha1, Digest};
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::include_file;
|
||||
|
||||
pub fn deck(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let mut user = userdata::get_acc(&key);
|
||||
|
||||
for (i, data) in user["deck_list"].clone().members().enumerate() {
|
||||
@@ -50,7 +50,7 @@ pub fn user(req: HttpRequest) -> Option<JsonValue> {
|
||||
|
||||
pub fn gift(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
|
||||
let mut user = userdata::get_acc_home(&key);
|
||||
let mut userr = userdata::get_acc(&key);
|
||||
@@ -108,7 +108,7 @@ pub fn gift(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
|
||||
pub fn user_post(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
|
||||
let mut user = userdata::get_acc(&key);
|
||||
|
||||
@@ -170,7 +170,7 @@ pub fn announcement(req: HttpRequest) -> Option<JsonValue> {
|
||||
}
|
||||
|
||||
pub fn get_migration_code(_req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
|
||||
let code = userdata::user::migration::get_acc_token(body["user_id"].as_i64()?);
|
||||
|
||||
@@ -181,7 +181,7 @@ pub fn get_migration_code(_req: HttpRequest, body: String) -> Option<JsonValue>
|
||||
|
||||
pub fn register_password(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
|
||||
let user = userdata::get_acc(&key);
|
||||
|
||||
@@ -191,7 +191,7 @@ pub fn register_password(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
}
|
||||
|
||||
pub fn verify_migration_code(_req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
|
||||
let user = userdata::user::migration::get_acc_transfer(&body["migrationCode"].to_string(), &body["pass"].to_string());
|
||||
|
||||
@@ -209,7 +209,7 @@ pub fn verify_migration_code(_req: HttpRequest, body: String) -> Option<JsonValu
|
||||
})
|
||||
}
|
||||
pub fn request_migration_code(_req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
|
||||
let user = userdata::user::migration::get_acc_transfer(&body["migrationCode"].to_string(), &body["pass"].to_string());
|
||||
|
||||
@@ -222,7 +222,7 @@ pub fn request_migration_code(_req: HttpRequest, body: String) -> Option<JsonVal
|
||||
})
|
||||
}
|
||||
pub fn migration(_req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
|
||||
let user = userdata::get_name_and_rank(body["user_id"].to_string().parse::<i64>().unwrap());
|
||||
|
||||
@@ -231,7 +231,7 @@ pub fn migration(_req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
|
||||
pub fn detail(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let friends = userdata::get_acc_friends(&key);
|
||||
|
||||
let mut user_detail_list = array![];
|
||||
@@ -252,7 +252,7 @@ pub fn sif(req: HttpRequest) -> Option<JsonValue> {
|
||||
|
||||
// prevent duplicate data in the database
|
||||
if user["user"]["sif_user_id"].as_i64().unwrap_or(0) == 111111111 {
|
||||
cards = json::parse(&include_file!("src/router/userdata/full_sif.json")).unwrap();
|
||||
cards = jzon::parse(&include_file!("src/router/userdata/full_sif.json")).unwrap();
|
||||
}
|
||||
|
||||
if items::give_gift_basic(8, 4293000525, 1, &mut user, &mut array![], &mut array![], &mut array![]) || items::give_gift_basic(8, 4293000521, 1, &mut user, &mut array![], &mut array![], &mut array![]) {
|
||||
@@ -300,7 +300,7 @@ async fn npps4_req(sha_id: String) -> Option<JsonValue> {
|
||||
.body_mut()
|
||||
.read_to_string().ok()?;
|
||||
|
||||
json::parse(&body).ok()
|
||||
jzon::parse(&body).ok()
|
||||
}
|
||||
|
||||
fn clean_sif_data(current: &JsonValue) -> JsonValue {
|
||||
@@ -318,7 +318,7 @@ fn clean_sif_data(current: &JsonValue) -> JsonValue {
|
||||
pub async fn sif_migrate(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let mut user = userdata::get_acc(&key);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
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;
|
||||
@@ -356,7 +356,7 @@ pub fn getregisteredplatformlist(_req: HttpRequest, _body: String) -> Option<Jso
|
||||
|
||||
pub fn initialize(req: HttpRequest, body: String) -> Option<JsonValue> {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
|
||||
let mut user = userdata::get_acc(&key);
|
||||
let mut user2 = userdata::get_acc_home(&key);
|
||||
|
||||
@@ -2,7 +2,7 @@ pub mod user;
|
||||
|
||||
use rusqlite::params;
|
||||
use lazy_static::lazy_static;
|
||||
use json::{JsonValue, array, object};
|
||||
use jzon::{JsonValue, array, object};
|
||||
use rand::RngExt;
|
||||
|
||||
use crate::router::global;
|
||||
@@ -13,7 +13,7 @@ use crate::include_file;
|
||||
lazy_static! {
|
||||
static ref DATABASE: SQLite = SQLite::new("userdata.db", setup_tables);
|
||||
static ref NEW_USER: JsonValue = {
|
||||
json::parse(&include_file!("src/router/userdata/new_user.json")).unwrap()
|
||||
jzon::parse(&include_file!("src/router/userdata/new_user.json")).unwrap()
|
||||
};
|
||||
}
|
||||
|
||||
@@ -107,13 +107,13 @@ fn generate_uid() -> i64 {
|
||||
}
|
||||
|
||||
fn add_user_to_database(uid: i64, user: JsonValue, user_home: JsonValue, user_missions: JsonValue, sif_cards: JsonValue) {
|
||||
let home = json::stringify(user_home.clone());
|
||||
let missions = json::stringify(user_missions.clone());
|
||||
let cards = json::stringify(sif_cards.clone());
|
||||
let home = jzon::stringify(user_home.clone());
|
||||
let missions = jzon::stringify(user_missions.clone());
|
||||
let cards = jzon::stringify(sif_cards.clone());
|
||||
|
||||
DATABASE.lock_and_exec("INSERT INTO userdata (user_id, userdata, friend_request_disabled) VALUES (?1, ?2, ?3)", params!(
|
||||
uid,
|
||||
json::stringify(user.clone()),
|
||||
jzon::stringify(user.clone()),
|
||||
user["user"]["friend_request_disabled"].as_i32().unwrap()
|
||||
));
|
||||
DATABASE.lock_and_exec("INSERT INTO userhome (user_id, userhome) VALUES (?1, ?2)", params!(
|
||||
@@ -218,7 +218,7 @@ fn get_data(auth_key: &str, row: &str) -> JsonValue {
|
||||
|
||||
let result = DATABASE.lock_and_select(&format!("SELECT {} FROM {} WHERE user_id=?1", row, row), params!(key));
|
||||
|
||||
json::parse(&result.unwrap()).unwrap()
|
||||
jzon::parse(&result.unwrap()).unwrap()
|
||||
}
|
||||
|
||||
pub fn get_acc(auth_key: &str) -> JsonValue {
|
||||
@@ -267,7 +267,7 @@ pub fn get_acc_eventlogin(auth_key: &str) -> JsonValue {
|
||||
pub fn save_data(auth_key: &str, row: &str, data: JsonValue) {
|
||||
let key = get_key(auth_key);
|
||||
|
||||
DATABASE.lock_and_exec(&format!("UPDATE {} SET {}=?1 WHERE user_id=?2", row, row), params!(json::stringify(data), key));
|
||||
DATABASE.lock_and_exec(&format!("UPDATE {} SET {}=?1 WHERE user_id=?2", row, row), params!(jzon::stringify(data), key));
|
||||
}
|
||||
|
||||
pub fn save_acc(auth_key: &str, data: JsonValue) {
|
||||
@@ -318,7 +318,7 @@ pub fn get_name_and_rank(uid: i64) -> JsonValue {
|
||||
}
|
||||
}
|
||||
let result = DATABASE.lock_and_select("SELECT userdata FROM userdata WHERE user_id=?1", params!(uid));
|
||||
let data = json::parse(&result.unwrap()).unwrap();
|
||||
let data = jzon::parse(&result.unwrap()).unwrap();
|
||||
|
||||
object!{
|
||||
user_name: data["user"]["name"].clone(),
|
||||
@@ -338,7 +338,7 @@ pub fn get_acc_from_uid(uid: i64) -> JsonValue {
|
||||
return object!{"error": true}
|
||||
}
|
||||
let result = DATABASE.lock_and_select("SELECT userdata FROM userdata WHERE user_id=?1", params!(uid));
|
||||
json::parse(&result.unwrap()).unwrap()
|
||||
jzon::parse(&result.unwrap()).unwrap()
|
||||
}
|
||||
|
||||
pub fn friend_request(uid: i64, requestor: i64) {
|
||||
@@ -348,10 +348,10 @@ pub fn friend_request(uid: i64, requestor: i64) {
|
||||
}
|
||||
let uid = get_uid(&login_token);
|
||||
let friends = DATABASE.lock_and_select("SELECT friends FROM friends WHERE user_id=?1", params!(uid));
|
||||
let mut friends = json::parse(&friends.unwrap()).unwrap();
|
||||
let mut friends = jzon::parse(&friends.unwrap()).unwrap();
|
||||
if !friends["pending_user_id_list"].contains(requestor) && friends["pending_user_id_list"].len() < crate::router::friend::FRIEND_LIMIT {
|
||||
friends["pending_user_id_list"].push(requestor).unwrap();
|
||||
DATABASE.lock_and_exec("UPDATE friends SET friends=?1 WHERE user_id=?2", params!(json::stringify(friends), uid));
|
||||
DATABASE.lock_and_exec("UPDATE friends SET friends=?1 WHERE user_id=?2", params!(jzon::stringify(friends), uid));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ pub fn friend_request_approve(uid: i64, requestor: i64, accepted: bool, key: &st
|
||||
}
|
||||
let uid = get_uid(&login_token);
|
||||
let friends = DATABASE.lock_and_select("SELECT friends FROM friends WHERE user_id=?1", params!(uid));
|
||||
let mut friends = json::parse(&friends.unwrap()).unwrap();
|
||||
let mut friends = jzon::parse(&friends.unwrap()).unwrap();
|
||||
let index = friends[key].members().position(|r| *r.to_string() == requestor.to_string());
|
||||
if index.is_some() {
|
||||
friends[key].array_remove(index.unwrap());
|
||||
@@ -374,7 +374,7 @@ pub fn friend_request_approve(uid: i64, requestor: i64, accepted: bool, key: &st
|
||||
if accepted && !friends["friend_user_id_list"].contains(requestor) && friends["friend_user_id_list"].len() < crate::router::friend::FRIEND_LIMIT {
|
||||
friends["friend_user_id_list"].push(requestor).unwrap();
|
||||
}
|
||||
DATABASE.lock_and_exec("UPDATE friends SET friends=?1 WHERE user_id=?2", params!(json::stringify(friends), uid));
|
||||
DATABASE.lock_and_exec("UPDATE friends SET friends=?1 WHERE user_id=?2", params!(jzon::stringify(friends), uid));
|
||||
}
|
||||
|
||||
pub fn friend_request_disabled(uid: i64) -> bool {
|
||||
@@ -384,7 +384,7 @@ pub fn friend_request_disabled(uid: i64) -> bool {
|
||||
}
|
||||
let uid = get_uid(&login_token);
|
||||
let user = DATABASE.lock_and_select("SELECT userdata FROM userdata WHERE user_id=?1", params!(uid));
|
||||
let user = json::parse(&user.unwrap()).unwrap();
|
||||
let user = jzon::parse(&user.unwrap()).unwrap();
|
||||
user["user"]["friend_request_disabled"] == 1
|
||||
}
|
||||
|
||||
@@ -395,12 +395,12 @@ pub fn friend_remove(uid: i64, requestor: i64) {
|
||||
}
|
||||
let uid = get_uid(&login_token);
|
||||
let friends = DATABASE.lock_and_select("SELECT friends FROM friends WHERE user_id=?1", params!(uid));
|
||||
let mut friends = json::parse(&friends.unwrap()).unwrap();
|
||||
let mut friends = jzon::parse(&friends.unwrap()).unwrap();
|
||||
let index = friends["friend_user_id_list"].members().position(|r| *r.to_string() == requestor.to_string());
|
||||
if index.is_some() {
|
||||
friends["friend_user_id_list"].array_remove(index.unwrap());
|
||||
}
|
||||
DATABASE.lock_and_exec("UPDATE friends SET friends=?1 WHERE user_id=?2", params!(json::stringify(friends), uid));
|
||||
DATABASE.lock_and_exec("UPDATE friends SET friends=?1 WHERE user_id=?2", params!(jzon::stringify(friends), uid));
|
||||
}
|
||||
|
||||
pub fn get_random_uids(count: i32) -> JsonValue {
|
||||
@@ -545,10 +545,10 @@ pub fn export_user(token: &str) -> Option<JsonValue> {
|
||||
let login_token = webui_login_token(token)?;
|
||||
|
||||
Some(object!{
|
||||
userdata: json::stringify(get_acc(&login_token)),
|
||||
userhome: json::stringify(get_acc_home(&login_token)),
|
||||
missions: json::stringify(get_acc_missions(&login_token)),
|
||||
sifcards: json::stringify(get_acc_sif(&login_token))
|
||||
userdata: jzon::stringify(get_acc(&login_token)),
|
||||
userhome: jzon::stringify(get_acc_home(&login_token)),
|
||||
missions: jzon::stringify(get_acc_missions(&login_token)),
|
||||
sifcards: jzon::stringify(get_acc_sif(&login_token))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use rusqlite::params;
|
||||
use json::{JsonValue, object};
|
||||
use jzon::{JsonValue, object};
|
||||
use crate::router::userdata;
|
||||
use rand::RngExt;
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
@@ -4,7 +4,7 @@ use actix_web::{
|
||||
http::header::HeaderValue,
|
||||
http::header::ContentType
|
||||
};
|
||||
use json::{JsonValue, object};
|
||||
use jzon::{JsonValue, object};
|
||||
use lazy_static::lazy_static;
|
||||
use include_dir::{include_dir, Dir};
|
||||
use std::fs;
|
||||
@@ -36,11 +36,11 @@ fn error(msg: &str) -> HttpResponse {
|
||||
};
|
||||
HttpResponse::Ok()
|
||||
.insert_header(ContentType::json())
|
||||
.body(json::stringify(resp))
|
||||
.body(jzon::stringify(resp))
|
||||
}
|
||||
|
||||
pub fn login(_req: HttpRequest, body: String) -> HttpResponse {
|
||||
let body = json::parse(&body).unwrap();
|
||||
let body = jzon::parse(&body).unwrap();
|
||||
let token = userdata::webui_login(body["uid"].as_i64().unwrap(), &body["password"].to_string());
|
||||
|
||||
if token.is_err() {
|
||||
@@ -53,14 +53,14 @@ pub fn login(_req: HttpRequest, body: String) -> HttpResponse {
|
||||
HttpResponse::Ok()
|
||||
.insert_header(ContentType::json())
|
||||
.insert_header(("Set-Cookie", format!("ew_token={}; SameSite=Strict; HttpOnly", token.unwrap())))
|
||||
.body(json::stringify(resp))
|
||||
.body(jzon::stringify(resp))
|
||||
}
|
||||
|
||||
pub fn import(_req: HttpRequest, body: String) -> HttpResponse {
|
||||
if !get_config()["import"].as_bool().unwrap() {
|
||||
return error("Importing accounts is disabled on this server.");
|
||||
}
|
||||
let body = json::parse(&body).unwrap();
|
||||
let body = jzon::parse(&body).unwrap();
|
||||
|
||||
let result = userdata::webui_import_user(body);
|
||||
|
||||
@@ -76,7 +76,7 @@ pub fn import(_req: HttpRequest, body: String) -> HttpResponse {
|
||||
};
|
||||
HttpResponse::Ok()
|
||||
.insert_header(ContentType::json())
|
||||
.body(json::stringify(resp))
|
||||
.body(jzon::stringify(resp))
|
||||
}
|
||||
|
||||
pub fn user(req: HttpRequest) -> HttpResponse {
|
||||
@@ -98,7 +98,7 @@ pub fn user(req: HttpRequest) -> HttpResponse {
|
||||
};
|
||||
HttpResponse::Ok()
|
||||
.insert_header(ContentType::json())
|
||||
.body(json::stringify(resp))
|
||||
.body(jzon::stringify(resp))
|
||||
}
|
||||
|
||||
pub fn start_loginbonus(req: HttpRequest, body: String) -> HttpResponse {
|
||||
@@ -106,12 +106,12 @@ pub fn start_loginbonus(req: HttpRequest, body: String) -> HttpResponse {
|
||||
if token.is_none() {
|
||||
return error("Not logged in");
|
||||
}
|
||||
let body = json::parse(&body).unwrap();
|
||||
let body = jzon::parse(&body).unwrap();
|
||||
let resp = userdata::webui_start_loginbonus(body["bonus_id"].as_i64().unwrap(), &token.unwrap());
|
||||
|
||||
HttpResponse::Ok()
|
||||
.insert_header(ContentType::json())
|
||||
.body(json::stringify(resp))
|
||||
.body(jzon::stringify(resp))
|
||||
}
|
||||
|
||||
pub fn set_time(req: HttpRequest, body: String) -> HttpResponse {
|
||||
@@ -119,12 +119,12 @@ pub fn set_time(req: HttpRequest, body: String) -> HttpResponse {
|
||||
if token.is_none() {
|
||||
return error("Not logged in");
|
||||
}
|
||||
let body = json::parse(&body).unwrap();
|
||||
let body = jzon::parse(&body).unwrap();
|
||||
let resp = userdata::set_server_time(body["timestamp"].as_i64().unwrap(), &token.unwrap());
|
||||
|
||||
HttpResponse::Ok()
|
||||
.insert_header(ContentType::json())
|
||||
.body(json::stringify(resp))
|
||||
.body(jzon::stringify(resp))
|
||||
}
|
||||
|
||||
pub fn logout(req: HttpRequest) -> HttpResponse {
|
||||
@@ -139,7 +139,7 @@ pub fn logout(req: HttpRequest) -> HttpResponse {
|
||||
.insert_header(ContentType::json())
|
||||
.insert_header(("Set-Cookie", "ew_token=deleted; expires=Thu, 01 Jan 1970 00:00:00 GMT"))
|
||||
.insert_header(("Location", "/login.html"))
|
||||
.body(json::stringify(resp))
|
||||
.body(jzon::stringify(resp))
|
||||
}
|
||||
|
||||
static WEBUI_ASSETS: Dir<'_> = include_dir!("webui/");
|
||||
@@ -209,7 +209,7 @@ pub fn export(req: HttpRequest) -> HttpResponse {
|
||||
};
|
||||
HttpResponse::Ok()
|
||||
.insert_header(ContentType::json())
|
||||
.body(json::stringify(resp))
|
||||
.body(jzon::stringify(resp))
|
||||
}
|
||||
|
||||
pub fn server_info(_req: HttpRequest) -> HttpResponse {
|
||||
@@ -232,7 +232,7 @@ pub fn server_info(_req: HttpRequest) -> HttpResponse {
|
||||
};
|
||||
HttpResponse::Ok()
|
||||
.insert_header(ContentType::json())
|
||||
.body(json::stringify(resp))
|
||||
.body(jzon::stringify(resp))
|
||||
}
|
||||
|
||||
fn get_query_str(req: &HttpRequest, key: &str, def: &str) -> String {
|
||||
@@ -252,7 +252,7 @@ pub fn get_card_info(req: HttpRequest) -> HttpResponse {
|
||||
|
||||
let start = page * max;
|
||||
|
||||
let items = json::parse(&include_file!("src/router/webui/cards.json")).unwrap();
|
||||
let items = jzon::parse(&include_file!("src/router/webui/cards.json")).unwrap();
|
||||
|
||||
if all == "true" {
|
||||
let resp = object!{
|
||||
@@ -262,7 +262,7 @@ pub fn get_card_info(req: HttpRequest) -> HttpResponse {
|
||||
|
||||
return HttpResponse::Ok()
|
||||
.content_type(ContentType::json())
|
||||
.body(json::stringify(resp));
|
||||
.body(jzon::stringify(resp));
|
||||
}
|
||||
|
||||
let mut filtered_items: Vec<_> = items.members().collect();
|
||||
@@ -299,7 +299,7 @@ pub fn get_card_info(req: HttpRequest) -> HttpResponse {
|
||||
|
||||
HttpResponse::Ok()
|
||||
.content_type(ContentType::json())
|
||||
.body(json::stringify(resp))
|
||||
.body(jzon::stringify(resp))
|
||||
}
|
||||
|
||||
pub fn get_music_info(req: HttpRequest) -> HttpResponse {
|
||||
@@ -310,9 +310,9 @@ pub fn get_music_info(req: HttpRequest) -> HttpResponse {
|
||||
let start = page * max;
|
||||
|
||||
let items = if lang == "EN" {
|
||||
json::parse(&include_file!("src/router/databases/json/global/music.json")).unwrap()
|
||||
jzon::parse(&include_file!("src/router/databases/json/global/music.json")).unwrap()
|
||||
} else {
|
||||
json::parse(&include_file!("src/router/databases/json/music.json")).unwrap()
|
||||
jzon::parse(&include_file!("src/router/databases/json/music.json")).unwrap()
|
||||
};
|
||||
|
||||
let page_items: Vec<_> = items.members()
|
||||
@@ -336,24 +336,24 @@ pub fn get_music_info(req: HttpRequest) -> HttpResponse {
|
||||
|
||||
HttpResponse::Ok()
|
||||
.content_type(ContentType::json())
|
||||
.body(json::stringify(resp))
|
||||
.body(jzon::stringify(resp))
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref ITEM: JsonValue = json::parse(&include_file!("src/router/webui/item.json")).unwrap();
|
||||
static ref LOGIN_BONUS: JsonValue = json::parse(&include_file!("src/router/webui/login_bonus.json")).unwrap();
|
||||
static ref ITEM: JsonValue = jzon::parse(&include_file!("src/router/webui/item.json")).unwrap();
|
||||
static ref LOGIN_BONUS: JsonValue = jzon::parse(&include_file!("src/router/webui/login_bonus.json")).unwrap();
|
||||
}
|
||||
|
||||
pub fn list_login_bonus(_req: HttpRequest) -> HttpResponse {
|
||||
HttpResponse::Ok()
|
||||
.content_type(ContentType::json())
|
||||
.body(json::stringify(LOGIN_BONUS.clone()))
|
||||
.body(jzon::stringify(LOGIN_BONUS.clone()))
|
||||
}
|
||||
|
||||
pub fn list_items(_req: HttpRequest) -> HttpResponse {
|
||||
HttpResponse::Ok()
|
||||
.content_type(ContentType::json())
|
||||
.body(json::stringify(ITEM.clone()))
|
||||
.body(jzon::stringify(ITEM.clone()))
|
||||
}
|
||||
|
||||
pub fn cheat(req: HttpRequest, _body: String) -> HttpResponse {
|
||||
@@ -393,5 +393,5 @@ pub fn cheat(req: HttpRequest, _body: String) -> HttpResponse {
|
||||
|
||||
HttpResponse::Ok()
|
||||
.insert_header(ContentType::json())
|
||||
.body(json::stringify(resp))
|
||||
.body(jzon::stringify(resp))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use rusqlite::{Connection, ToSql};
|
||||
use json::{JsonValue, array};
|
||||
use jzon::{JsonValue, array};
|
||||
|
||||
pub struct SQLite {
|
||||
path: String
|
||||
|
||||
Reference in New Issue
Block a user