Split giant router api function mess

This commit is contained in:
Ethan O'Brien
2026-06-11 15:47:03 -05:00
parent df83adf710
commit e631b34945
24 changed files with 701 additions and 555 deletions

View File

@@ -1,10 +1,14 @@
use jzon::{object, JsonValue};
use actix_web::{HttpRequest};
use jzon::{object};
use actix_web::{web, HttpRequest, Responder};
use crate::encryption;
use crate::router::{global, userdata, databases};
pub fn read(req: HttpRequest, body: String) -> Option<JsonValue> {
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();
let mut user = userdata::get_acc(&key);
@@ -29,12 +33,12 @@ pub fn read(req: HttpRequest, body: String) -> Option<JsonValue> {
userdata::save_acc(&key, user.clone());
Some(object!{
global::api(&req, Some(object!{
"gift_list":[],
"updated_value_list":{
"story_list": user["story_list"].clone()
},
"reward_list":[],
"clear_mission_ids":[]
})
}))
}