Implement /api/album/sif

This commit is contained in:
Ethan O'Brien 2024-04-11 13:58:41 -05:00
parent 89eaf11414
commit f226ef41eb
3 changed files with 28 additions and 6 deletions

View file

@ -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)

View file

@ -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);

View file

@ -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);