mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew
synced 2026-08-27 15:32:17 +08:00
Move all encryption to a session handler
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
use jzon::{object, array, JsonValue};
|
||||
use actix_web::{web, HttpRequest, Responder};
|
||||
|
||||
use crate::router::{global, items, userdata, databases};
|
||||
use crate::encryption;
|
||||
use crate::router::{global, items, userdata, databases, Login, Session};
|
||||
|
||||
pub fn routes(cfg: &mut web::ServiceConfig) {
|
||||
cfg.service(
|
||||
@@ -38,8 +37,7 @@ pub fn add_chat_from_chapter_id(chapter_id: i64, chats: &mut JsonValue) -> bool
|
||||
add_chat(chapter["masterChatId"].as_i64().unwrap(), chapter["roomId"].as_i64().unwrap(), chats)
|
||||
}
|
||||
|
||||
async fn home(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
async fn home(req: HttpRequest, Login(key): Login) -> impl Responder {
|
||||
let chats = userdata::get_acc_chats(&key);
|
||||
|
||||
let mut rooms = array![];
|
||||
@@ -55,13 +53,11 @@ async fn home(req: HttpRequest, body: String) -> impl Responder {
|
||||
}))
|
||||
}
|
||||
|
||||
async fn start(req: HttpRequest, _body: String) -> impl Responder {
|
||||
async fn start(req: HttpRequest) -> impl Responder {
|
||||
global::api(&req, Some(object!{"select_talk_id_list":[],"get_item_list":[],"is_read":0}))
|
||||
}
|
||||
|
||||
async fn end(req: HttpRequest, body: String) -> impl Responder {
|
||||
let key = global::get_login(req.headers(), &body);
|
||||
let body = jzon::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
|
||||
async fn end(req: HttpRequest, Session { key, body }: Session) -> impl Responder {
|
||||
let mut missions = userdata::get_acc_missions(&key);
|
||||
let mut chats = userdata::get_acc_chats(&key);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user