From bfb611d9e4344412bbeb82dcf5dabec4c696a8cc Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Fri, 13 Nov 2026 16:28:32 -0500 Subject: [PATCH] fix(config): Include experiments in the generated example config --- conduwuit-example.toml | 94 ++++++++++++++++++++++++++++++++++ src/core/config/experiments.rs | 34 ++++++++---- src/core/config/mod.rs | 7 ++- 3 files changed, 125 insertions(+), 10 deletions(-) diff --git a/conduwuit-example.toml b/conduwuit-example.toml index d13bd50a4..7cc920932 100644 --- a/conduwuit-example.toml +++ b/conduwuit-example.toml @@ -2657,3 +2657,97 @@ # # env: CONTINUWUITY_OAUTH__OIDC__PROFILE_KEY_IMPORT_MODE #profile_key_import_mode = "on_registration" + +[global.experiments] + +# MSC4155: Invite filtering +# +# Provides advanced invite filtering rules for users, allowing complex +# configurations that can allow, ignore, and reject invites from users and +# servers broadly. +# +# Requires a supporting client to set up on an account. +# +# https://github.com/matrix-org/matrix-spec-proposals/pull/4155 +# +# env: CONTINUWUITY_EXPERIMENTS__MSC4155 +#msc4155 = false + +# MSC4174: Web push +# +# Adds server-side support for web push, allowing web clients to receive +# push notifications directly without the need for an intermediary push +# gateway like Sygnal. +# +# https://github.com/matrix-org/matrix-spec-proposals/pull/4174 +# +# env: CONTINUWUITY_EXPERIMENTS__MSC4174 +#msc4174 = false + +# MSC4484: Server Administration OAuth Scope +# +# Adds a new OAuth2 scope that explicitly grants a token temporary +# homeserver administrator privileges, granting temporary token access +# to administrator endpoints like locking & suspension. +# +# https://github.com/matrix-org/matrix-spec-proposals/pull/4484 +# +# env: CONTINUWUITY_EXPERIMENTS__MSC4484 +#msc4484 = false + +# MSC4494: Membership-based invite blocking +# +# Adds a new invite blocking action that will reject all invites coming +# from users who do not share a room with the invitee that is not `public` +# (the join rule). +# +# This is not related to MSC4155, this proposal instead builds on the +# "invite blocking" proposal that landed in the specification in v1.17, +# which simply allows enabling or disabling invites altogether. +# +# MSC4494 is a good middle-ground between the allowlisting possible with +# MSC4155, and the general desire to block invites from users you may not +# know. +# +# Requires a supporting client to enable on an account. +# +# https://github.com/matrix-org/matrix-spec-proposals/pull/4494 +# +# env: CONTINUWUITY_EXPERIMENTS__MSC4494 +#msc4494 = false + +# MSC4560: Stripped state requests over federation +# +# Implements a more efficient way for servers to acquire and serve +# "stripped state" to clients, which is typically only used for displaying +# rooms. The display of space hierarchies and room summaries is +# significantly faster when this proposal is enabled and used. +# +# https://github.com/matrix-org/matrix-spec-proposals/pull/4560 +# +# env: CONTINUWUITY_EXPERIMENTS__MSC4560 +#msc4560 = false + +#[global.experiments.msc2815] +# MSC2815: Proposal to allow room moderators to view redacted event content +# +# Allows the server to retain unredacted copies of events that have been +# redacted for a limited period of time, which allows room moderators and +# server administrators to reveal redacted contents. Useful for moderation +# and investigating reports. +# +# Requires a supporting client to use. +# +# https://github.com/matrix-org/matrix-spec-proposals/pull/2815 + + +# Whether to enable MSC2815. +# +# env: CONTINUWUITY_EXPERIMENTS__MSC2815__ENABLED +#enabled = false + +# How long, in seconds, to retain the original content of redacted +# events before it is permanently erased. Defaults to 90 days. +# +# env: CONTINUWUITY_EXPERIMENTS__MSC2815__UNREDACTED_CONTENT_MAX_AGE_SECS +#unredacted_content_max_age_secs = 7776000 diff --git a/src/core/config/experiments.rs b/src/core/config/experiments.rs index e140a695c..14d5d556f 100644 --- a/src/core/config/experiments.rs +++ b/src/core/config/experiments.rs @@ -8,16 +8,9 @@ pub struct Experiments { /// MSC2815: Proposal to allow room moderators to view redacted event /// content /// - /// Allows the server to retain unredacted copies of events that have been - /// redacted for a limited period of time, which allows room moderators and - /// server administrators to reveal redacted contents. Useful for moderation - /// and investigating reports. + /// See [`MSC2815`] for details. /// - /// Requires a supporting client to use. - /// - /// https://github.com/matrix-org/matrix-spec-proposals/pull/2815 - /// - /// default: false + /// display: nested #[serde(default)] pub msc2815: Option, /// MSC4155: Invite filtering @@ -113,9 +106,32 @@ impl ToggledExperiment for SimpleExperiment { /// /// MSC2815: https://github.com/matrix-org/matrix-spec-proposals/pull/2815 #[derive(Debug, Deserialize, Default, Clone, Copy)] +#[config_example_generator( + filename = "conduwuit-example.toml", + section = "global.experiments.msc2815", + optional = "true", + subheader = r#"# MSC2815: Proposal to allow room moderators to view redacted event content +# +# Allows the server to retain unredacted copies of events that have been +# redacted for a limited period of time, which allows room moderators and +# server administrators to reveal redacted contents. Useful for moderation +# and investigating reports. +# +# Requires a supporting client to use. +# +# https://github.com/matrix-org/matrix-spec-proposals/pull/2815"# +)] pub struct MSC2815 { + /// Whether to enable MSC2815. + /// + /// default: false #[serde(default)] pub enabled: bool, + + /// How long, in seconds, to retain the original content of redacted + /// events before it is permanently erased. Defaults to 90 days. + /// + /// default: 7776000 #[serde(default = "default_unredacted_content_max_age_secs")] pub unredacted_content_max_age_secs: u64, } diff --git a/src/core/config/mod.rs b/src/core/config/mod.rs index 078e2558f..b720756ee 100644 --- a/src/core/config/mod.rs +++ b/src/core/config/mod.rs @@ -1,6 +1,5 @@ #![allow(clippy::doc_link_with_quotes)] pub mod check; -pub mod experiments; pub mod manager; pub mod proxy; @@ -3423,3 +3422,9 @@ fn default_profile_key_map() -> HashMap { fn default_unauthenticated_request_ratelimit() -> PerMinuteRatelimiter { PerMinuteRatelimiter::new(Quota::per_minute(30.try_into().unwrap())) } + +// NOTE: This must be declared *after* every config struct in this file. The +// example config generator writes sections in macro expansion order, and the +// `global` section truncates the file, so declaring this module any earlier +// causes its sections to be wiped from the generated example config. +pub mod experiments;