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
This commit is contained in:
parent
be8f62396a
commit
26aac1408e
3 changed files with 13 additions and 16 deletions
|
|
@ -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/<version> (bot; +https://continuwuity.org)"
|
||||
|
||||
# List of forbidden room aliases and room IDs as strings of regex
|
||||
# patterns.
|
||||
|
|
|
|||
|
|
@ -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/<version> (bot; +https://continuwuity.org)"
|
||||
pub url_preview_user_agent: Option<String>,
|
||||
|
||||
/// List of forbidden room aliases and room IDs as strings of regex
|
||||
|
|
|
|||
|
|
@ -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<String> = OnceLock::new();
|
||||
static VERSION_UA: OnceLock<String> = OnceLock::new();
|
||||
static USER_AGENT: OnceLock<String> = 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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue