feat: audit log on role creation
This commit is contained in:
parent
362e4bc2e8
commit
55ef6ddde2
2 changed files with 6 additions and 7 deletions
|
@ -10,11 +10,7 @@ use axum::{
|
|||
use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
AppState,
|
||||
api::v1::auth::CurrentUser,
|
||||
error::Error,
|
||||
objects::{Member, Permissions, Role},
|
||||
utils::{CacheFns, global_checks, order_by_is_above},
|
||||
api::v1::auth::CurrentUser, error::Error, objects::{AuditLog, AuditLogId, Member, Permissions, Role}, utils::{global_checks, order_by_is_above, CacheFns}, AppState
|
||||
};
|
||||
|
||||
pub mod uuid;
|
||||
|
@ -71,7 +67,10 @@ pub async fn create(
|
|||
.check_permission(&mut conn, &app_state.cache_pool, Permissions::ManageRole)
|
||||
.await?;
|
||||
|
||||
// TODO: roles permission
|
||||
let role = Role::new(&mut conn, guild_uuid, role_info.name.clone()).await?;
|
||||
|
||||
AuditLog::new(guild_uuid, AuditLogId::RoleCreate as i16, member.uuid, None, None, None, Some(role.uuid), Some(role_info.name.clone()) , None, None).await.push(&mut conn).await?;
|
||||
|
||||
Ok((StatusCode::OK, Json(role)).into_response())
|
||||
}
|
||||
|
|
|
@ -21,9 +21,9 @@ use super::{HasIsAbove, HasUuid, load_or_empty, member::MemberBuilder};
|
|||
#[diesel(primary_key(uuid))]
|
||||
#[diesel(check_for_backend(diesel::pg::Pg))]
|
||||
pub struct Role {
|
||||
uuid: Uuid,
|
||||
pub uuid: Uuid,
|
||||
guild_uuid: Uuid,
|
||||
name: String,
|
||||
pub name: String,
|
||||
color: i32,
|
||||
is_above: Option<Uuid>,
|
||||
pub permissions: i64,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue