feat(core): Change default user agent

This commit is contained in:
Trash Panda 2026-02-14 19:44:17 -07:00 committed by Jade Ellis
parent 40996a6602
commit be8f62396a
No known key found for this signature in database
GPG key ID: 8705A2A3EBF77BD2
2 changed files with 10 additions and 2 deletions

View file

@ -8,6 +8,7 @@
use std::sync::OnceLock;
static BRANDING: &str = "continuwuity";
static WEBSITE: &str = "https://continuwuity.com";
static SEMANTIC: &str = env!("CARGO_PKG_VERSION");
static VERSION: OnceLock<String> = OnceLock::new();
@ -23,7 +24,14 @@ pub fn version() -> &'static str { VERSION.get_or_init(init_version) }
#[inline]
pub fn user_agent() -> &'static str { USER_AGENT.get_or_init(init_user_agent) }
fn init_user_agent() -> String { format!("{}/{}", name(), version()) }
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_version() -> String {
conduwuit_build_metadata::version_tag()

View file

@ -39,7 +39,7 @@ impl crate::Service for Service {
let url_preview_user_agent = config
.url_preview_user_agent
.clone()
.unwrap_or_else(|| conduwuit::version::user_agent().to_string());
.unwrap_or_else(|| conduwuit::version::user_agent().to_owned());
Ok(Arc::new(Self {
default: base(config)?