Split out and eliminate api/client/unversioned.rs.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2026-02-13 22:51:46 +00:00
parent 2f41784a3b
commit 4d2845dd54
3 changed files with 33 additions and 30 deletions

View File

@@ -35,10 +35,11 @@ pub(super) mod tag;
pub(super) mod thirdparty;
pub(super) mod threads;
pub(super) mod to_device;
pub(super) mod tuwunel;
pub(super) mod typing;
pub(super) mod unstable;
pub(super) mod unversioned;
pub(super) mod user_directory;
pub(super) mod versions;
pub(super) mod voip;
pub(super) mod well_known;
@@ -81,10 +82,11 @@ pub(super) use tag::*;
pub(super) use thirdparty::*;
pub(super) use threads::*;
pub(super) use to_device::*;
pub(super) use tuwunel::*;
pub(super) use typing::*;
pub(super) use unstable::*;
pub(super) use unversioned::*;
pub(super) use user_directory::*;
pub(super) use versions::*;
pub(super) use voip::*;
pub(super) use well_known::*;

29
src/api/client/tuwunel.rs Normal file
View File

@@ -0,0 +1,29 @@
use axum::{Json, extract::State, response::IntoResponse};
use futures::StreamExt;
use tuwunel_core::Result;
/// # `GET /_tuwunel/server_version`
///
/// Tuwunel-specific API to get the server version, results akin to
/// `/_matrix/federation/v1/version`
pub(crate) async fn tuwunel_server_version() -> Result<impl IntoResponse> {
Ok(Json(serde_json::json!({
"name": tuwunel_core::version::name(),
"version": tuwunel_core::version::version(),
})))
}
/// # `GET /_tuwunel/local_user_count`
///
/// Tuwunel-specific API to return the amount of users registered on this
/// homeserver. Endpoint is disabled if federation is disabled for privacy. This
/// only includes active users (not deactivated, no guests, etc)
pub(crate) async fn tuwunel_local_user_count(
State(services): State<crate::State>,
) -> Result<impl IntoResponse> {
let user_count = services.users.list_local_users().count().await;
Ok(Json(serde_json::json!({
"count": user_count
})))
}

View File

@@ -1,7 +1,5 @@
use std::collections::BTreeMap;
use axum::{Json, extract::State, response::IntoResponse};
use futures::StreamExt;
use ruma::api::client::discovery::get_supported_versions;
use tuwunel_core::Result;
@@ -65,29 +63,3 @@ pub(crate) async fn get_supported_versions_route(
Ok(resp)
}
/// # `GET /_tuwunel/server_version`
///
/// Tuwunel-specific API to get the server version, results akin to
/// `/_matrix/federation/v1/version`
pub(crate) async fn tuwunel_server_version() -> Result<impl IntoResponse> {
Ok(Json(serde_json::json!({
"name": tuwunel_core::version::name(),
"version": tuwunel_core::version::version(),
})))
}
/// # `GET /_tuwunel/local_user_count`
///
/// Tuwunel-specific API to return the amount of users registered on this
/// homeserver. Endpoint is disabled if federation is disabled for privacy. This
/// only includes active users (not deactivated, no guests, etc)
pub(crate) async fn tuwunel_local_user_count(
State(services): State<crate::State>,
) -> Result<impl IntoResponse> {
let user_count = services.users.list_local_users().count().await;
Ok(Json(serde_json::json!({
"count": user_count
})))
}