WIP: Audit Logs #45

Draft
baaboe wants to merge 13 commits from wip/auditlog into main
2 changed files with 6 additions and 10 deletions
Showing only changes of commit 6afa78c8e8 - Show all commits

View file

@ -9,11 +9,7 @@ use axum::{
use uuid::Uuid;
use crate::{
AppState,
api::v1::auth::CurrentUser,
error::Error,
objects::{GuildBan, Member, Permissions},
utils::global_checks,
api::v1::auth::CurrentUser, error::Error, objects::{AuditLog, AuditLogId, GuildBan, Member, Permissions}, utils::global_checks, AppState
};
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 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?;
log_entrie.push(&mut conn).await?;
Ok(StatusCode::OK)
}

View file

@ -9,11 +9,7 @@ use axum::{
use serde::Deserialize;
use crate::{
AppState,
api::v1::auth::CurrentUser,
error::Error,
objects::{Member, Permissions},
utils::global_checks,
api::v1::auth::CurrentUser, error::Error, objects::{AuditLog, AuditLogId, Member, Permissions}, utils::global_checks, AppState
};
use uuid::Uuid;
@ -42,7 +38,9 @@ pub async fn post(
.check_permission(&mut conn, &app_state.cache_pool, Permissions::BanMember)
.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?;
log_entrie.push(&mut conn).await?;
Ok(StatusCode::OK)
}