mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
feat(core): Change default user agent
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
|
|
||||||
static BRANDING: &str = "continuwuity";
|
static BRANDING: &str = "continuwuity";
|
||||||
|
static WEBSITE: &str = "https://continuwuity.com";
|
||||||
static SEMANTIC: &str = env!("CARGO_PKG_VERSION");
|
static SEMANTIC: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
static VERSION: OnceLock<String> = OnceLock::new();
|
static VERSION: OnceLock<String> = OnceLock::new();
|
||||||
@@ -23,7 +24,14 @@ pub fn version() -> &'static str { VERSION.get_or_init(init_version) }
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn user_agent() -> &'static str { USER_AGENT.get_or_init(init_user_agent) }
|
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 {
|
fn init_version() -> String {
|
||||||
conduwuit_build_metadata::version_tag()
|
conduwuit_build_metadata::version_tag()
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ impl crate::Service for Service {
|
|||||||
let url_preview_user_agent = config
|
let url_preview_user_agent = config
|
||||||
.url_preview_user_agent
|
.url_preview_user_agent
|
||||||
.clone()
|
.clone()
|
||||||
.unwrap_or_else(|| conduwuit::version::user_agent().to_string());
|
.unwrap_or_else(|| conduwuit::version::user_agent().to_owned());
|
||||||
|
|
||||||
Ok(Arc::new(Self {
|
Ok(Arc::new(Self {
|
||||||
default: base(config)?
|
default: base(config)?
|
||||||
|
|||||||
Reference in New Issue
Block a user