Skip to content

Commit dd3fa88

Browse files
authored
Merge pull request #340 from Rustmail/329-ensure-that-discord-logs-can-be-disabled-independently-of-rustmail-logs
refactor(logs): ensure that discord logs can be disabled independently of rustmail logs
2 parents a4ff409 + ade58b2 commit dd3fa88

12 files changed

Lines changed: 49 additions & 33 deletions

File tree

crates/rustmail/src/commands/close/slash_command/close.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ impl RegistrableCommand for CloseCommand {
344344
.await?;
345345
let _ = delete_scheduled_closure(&thread.id, db_pool).await;
346346

347-
if config.bot.enable_logs {
347+
if config.bot.enable_rustmail_logs {
348348
if let Some(logs_channel_id) = config.bot.logs_channel_id {
349349
let base_url = config
350350
.bot

crates/rustmail/src/commands/close/text_command/close.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ pub async fn close(
284284
.await?;
285285
let _ = delete_scheduled_closure(&thread.id, db_pool).await;
286286

287-
if config.bot.enable_logs {
287+
if config.bot.enable_rustmail_logs {
288288
if let Some(logs_channel_id) = config.bot.logs_channel_id {
289289
let base_url = config
290290
.bot

crates/rustmail/src/commands/edit/common.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ mod tests {
2626
close_message: "Thank you for your message!".to_string(),
2727
typing_proxy_from_user: false,
2828
typing_proxy_from_staff: false,
29-
enable_logs: true,
29+
enable_rustmail_logs: true,
30+
enable_discord_logs: true,
3031
enable_features: true,
3132
enable_panel: false,
3233
features_channel_id: Some(12345),

crates/rustmail/src/commands/force_close/slash_command/force_close.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl RegistrableCommand for ForceCloseCommand {
9494
}
9595

9696
if let Some(thread_info) = thread {
97-
if config.bot.enable_logs {
97+
if config.bot.enable_rustmail_logs {
9898
if let Some(logs_channel_id) = config.bot.logs_channel_id {
9999
let base_url = config
100100
.bot

crates/rustmail/src/commands/force_close/text_command/force_close.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub async fn force_close(
3636
}
3737

3838
if let Some(thread_info) = thread {
39-
if config.bot.enable_logs {
39+
if config.bot.enable_rustmail_logs {
4040
if let Some(logs_channel_id) = config.bot.logs_channel_id {
4141
let base_url = config
4242
.bot

crates/rustmail/src/handlers/guild_moderation_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl EventHandler for GuildModerationHandler {
110110
}
111111
}
112112

113-
if !self.config.bot.enable_logs {
113+
if !self.config.bot.enable_discord_logs {
114114
return;
115115
}
116116

crates/rustmail/src/modules/scheduled_closures.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub fn schedule_one(ctx: &Context, config: &Config, thread_id: String, close_at:
3434
.await;
3535
let _ = delete_scheduled_closure(&thread_id, pool).await;
3636

37-
if config_clone.bot.enable_logs {
37+
if config_clone.bot.enable_rustmail_logs {
3838
if let Some(logs_channel_id) = config_clone.bot.logs_channel_id {
3939
let base_url = config_clone
4040
.bot
@@ -116,7 +116,7 @@ pub async fn hydrate_scheduled_closures(ctx: &Context, config: &Config) {
116116
.await;
117117
let _ = delete_scheduled_closure(&thread.id, pool).await;
118118

119-
if config.bot.enable_logs {
119+
if config.bot.enable_rustmail_logs {
120120
if let Some(logs_channel_id) = config.bot.logs_channel_id {
121121
let base_url = config
122122
.bot

crates/rustmail_panel/src/components/configuration.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -889,13 +889,26 @@ fn bot_section(props: &BotSectionProps) -> Html {
889889

890890
<div class="grid grid-cols-3 gap-4">
891891
<CheckboxInput
892-
label={i18n.t("panel.configuration.bot.enable_logs")}
893-
checked={config.bot.enable_logs}
892+
label={i18n.t("panel.configuration.bot.enable_rustmail_logs")}
893+
checked={config.bot.enable_rustmail_logs}
894894
on_change={{
895895
let config = config.clone();
896896
Callback::from(move |val: bool| {
897897
let mut cfg = (*config).clone();
898-
cfg.bot.enable_logs = val;
898+
cfg.bot.enable_rustmail_logs = val;
899+
config.set(cfg);
900+
})
901+
}}
902+
/>
903+
904+
<CheckboxInput
905+
label={i18n.t("panel.configuration.bot.enable_discord_logs")}
906+
checked={config.bot.enable_discord_logs}
907+
on_change={{
908+
let config = config.clone();
909+
Callback::from(move |val: bool| {
910+
let mut cfg = (*config).clone();
911+
cfg.bot.enable_discord_logs = val;
899912
config.set(cfg);
900913
})
901914
}}

crates/rustmail_panel/src/i18n/fr/fr.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
"close_message": "Message de fermeture",
5252
"typing_proxy_user": "Proxy de frappe (utilisateur)",
5353
"typing_proxy_staff": "Proxy de frappe (staff)",
54-
"enable_logs": "Activer les logs",
54+
"enable_rustmail_logs": "Activer les logs rustmail",
55+
"enable_discord_logs": "Activer les logs discord",
5556
"enable_features": "Activer les features",
5657
"enable_panel": "Activer le panel",
5758
"client_id": "Client ID",

crates/rustmail_panel/src/pages/panel.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,7 @@ pub fn panel() -> Html {
5757
use_effect_with((*authorized).clone(), move |auth| {
5858
if matches!(auth, Some(false)) {
5959
let win = window();
60-
if let Ok(pathname) = win.location().pathname() {
61-
let _ = win.location().set_href("/error?message=Access+Denied");
62-
} else {
63-
let _ = win.location().set_href("/api/auth/login");
64-
}
60+
let _ = win.location().set_href("/error?message=Access+Denied");
6561
}
6662
|| ()
6763
});

0 commit comments

Comments
 (0)