Move all encryption to a session handler

This commit is contained in:
Ethan O'Brien
2026-07-24 14:20:26 -05:00
parent 2cd11c8467
commit 0b0b50de36
23 changed files with 155 additions and 241 deletions

View File

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