fix: squash audit log branch changes

Signed-off-by: Zomatree <me@zomatree.live>
This commit is contained in:
Zomatree
2026-04-20 03:47:49 +01:00
parent 057f2bb8b3
commit ada0bc0f8e
57 changed files with 1923 additions and 153 deletions

View File

@@ -1,12 +1,14 @@
use revolt_database::{
util::{permissions::DatabasePermissionQuery, reference::Reference},
Database, User,
AuditLogEntryAction, Database, User,
};
use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
use revolt_result::Result;
use rocket::State;
use rocket_empty::EmptyResponse;
use crate::util::audit_log_reason::AuditLogReason;
/// # Deletes a webhook
///
/// Deletes a webhook
@@ -15,6 +17,7 @@ use rocket_empty::EmptyResponse;
pub async fn webhook_delete(
db: &State<Database>,
user: User,
reason: AuditLogReason,
webhook_id: Reference<'_>,
) -> Result<EmptyResponse> {
let webhook = webhook_id.as_webhook(db).await?;
@@ -25,5 +28,24 @@ pub async fn webhook_delete(
.await
.throw_if_lacking_channel_permission(ChannelPermission::ManageWebhooks)?;
webhook.delete(db).await.map(|_| EmptyResponse)
webhook.delete(db).await?;
AuditLogEntryAction::WebhookDelete {
webhook: webhook.id,
name: webhook.name,
channel: webhook.channel_id,
}
.insert(
db,
channel
.server()
.expect("Webhook created on non server channel")
.to_string(),
reason,
user.id,
Some(webhook.creator_id),
)
.await;
Ok(EmptyResponse)
}