From a0193181c44e96d147a18d8d18505a1c6ca6ac43 Mon Sep 17 00:00:00 2001 From: Mathieu133 Date: Tue, 10 Nov 2026 17:12:00 +0100 Subject: [PATCH] feat(logs): add option to hide ticket rename audit logs --- config.example.toml | 1 + .../src/handlers/guild_moderation_handler.rs | 25 +++++++++++++++++-- .../src/components/configuration.rs | 13 ++++++++++ crates/rustmail_panel/src/i18n/en/en.json | 3 ++- crates/rustmail_panel/src/i18n/fr/fr.json | 3 ++- crates/rustmail_types/src/config/logs.rs | 3 +++ docs/getting-started/configuration.md | 1 + docs/reference/configuration.md | 2 ++ 8 files changed, 47 insertions(+), 4 deletions(-) diff --git a/config.example.toml b/config.example.toml index 5c16c03c..7cb4bf45 100644 --- a/config.example.toml +++ b/config.example.toml @@ -70,6 +70,7 @@ embed_color = "ffb800" [logs] show_log_on_edit = true show_log_on_delete = true +hide_ticket_rename_logs = false [updates] enabled = true diff --git a/crates/rustmail/src/handlers/guild_moderation_handler.rs b/crates/rustmail/src/handlers/guild_moderation_handler.rs index fd94e581..8c9d9a42 100644 --- a/crates/rustmail/src/handlers/guild_moderation_handler.rs +++ b/crates/rustmail/src/handlers/guild_moderation_handler.rs @@ -4,10 +4,10 @@ use crate::prelude::db::*; use crate::prelude::features::*; use crate::prelude::i18n::*; use crate::prelude::utils::*; -use serenity::all::audit_log::Action; +use serenity::all::audit_log::{Action, Change}; use serenity::all::{ButtonStyle, ChannelAction}; use serenity::{ - all::{AuditLogEntry, ChannelId, Context, EventHandler, GuildId}, + all::{AuditLogEntry, ChannelId, Context, EventHandler, GuildId, UserId}, async_trait, }; @@ -90,6 +90,21 @@ async fn manage_creating_ticket_via_opening_thread( .await; } +fn is_bot_channel_rename(entry: &AuditLogEntry, bot_id: UserId) -> bool { + let Action::Channel(ChannelAction::Update) = entry.action else { + return false; + }; + if entry.user_id != bot_id { + return false; + } + match entry.changes.as_deref() { + Some(changes) if !changes.is_empty() => changes + .iter() + .all(|change| matches!(change, Change::Name { .. })), + _ => false, + } +} + #[async_trait] impl EventHandler for GuildModerationHandler { async fn guild_audit_log_entry_create( @@ -118,6 +133,12 @@ impl EventHandler for GuildModerationHandler { None => return, }; + if self.config.logs.hide_ticket_rename_logs + && is_bot_channel_rename(&entry, ctx.cache.current_user().id) + { + return; + } + let user = match entry.user_id.to_user(ctx.clone()).await { Ok(user) => user, Err(_) => { diff --git a/crates/rustmail_panel/src/components/configuration.rs b/crates/rustmail_panel/src/components/configuration.rs index 506465f4..a4533d6d 100644 --- a/crates/rustmail_panel/src/components/configuration.rs +++ b/crates/rustmail_panel/src/components/configuration.rs @@ -1637,6 +1637,19 @@ fn logs_reminder_section(props: &LogsReminderSectionProps) -> Html { }} /> + +

{i18n.t("panel.configuration.reminders.title")}