mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew.git
synced 2025-05-13 11:37:33 -05:00
Implement announcement endpoints
This commit is contained in:
parent
9b9afecb28
commit
8f018f558a
4 changed files with 34 additions and 0 deletions
|
@ -177,6 +177,12 @@ async fn serial_code_events(req: HttpRequest) -> HttpResponse { router::serial_c
|
||||||
#[get("/api/album/sif")]
|
#[get("/api/album/sif")]
|
||||||
async fn sif_album(req: HttpRequest) -> HttpResponse { router::user::sif(req) }
|
async fn sif_album(req: HttpRequest) -> HttpResponse { router::user::sif(req) }
|
||||||
|
|
||||||
|
#[get("/web/announcement")]
|
||||||
|
async fn announcement(req: HttpRequest) -> HttpResponse { router::web::announcement(req) }
|
||||||
|
|
||||||
|
#[get("/api/home/announcement")]
|
||||||
|
async fn announcement_api(req: HttpRequest) -> HttpResponse { router::user::announcement(req) }
|
||||||
|
|
||||||
async fn log_unknown_request(req: HttpRequest, body: String) -> HttpResponse {
|
async fn log_unknown_request(req: HttpRequest, body: String) -> HttpResponse {
|
||||||
if body != String::new() {
|
if body != String::new() {
|
||||||
println!("{}", encryption::decrypt_packet(&body).unwrap());
|
println!("{}", encryption::decrypt_packet(&body).unwrap());
|
||||||
|
@ -194,6 +200,8 @@ async fn main() -> std::io::Result<()> {
|
||||||
println!("Request: {}", req.path());
|
println!("Request: {}", req.path());
|
||||||
srv.call(req)
|
srv.call(req)
|
||||||
})
|
})
|
||||||
|
.service(announcement_api)
|
||||||
|
.service(announcement)
|
||||||
.service(sif_album)
|
.service(sif_album)
|
||||||
.service(preset)
|
.service(preset)
|
||||||
.service(preset_get)
|
.service(preset_get)
|
||||||
|
|
|
@ -17,3 +17,4 @@ pub mod notice;
|
||||||
pub mod debug;
|
pub mod debug;
|
||||||
pub mod gree;
|
pub mod gree;
|
||||||
pub mod serial_code;
|
pub mod serial_code;
|
||||||
|
pub mod web;
|
||||||
|
|
|
@ -215,6 +215,25 @@ pub fn user_post(req: HttpRequest, body: String) -> HttpResponse {
|
||||||
global::send(resp)
|
global::send(resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn announcement(req: HttpRequest) -> HttpResponse {
|
||||||
|
let key = global::get_login(req.headers(), "");
|
||||||
|
|
||||||
|
let mut user = userdata::get_acc_home(&key);
|
||||||
|
|
||||||
|
user["home"]["new_announcement_flag"] = (0).into();
|
||||||
|
|
||||||
|
userdata::save_acc_home(&key, user);
|
||||||
|
|
||||||
|
let resp = object!{
|
||||||
|
"code": 0,
|
||||||
|
"server_time": global::timestamp(),
|
||||||
|
"data": {
|
||||||
|
new_announcement_flag: 0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
global::send(resp)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn uid_to_code(uid: String) -> String {
|
pub fn uid_to_code(uid: String) -> String {
|
||||||
//just replace uid with numbers because im too lazy to have a real database and this is close enough anyways
|
//just replace uid with numbers because im too lazy to have a real database and this is close enough anyways
|
||||||
return uid
|
return uid
|
||||||
|
|
6
src/router/web.rs
Normal file
6
src/router/web.rs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
use actix_web::{HttpResponse, HttpRequest};
|
||||||
|
|
||||||
|
pub fn announcement(_req: HttpRequest) -> HttpResponse {
|
||||||
|
|
||||||
|
HttpResponse::Ok().body("sif2 is back!")
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue