feat(core): Change default user agent
This commit is contained in:
parent
40996a6602
commit
be8f62396a
2 changed files with 10 additions and 2 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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)?
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue