implement tutorial endpoint

This commit is contained in:
Ethan O'Brien
2024-02-23 19:13:03 -06:00
parent 9ce5f9bd42
commit c5cfc9bf4d
6 changed files with 70 additions and 6 deletions

25
src/router/tutorial.rs Normal file
View File

@@ -0,0 +1,25 @@
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 tutorial(req: HttpRequest, body: String) -> HttpResponse {
let body = json::parse(&encryption::decrypt_packet(&body).unwrap()).unwrap();
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 mut user = userdata::get_acc(key, uid);
user["tutorial_step"] = body["step"].clone();
userdata::save_acc(key, uid, user);
let resp = object!{
"code": 0,
"server_time": global::timestamp(),
"data": []
};
global::send(resp)
}