use CONDUIT_VERSION_EXTRA in endpoints

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-03-29 18:21:33 -04:00 committed by June
parent 87a7c8d9e8
commit 47889410eb
3 changed files with 24 additions and 4 deletions

View file

@ -74,9 +74,14 @@ pub async fn syncv3_client_server_json() -> Result<impl IntoResponse> {
},
};
let version = match option_env!("CONDUIT_VERSION_EXTRA") {
Some(extra) => format!("{} ({})", env!("CARGO_PKG_VERSION"), extra),
None => env!("CARGO_PKG_VERSION").to_owned(),
};
Ok(Json(serde_json::json!({
"server": server_url,
"version": format!("Conduwuit {}", env!("CARGO_PKG_VERSION"))
"version": version,
})))
}
@ -85,8 +90,13 @@ pub async fn syncv3_client_server_json() -> Result<impl IntoResponse> {
/// Conduwuit-specific API to get the server version, results akin to
/// `/_matrix/federation/v1/version`
pub async fn conduwuit_server_version() -> Result<impl IntoResponse> {
let version = match option_env!("CONDUIT_VERSION_EXTRA") {
Some(extra) => format!("{} ({})", env!("CARGO_PKG_VERSION"), extra),
None => env!("CARGO_PKG_VERSION").to_owned(),
};
Ok(Json(serde_json::json!({
"name": "Conduwuit",
"version": env!("CARGO_PKG_VERSION"),
"version": version,
})))
}

View file

@ -623,10 +623,15 @@ pub async fn get_server_version_route(
return Err(Error::bad_config("Federation is disabled."));
}
let version = match option_env!("CONDUIT_VERSION_EXTRA") {
Some(extra) => format!("{} ({})", env!("CARGO_PKG_VERSION"), extra),
None => env!("CARGO_PKG_VERSION").to_owned(),
};
Ok(get_server_version::v1::Response {
server: Some(get_server_version::v1::Server {
name: Some("Conduwuit".to_owned()),
version: Some(env!("CARGO_PKG_VERSION").to_owned()),
version: Some(version),
}),
})
}

View file

@ -83,13 +83,18 @@ impl Client {
}
fn base(config: &Config) -> Result<reqwest::ClientBuilder> {
let version = match option_env!("CONDUIT_VERSION_EXTRA") {
Some(extra) => format!("{} ({})", env!("CARGO_PKG_VERSION"), extra),
None => env!("CARGO_PKG_VERSION").to_owned(),
};
let builder = reqwest::Client::builder()
.hickory_dns(true)
.timeout(Duration::from_secs(config.request_timeout))
.connect_timeout(Duration::from_secs(config.request_conn_timeout))
.pool_max_idle_per_host(config.request_idle_per_host.into())
.pool_idle_timeout(Duration::from_secs(config.request_idle_timeout))
.user_agent("Conduwuit".to_owned() + "/" + env!("CARGO_PKG_VERSION"))
.user_agent("Conduwuit".to_owned() + "/" + &version)
.redirect(redirect::Policy::limited(6));
if let Some(proxy) = config.proxy.to_proxy()? {