mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew
synced 2026-08-26 23:12:20 +08:00
Split giant router api function mess
This commit is contained in:
@@ -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":[]
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user