From a7f1d2d98d879e13ae1bbcec27f0ca6c81a03d60 Mon Sep 17 00:00:00 2001 From: Quentin Gliech Date: Fri, 27 Mar 2026 15:03:32 +0100 Subject: [PATCH] Rename the `WithCaptcha` template context field to `captcha_config` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The field name is now more descriptive of what it actually is – the configuration of the CAPTCHA provider – and aligns with the key used when passing it to the client-side React form. --- crates/templates/src/context/captcha.rs | 5 +++-- templates/components/captcha.html | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/crates/templates/src/context/captcha.rs b/crates/templates/src/context/captcha.rs index f9d8723b4..f2139e2bd 100644 --- a/crates/templates/src/context/captcha.rs +++ b/crates/templates/src/context/captcha.rs @@ -1,3 +1,4 @@ +// Copyright 2025, 2026 Element Creations Ltd. // Copyright 2024, 2025 New Vector Ltd. // Copyright 2024 The Matrix.org Foundation C.I.C. // @@ -42,7 +43,7 @@ impl Object for CaptchaConfig { /// Context with an optional CAPTCHA configuration in it #[derive(Serialize)] pub struct WithCaptcha { - captcha: Option, + captcha_config: Option, #[serde(flatten)] inner: T, @@ -52,7 +53,7 @@ impl WithCaptcha { #[must_use] pub(crate) fn new(captcha: Option, inner: T) -> Self { Self { - captcha: captcha.map(|captcha| Value::from_object(CaptchaConfig(captcha))), + captcha_config: captcha.map(|captcha| Value::from_object(CaptchaConfig(captcha))), inner, } } diff --git a/templates/components/captcha.html b/templates/components/captcha.html index 42b5e12b2..45fbf9bcb 100644 --- a/templates/components/captcha.html +++ b/templates/components/captcha.html @@ -7,19 +7,19 @@ Please see LICENSE files in the repository root for full details. -#} {% macro form(class="") -%} - {%- if captcha|default(False) -%} + {%- if captcha_config|default(False) -%} - {%- if captcha.service == "recaptcha_v2" -%} -
- {%- elif captcha.service == "cloudflare_turnstile" -%} -
- {%- elif captcha.service == "hcaptcha" -%} -
+ {%- if captcha_config.service == "recaptcha_v2" -%} +
+ {%- elif captcha_config.service == "cloudflare_turnstile" -%} +
+ {%- elif captcha_config.service == "hcaptcha" -%} +
{%- else -%} {{ throw(message="Invalid captcha service setup") }} {%- endif %} @@ -27,12 +27,12 @@ Please see LICENSE files in the repository root for full details. {% endmacro %} {% macro head() -%} - {%- if captcha|default(False) -%} - {%- if captcha.service == "recaptcha_v2" -%} + {%- if captcha_config|default(False) -%} + {%- if captcha_config.service == "recaptcha_v2" -%} - {%- elif captcha.service == "cloudflare_turnstile" -%} + {%- elif captcha_config.service == "cloudflare_turnstile" -%} - {%- elif captcha.service == "hcaptcha" -%} + {%- elif captcha_config.service == "hcaptcha" -%} {%- else -%} {{ throw(message="Invalid captcha service setup") }}