diff --git a/src/main.rs b/src/main.rs index 4f2b19b..e81faef 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,6 +24,15 @@ async fn user(req: HttpRequest) -> HttpResponse { router::user::user(req) } #[post("/api/user")] async fn user_post(req: HttpRequest, body: String) -> HttpResponse { router::user::user_post(req, body) } +#[post("/api/chat/home")] +async fn chat_home(req: HttpRequest, body: String) -> HttpResponse { router::chat::home(req, body) } + +#[post("/api/chat/talk/start")] +async fn chat_start(req: HttpRequest, body: String) -> HttpResponse { router::chat::start(req, body) } + +#[post("/api/chat/talk/end")] +async fn chat_end(req: HttpRequest, body: String) -> HttpResponse { router::chat::end(req, body) } + #[post("/api/user/initialize")] async fn user_initialize(req: HttpRequest, body: String) -> HttpResponse { router::user::initialize(req, body) } @@ -80,6 +89,9 @@ async fn main() -> std::io::Result<()> { .service(live_guest) .service(live_clearrate) .service(live_start) + .service(chat_home) + .service(chat_end) + .service(chat_start) .service(event) .service(purchase) .service(user_initialize) diff --git a/src/router.rs b/src/router.rs index e9af9ab..eb04042 100644 --- a/src/router.rs +++ b/src/router.rs @@ -11,3 +11,4 @@ pub mod lottery; pub mod friend; pub mod live; pub mod event; +pub mod chat; diff --git a/src/router/chat.rs b/src/router/chat.rs new file mode 100644 index 0000000..ca37309 --- /dev/null +++ b/src/router/chat.rs @@ -0,0 +1,58 @@ +use json; +use json::object; +use crate::router::global; +//use crate::encryption; +use actix_web::{HttpResponse, HttpRequest, http::header::HeaderValue}; +use crate::router::userdata; + +pub fn home(req: HttpRequest, _body: String) -> HttpResponse { + let blank_header = HeaderValue::from_static(""); + let key = req.headers().get("a6573cbe").unwrap_or(&blank_header).to_str().unwrap_or(""); + let uid = req.headers().get("aoharu-user-id").unwrap_or(&blank_header).to_str().unwrap_or(""); + let user = userdata::get_acc(key, uid); + + let id = user["user"]["favorite_master_card_id"].as_i64().unwrap() / 10000; + + let chapter_id = (id * 100000) + 101; + let room_id = (id * 1000) + 1; + + let resp = object!{ + "code": 0, + "server_time": global::timestamp(), + "data": { + "progress_list": [ + { + "chat_id": id, + "room_id": 1, + "chapter_id": chapter_id, + "is_read": 0, + "created_at": global::timestamp() + } + ], + "master_chat_room_ids": [room_id], + "master_chat_stamp_ids": [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,44,45,46,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,11001003,22001001,33001001,44001002], + "master_chat_attachment_ids": [] + } + }; + global::send(resp) +} + +pub fn start(_req: HttpRequest, _body: String) -> HttpResponse { + + let resp = object!{ + "code": 0, + "server_time": global::timestamp(), + "data": {"select_talk_id_list":[],"get_item_list":[],"is_read":0} + }; + global::send(resp) +} + +pub fn end(_req: HttpRequest, _body: String) -> HttpResponse { + + let resp = object!{ + "code": 0, + "server_time": global::timestamp(), + "data": [] + }; + global::send(resp) +}