audit log on ban and unban
This commit is contained in:
parent
dee248e02d
commit
6afa78c8e8
2 changed files with 6 additions and 10 deletions
|
@ -9,11 +9,7 @@ use axum::{
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
AppState,
|
api::v1::auth::CurrentUser, error::Error, objects::{AuditLog, AuditLogId, GuildBan, Member, Permissions}, utils::global_checks, AppState
|
||||||
api::v1::auth::CurrentUser,
|
|
||||||
error::Error,
|
|
||||||
objects::{GuildBan, Member, Permissions},
|
|
||||||
utils::global_checks,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub async fn get(
|
pub async fn get(
|
||||||
|
@ -51,7 +47,9 @@ pub async fn unban(
|
||||||
|
|
||||||
let ban = GuildBan::fetch_one(&mut conn, guild_uuid, user_uuid).await?;
|
let ban = GuildBan::fetch_one(&mut conn, guild_uuid, user_uuid).await?;
|
||||||
|
|
||||||
|
let log_entrie = AuditLog::new(guild_uuid, AuditLogId::MemberUnban as i16, caller.uuid, None, Some(ban.user_uuid), None, None, None, None, None).await;
|
||||||
ban.unban(&mut conn).await?;
|
ban.unban(&mut conn).await?;
|
||||||
|
log_entrie.push(&mut conn).await?;
|
||||||
|
|
||||||
Ok(StatusCode::OK)
|
Ok(StatusCode::OK)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,7 @@ use axum::{
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
AppState,
|
api::v1::auth::CurrentUser, error::Error, objects::{AuditLog, AuditLogId, Member, Permissions}, utils::global_checks, AppState
|
||||||
api::v1::auth::CurrentUser,
|
|
||||||
error::Error,
|
|
||||||
objects::{Member, Permissions},
|
|
||||||
utils::global_checks,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
@ -42,7 +38,9 @@ pub async fn post(
|
||||||
.check_permission(&mut conn, &app_state.cache_pool, Permissions::BanMember)
|
.check_permission(&mut conn, &app_state.cache_pool, Permissions::BanMember)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
let log_entrie = AuditLog::new(member.guild_uuid, AuditLogId::MemberBan as i16, caller.uuid, None, Some(member.user_uuid), None, None, Some(payload.reason.clone()), None, None).await;
|
||||||
member.ban(&mut conn, &payload.reason).await?;
|
member.ban(&mut conn, &payload.reason).await?;
|
||||||
|
log_entrie.push(&mut conn).await?;
|
||||||
|
|
||||||
Ok(StatusCode::OK)
|
Ok(StatusCode::OK)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue