1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-07-10 01:22:48 +00:00

Return format string with admin logs

This commit is contained in:
2021-07-11 13:49:59 +02:00
parent 5d97ca18cb
commit 28b24f39b0
5 changed files with 57 additions and 14 deletions

View File

@ -11,13 +11,13 @@ use crate::helpers::database;
use crate::utils::date_utils::time;
/// Save a new key in the database
pub fn add_key(id: AdminID, name: &str, key: Credential) -> Res {
pub fn add_key(id: AdminID, name: &str, key: Credential) -> Res<u64> {
database::InsertQuery::new(ADMIN_KEYS_TABLE)
.add_admin_id("admin_id", id)
.add_str("name", name)
.add_u64("time_add", time())
.add_str("credential", &serde_json::to_string(&key)?)
.insert_drop_result()
.insert_expect_result()
}
/// Get the list of keys of a given admin

View File

@ -48,6 +48,6 @@ fn db_to_log(row: &database::RowResult) -> Res<AdminActionLog> {
ip: row.get_str("ip")?,
time: row.get_u64("time")?,
action: serde_json::from_str(&row.get_str("action")?)
.unwrap_or(AdminAction::UnsupportedAction),
.unwrap_or(AdminAction::UnsupportedAction { raw_data: row.get_str("action").unwrap() }),
})
}