From 26aac1408e7c69e00b88a911e0122ccd249242ce Mon Sep 17 00:00:00 2001 From: Jade Ellis Date: Sun, 15 Feb 2026 14:33:27 +0000 Subject: [PATCH] fix: Correct user agent changes Correct the domain Remove "embed" in the UA because the global UA was modified, rather than just the one for preview requests --- conduwuit-example.toml | 6 ++---- src/core/config/mod.rs | 6 ++---- src/core/info/version.rs | 17 +++++++++-------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/conduwuit-example.toml b/conduwuit-example.toml index 841ee4a3..43b3958a 100644 --- a/conduwuit-example.toml +++ b/conduwuit-example.toml @@ -1474,11 +1474,9 @@ # #url_preview_check_root_domain = false -# User agent that is used specifically when downloading url previews. +# User agent that is used specifically when fetching url previews. # -# example: "continuwuity (bot; +https://forgejo.ellis.link/continuwuation/continuwuity)" -# -#url_preview_user_agent = "continuwuity/$VERSION ($VERSION_TAG)" +#url_preview_user_agent = "continuwuity/ (bot; +https://continuwuity.org)" # List of forbidden room aliases and room IDs as strings of regex # patterns. diff --git a/src/core/config/mod.rs b/src/core/config/mod.rs index f2813b04..6f758af1 100644 --- a/src/core/config/mod.rs +++ b/src/core/config/mod.rs @@ -1696,11 +1696,9 @@ pub struct Config { #[serde(default)] pub url_preview_check_root_domain: bool, - /// User agent that is used specifically when downloading url previews. + /// User agent that is used specifically when fetching url previews. /// - /// example: "continuwuity (bot; +https://forgejo.ellis.link/continuwuation/continuwuity)" - /// - /// default: "continuwuity/$VERSION ($VERSION_TAG)" + /// default: "continuwuity/ (bot; +https://continuwuity.org)" pub url_preview_user_agent: Option, /// List of forbidden room aliases and room IDs as strings of regex diff --git a/src/core/info/version.rs b/src/core/info/version.rs index e1e13b76..acdd65f4 100644 --- a/src/core/info/version.rs +++ b/src/core/info/version.rs @@ -8,10 +8,11 @@ use std::sync::OnceLock; static BRANDING: &str = "continuwuity"; -static WEBSITE: &str = "https://continuwuity.com"; +static WEBSITE: &str = "https://continuwuity.org"; static SEMANTIC: &str = env!("CARGO_PKG_VERSION"); static VERSION: OnceLock = OnceLock::new(); +static VERSION_UA: OnceLock = OnceLock::new(); static USER_AGENT: OnceLock = OnceLock::new(); #[inline] @@ -20,17 +21,17 @@ pub fn name() -> &'static str { BRANDING } #[inline] pub fn version() -> &'static str { VERSION.get_or_init(init_version) } +#[inline] +pub fn version_ua() -> &'static str { VERSION_UA.get_or_init(init_version_ua) } #[inline] pub fn user_agent() -> &'static str { USER_AGENT.get_or_init(init_user_agent) } -fn init_user_agent() -> String { - format!( - "{}/{SEMANTIC}{} (embedbot; +{WEBSITE})", - name(), - conduwuit_build_metadata::version_tag() - .map_or_else(String::new, |extra| format!("+{extra}")) - ) +fn init_user_agent() -> String { format!("{}/{} (bot; +{WEBSITE})", name(), version_ua()) } + +fn init_version_ua() -> String { + conduwuit_build_metadata::version_tag() + .map_or_else(|| SEMANTIC.to_owned(), |extra| format!("{SEMANTIC}+{extra}")) } fn init_version() -> String {