Skip to content

Commit

Permalink
perf: Remove deprecated configuration bypass_guild_check (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
m1sk9 authored Oct 18, 2024
1 parent 4b4c0db commit b4ee4f1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 29 deletions.
5 changes: 0 additions & 5 deletions config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,5 @@ logger_format='compact'

[preview]

# Sets whether the guild check process is bypassed when quoting.
# If the guild check process is bypassed, messages can be shared and quoted from all guilds in which babyrite is installed.
# However, the message will be shared to members who do not belong to that guild. This setting is recommended when babyrite is used by multiple private guilds.
bypass_guild_check=false

# Whether to enable mentions in quoted messages.
is_mention=true
29 changes: 16 additions & 13 deletions docs/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Recommended settings are as follows:
logger_format='compact'

[preview]
bypass_guild_check=false
is_mention=true
```

Expand Down Expand Up @@ -55,17 +54,6 @@ Sets the format of the log output. Both will show logs above babyrite's `INFO` l
> }
> ```
#### `preview.bypass_guild_check`
> *Available in [v0.9.0](https://github.com/m1sk9/babyrite/releases/tag/babyrite-v0.9.0)*
>
> *Expected type: boolean*
Sets whether the guild check process is bypassed when quoting.
If the guild check process is bypassed, messages can be shared and quoted from all guilds in which babyrite is installed.
However, the message will be shared to members who do not belong to that guild. This setting is recommended when babyrite is used by multiple private guilds.
> [!CAUTION]
>
> Note that if you enable `bypass_guilds`, bots may be used for malicious purposes. This setting is only intended for use when babyrite is used among a limited group.
Expand All @@ -78,4 +66,19 @@ However, the message will be shared to members who do not belong to that guild.
>
> *Expected type: boolean*
Whether or not to make a quoted message mentions.
Whether to make a quoted message mentions.
------
### Deprecated Configuration
#### `preview.bypass_guild_check`
> *Unavailable in [v0.12.2](https://github.com/m1sk9/babyrite/releases/tag/babyrite-v0.12.2)*
> --- Reason: This setting is not recommended for use in a public environment.
Sets whether the guild check process is bypassed when quoting.
If the guild check process is bypassed, messages can be shared and quoted from all guilds in which babyrite is installed.
However, the message will be shared to members who do not belong to that guild. This setting is recommended when babyrite is used by multiple private guilds.
1 change: 0 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub enum LoggerFormat {

#[derive(Debug, Deserialize)]
pub struct PreviewConfig {
pub bypass_guild_check: bool,
pub is_mention: bool,
}

Expand Down
6 changes: 0 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ async fn main() -> anyhow::Result<()> {
}

tracing::info!("Configuration: {:?}", config);
if config.preview.bypass_guild_check {
tracing::warn!(
"The guild bypass setting is enabled. Quote messages between different guilds. "
)
}

let intents = GatewayIntents::MESSAGE_CONTENT | GatewayIntents::GUILD_MESSAGES;
let mut client = serenity::Client::builder(&envs.discord_api_token, intents)
.event_handler(handler::BabyriteHandler)
Expand Down
6 changes: 2 additions & 4 deletions src/preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ impl MessagePreviewIDs {
ctx: &Context,
is_private: bool,
) -> anyhow::Result<MessagePreview, MessagePreviewError> {
let config = crate::config::BabyriteConfig::get();
let guild = self.guild_id;

let channel =
if let Some(channel) = MESSAGE_PREVIEW_CHANNEL_CACHE.get(&self.channel_id).await {
channel
Expand All @@ -131,9 +129,9 @@ impl MessagePreviewIDs {
};
debug!("channel: {:?}", channel);

if !config.preview.bypass_guild_check && guild != channel.guild_id {
if guild != channel.guild_id {
return Err(MessagePreviewError::GuildError(
"mismatched guilds (set `bypass_guilds` to `true` to enable citation)".to_string(),
"Mismatched guilds".to_string(),
));
}

Expand Down

0 comments on commit b4ee4f1

Please sign in to comment.