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:
@ -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
|
||||
|
@ -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() }),
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user