From f226ef41eb1c1c492e00e78ac671c1aa0aca085b Mon Sep 17 00:00:00 2001 From: Ethan O'Brien <77750390+ethanaobrien@users.noreply.github.com> Date: Thu, 11 Apr 2024 13:58:41 -0500 Subject: [PATCH] Implement /api/album/sif --- src/main.rs | 4 ++++ src/router/user.rs | 13 +++++++++++++ src/router/userdata/mod.rs | 17 +++++++++++------ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 50f7f82..d874665 100644 --- a/src/main.rs +++ b/src/main.rs @@ -174,6 +174,9 @@ async fn gglverifymigrationcode(req: HttpRequest, body: String) -> HttpResponse #[get("/api/serial_code/events")] async fn serial_code_events(req: HttpRequest) -> HttpResponse { router::serial_code::events(req) } +#[get("/api/album/sif")] +async fn sif_album(req: HttpRequest) -> HttpResponse { router::user::sif(req) } + async fn log_unknown_request(req: HttpRequest, body: String) -> HttpResponse { if body != String::new() { println!("{}", encryption::decrypt_packet(&body).unwrap()); @@ -191,6 +194,7 @@ async fn main() -> std::io::Result<()> { println!("Request: {}", req.path()); srv.call(req) }) + .service(sif_album) .service(preset) .service(preset_get) .service(gree_init) diff --git a/src/router/user.rs b/src/router/user.rs index 74fb986..b646d47 100644 --- a/src/router/user.rs +++ b/src/router/user.rs @@ -410,6 +410,19 @@ pub fn detail(_req: HttpRequest, body: String) -> HttpResponse { global::send(resp) } +pub fn sif(req: HttpRequest) -> HttpResponse { + let key = global::get_login(req.headers(), ""); + let cards = userdata::get_acc_sif(&key); + + let resp = object!{ + "code": 0, + "server_time": global::timestamp(), + "data": { + cards: cards + } + }; + global::send(resp) +} pub fn initialize(req: HttpRequest, body: String) -> HttpResponse { let key = global::get_login(req.headers(), &body); diff --git a/src/router/userdata/mod.rs b/src/router/userdata/mod.rs index 4bbeedc..a15a8ab 100644 --- a/src/router/userdata/mod.rs +++ b/src/router/userdata/mod.rs @@ -148,17 +148,19 @@ fn create_acc(uid: i64, login: &str) { new_user["stamina"]["last_updated_time"] = global::timestamp().into(); create_store(&format!("SELECT userhome FROM _{}_", key), &format!("CREATE TABLE _{}_ ( - userdata TEXT NOT NULL, - userhome TEXT NOT NULL, - missions TEXT NOT NULL, - loginbonus TEXT NOT NULL + userdata TEXT NOT NULL, + userhome TEXT NOT NULL, + missions TEXT NOT NULL, + loginbonus TEXT NOT NULL, + sifcards TEXT NOT NULL )", key), - &format!("INSERT INTO _{}_ (userdata, userhome, missions, loginbonus) VALUES (?1, ?2, ?3, ?4)", key), + &format!("INSERT INTO _{}_ (userdata, userhome, missions, loginbonus, sifcards) VALUES (?1, ?2, ?3, ?4, ?5)", key), params!( json::stringify(new_user), include_str!("new_user_home.json"), include_str!("chat_missions.json"), - format!(r#"{{"last_rewarded": 0, "bonus_list": [], "start_time": {}}}"#, global::timestamp()) + format!(r#"{{"last_rewarded": 0, "bonus_list": [], "start_time": {}}}"#, global::timestamp()), + "[]" ) ); @@ -235,6 +237,9 @@ pub fn get_acc_missions(auth_key: &str) -> JsonValue { pub fn get_acc_loginbonus(auth_key: &str) -> JsonValue { get_data(auth_key, "loginbonus") } +pub fn get_acc_sif(auth_key: &str) -> JsonValue { + get_data(auth_key, "sifcards") +} pub fn save_data(auth_key: &str, row: &str, data: JsonValue) { let key = get_key(&auth_key);