fix: squash audit log branch changes
Signed-off-by: Zomatree <me@zomatree.live>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use revolt_database::{
|
||||
util::{permissions::DatabasePermissionQuery, reference::Reference},
|
||||
Database, Invite, User,
|
||||
AuditLogEntryAction, Database, Invite, User,
|
||||
};
|
||||
use revolt_models::v0;
|
||||
use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
|
||||
@@ -8,6 +8,8 @@ use revolt_permissions::{calculate_channel_permissions, ChannelPermission};
|
||||
use revolt_result::{create_error, Result};
|
||||
use rocket::{serde::json::Json, State};
|
||||
|
||||
use crate::util::audit_log_reason::AuditLogReason;
|
||||
|
||||
/// # Create Invite
|
||||
///
|
||||
/// Creates an invite to this channel.
|
||||
@@ -18,6 +20,7 @@ use rocket::{serde::json::Json, State};
|
||||
pub async fn create_invite(
|
||||
db: &State<Database>,
|
||||
user: User,
|
||||
reason: AuditLogReason,
|
||||
target: Reference<'_>,
|
||||
) -> Result<Json<v0::Invite>> {
|
||||
if user.bot.is_some() {
|
||||
@@ -30,8 +33,16 @@ pub async fn create_invite(
|
||||
.await
|
||||
.throw_if_lacking_channel_permission(ChannelPermission::InviteOthers)?;
|
||||
|
||||
Invite::create_channel_invite(db, &user, &channel)
|
||||
.await
|
||||
.map(|invite| invite.into())
|
||||
.map(Json)
|
||||
let invite = Invite::create_channel_invite(db, &user, &channel).await?;
|
||||
|
||||
if let Some(server_id) = channel.server() {
|
||||
AuditLogEntryAction::InviteCreate {
|
||||
invite: invite.code().to_string(),
|
||||
channel: channel.id().to_string(),
|
||||
}
|
||||
.insert(db, server_id.to_string(), reason, user.id, None)
|
||||
.await;
|
||||
}
|
||||
|
||||
Ok(Json(invite.into()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user