5 changed files with 84 additions and 9 deletions
@ -1,16 +1,26 @@
|
||||
use crate::api::{CurrentUser, API}; |
||||
use crate::db_conn::Db; |
||||
use crate::api::{CurrentUser, JsonAPI}; |
||||
use crate::random_hasher::RandomHasher; |
||||
use crate::rds_conn::RdsConn; |
||||
use crate::rds_models::Systemlog; |
||||
use rocket::serde::json::{json, Value}; |
||||
use rocket::State; |
||||
|
||||
#[get("/systemlog")] |
||||
pub async fn get_systemlog(user: CurrentUser, rh: &State<RandomHasher>, db: Db) -> API<Value> { |
||||
pub async fn get_systemlog(user: CurrentUser, rh: &State<RandomHasher>, rconn: RdsConn) -> JsonAPI { |
||||
let logs = Systemlog::get_list(&rconn, 50).await?; |
||||
|
||||
Ok(json!({ |
||||
"tmp_token": rh.get_tmp_token(), |
||||
"salt": look!(rh.salt), |
||||
"start_time": rh.start_time.timestamp(), |
||||
"custom_title": user.custom_title, |
||||
"data": [], |
||||
"data": logs.into_iter().map(|log| |
||||
json!({ |
||||
"type": log.action_type, |
||||
"user": look!(log.user_hash), |
||||
"timestamp": log.time.timestamp(), |
||||
"detail": format!("{}\n{}", &log.target, &log.detail) |
||||
}) |
||||
).collect::<Vec<Value>>(), |
||||
})) |
||||
} |
||||
|
Loading…
Reference in new issue