mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-07-03 22:45:01 +00:00
Return format string with admin logs
This commit is contained in:
@ -6,16 +6,49 @@ use crate::data::admin::AdminID;
|
||||
pub enum AdminAction {
|
||||
AuthWithResetToken,
|
||||
AuthWithAccessKey { key: String, key_id: u64 },
|
||||
RegisteredAdminKey { name: String, target: AdminID },
|
||||
DeletedAdminKey { name: String, target: AdminID },
|
||||
RegisteredAdminKey { key_id: u64, key_name: String, target: AdminID },
|
||||
DeletedAdminKey { key_id: u64, key_name: String, target: AdminID },
|
||||
GeneratedAdminResetToken { target: AdminID },
|
||||
CreatedAdmin { id: AdminID, name: String, email: String },
|
||||
UpdatedAdminGeneralSettings { target: AdminID, new_email: String, new_name: String },
|
||||
AddAdminRole { target: AdminID, role: String },
|
||||
RemoveAdminRole { target: AdminID, role: String },
|
||||
UnsupportedAction,
|
||||
UnsupportedAction { raw_data: String },
|
||||
}
|
||||
|
||||
impl AdminAction {
|
||||
pub fn format_string(&self) -> &'static str {
|
||||
match self {
|
||||
AdminAction::AuthWithResetToken => { "Authenticated with a reset token" }
|
||||
|
||||
AdminAction::AuthWithAccessKey { .. } =>
|
||||
{ "Authenticated with key #{key_id} : \"{key}\"" }
|
||||
|
||||
AdminAction::RegisteredAdminKey { .. } =>
|
||||
{ "Registered a new key #{key_id} with name \'{key_name}\' for [admin]{target}[/admin]" }
|
||||
|
||||
AdminAction::DeletedAdminKey { .. } =>
|
||||
{ "Deleted key #{key_id} \'{key_name\' of [admin]{target}[/admin]" }
|
||||
|
||||
AdminAction::GeneratedAdminResetToken { .. } =>
|
||||
{ "Generated new admin access reset token for [admin]{target}[/admin]" }
|
||||
|
||||
AdminAction::CreatedAdmin { .. } =>
|
||||
{ "Created a new administrator [admin]#{id}[/admin] with name \'{name}\' and email \'email\'" }
|
||||
|
||||
AdminAction::UpdatedAdminGeneralSettings { .. } =>
|
||||
{ "Updated general admin settings of [admin]{target}[/admin]. New name: \'{new_name}\' / New email: \'{new_email}\'" }
|
||||
|
||||
AdminAction::AddAdminRole { .. } =>
|
||||
{ "Add a new role to [admin]{target}[/admin] => {role}" }
|
||||
|
||||
AdminAction::RemoveAdminRole { .. } =>
|
||||
{ "Removed a role from [admin]{target}[/admin] => {role}" }
|
||||
|
||||
AdminAction::UnsupportedAction { .. } => { "Unsupported action. Raw data: {raw_data}" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AdminActionLog {
|
||||
pub id: u64,
|
||||
|
Reference in New Issue
Block a user