feat: Audit Logs (#466)

* fix: squash audit log branch changes

Signed-off-by: Zomatree <me@zomatree.live>

* feat: emoji edit + pronoun

Signed-off-by: Zomatree <me@zomatree.live>

* fix: use tokio instead of async-std

Signed-off-by: Zomatree <me@zomatree.live>

* feat: add slowmode to audit log

Signed-off-by: Zomatree <me@zomatree.live>

* chore: update comments on permissions

Signed-off-by: Zomatree <me@zomatree.live>

---------

Signed-off-by: Zomatree <me@zomatree.live>
This commit is contained in:
Zomatree
2026-07-13 13:39:28 -07:00
committed by GitHub
parent f60c8340f4
commit 502203d37c
57 changed files with 2014 additions and 150 deletions
+20 -5
View File
@@ -4,7 +4,7 @@ use revolt_database::{
get_user_voice_channel_in_server, remove_user_from_voice_channel, UserVoiceChannel,
VoiceClient,
},
Database, Message, RemovalIntention, ServerBan, User,
AuditLogEntryAction, Database, Message, RemovalIntention, ServerBan, User,
};
use revolt_models::v0;
use std::time::{Duration, SystemTime};
@@ -16,6 +16,8 @@ use rocket::{serde::json::Json, State};
use ulid::Ulid;
use validator::Validate;
use crate::util::audit_log_reason::AuditLogReason;
/// # Ban User
///
/// Ban a user by their id.
@@ -25,6 +27,7 @@ pub async fn ban(
db: &State<Database>,
voice_client: &State<VoiceClient>,
user: User,
audit_log_reason: AuditLogReason,
server: Reference<'_>,
target: Reference<'_>,
data: Json<v0::DataBanCreate>,
@@ -85,8 +88,20 @@ pub async fn ban(
.await?;
}
}
ServerBan::create(db, &server, target.id, data.reason)
.await
.map(Into::into)
.map(Json)
let ban = ServerBan::create(db, &server, target.id, data.reason.clone()).await?;
AuditLogEntryAction::BanCreate {
user: target.id.to_string(),
}
.insert(
db,
server.id,
audit_log_reason.0.or(data.reason),
user.id,
Some(target.id.to_string()),
)
.await;
Ok(Json(ban.into()))
}