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
@@ -1,6 +1,7 @@
use revolt_database::{
util::{permissions::DatabasePermissionQuery, reference::Reference},
Channel, Database, FieldsMessage, PartialMessage, SystemMessage, User, AMQP,
AuditLogEntryAction, Channel, Database, FieldsMessage, PartialMessage, SystemMessage, User,
AMQP,
};
use revolt_models::v0::MessageAuthor;
use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
@@ -8,6 +9,8 @@ use revolt_result::{create_error, Result};
use rocket::State;
use rocket_empty::EmptyResponse;
use crate::util::audit_log_reason::AuditLogReason;
/// # Unpins a message
///
/// Unpins a message by its id.
@@ -17,6 +20,7 @@ pub async fn message_unpin(
db: &State<Database>,
amqp: &State<AMQP>,
user: User,
reason: AuditLogReason,
target: Reference<'_>,
msg: Reference<'_>,
) -> Result<EmptyResponse> {
@@ -58,6 +62,22 @@ pub async fn message_unpin(
)
.await?;
if let Some(server_id) = channel.server() {
AuditLogEntryAction::MessageUnpin {
message: message.id.clone(),
author: message.author.clone(),
channel: message.channel.clone(),
}
.insert(
db,
server_id.to_string(),
reason,
user.id,
Some(message.author),
)
.await;
}
Ok(EmptyResponse)
}