diff --git a/changelog.d/1290.bugfix.md b/changelog.d/1290.bugfix.md new file mode 100644 index 00000000..c0a1824b --- /dev/null +++ b/changelog.d/1290.bugfix.md @@ -0,0 +1 @@ +Fix the generated configuration containing uncommented optional sections. Contributed by @Jade diff --git a/conduwuit-example.toml b/conduwuit-example.toml index 94599773..5aaed400 100644 --- a/conduwuit-example.toml +++ b/conduwuit-example.toml @@ -1926,9 +1926,9 @@ # #admin_filter = "" -[global.antispam] +#[global.antispam] -[global.antispam.meowlnir] +#[global.antispam.meowlnir] # The base URL on which to contact Meowlnir (before /_meowlnir/antispam). # @@ -1953,7 +1953,7 @@ # #check_all_joins = false -[global.antispam.draupnir] +#[global.antispam.draupnir] # The base URL on which to contact Draupnir (before /api/). # diff --git a/src/core/config/mod.rs b/src/core/config/mod.rs index ba8010a7..13cde3cb 100644 --- a/src/core/config/mod.rs +++ b/src/core/config/mod.rs @@ -2261,7 +2261,11 @@ struct ListeningAddr { } #[derive(Clone, Debug, Deserialize)] -#[config_example_generator(filename = "conduwuit-example.toml", section = "global.antispam")] +#[config_example_generator( + filename = "conduwuit-example.toml", + section = "global.antispam", + optional = "true" +)] pub struct Antispam { /// display: nested pub meowlnir: Option, @@ -2272,7 +2276,8 @@ pub struct Antispam { #[derive(Clone, Debug, Deserialize)] #[config_example_generator( filename = "conduwuit-example.toml", - section = "global.antispam.meowlnir" + section = "global.antispam.meowlnir", + optional = "true" )] pub struct MeowlnirConfig { /// The base URL on which to contact Meowlnir (before /_meowlnir/antispam). @@ -2301,7 +2306,8 @@ pub struct MeowlnirConfig { #[derive(Clone, Debug, Deserialize)] #[config_example_generator( filename = "conduwuit-example.toml", - section = "global.antispam.draupnir" + section = "global.antispam.draupnir", + optional = "true" )] pub struct DraupnirConfig { /// The base URL on which to contact Draupnir (before /api/). diff --git a/src/macros/config.rs b/src/macros/config.rs index 32bde53b..b0b42edd 100644 --- a/src/macros/config.rs +++ b/src/macros/config.rs @@ -73,7 +73,13 @@ fn generate_example(input: &ItemStruct, args: &[Meta], write: bool) -> Result