Split out and eliminate api/client/unversioned.rs.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -35,10 +35,11 @@ pub(super) mod tag;
|
|||||||
pub(super) mod thirdparty;
|
pub(super) mod thirdparty;
|
||||||
pub(super) mod threads;
|
pub(super) mod threads;
|
||||||
pub(super) mod to_device;
|
pub(super) mod to_device;
|
||||||
|
pub(super) mod tuwunel;
|
||||||
pub(super) mod typing;
|
pub(super) mod typing;
|
||||||
pub(super) mod unstable;
|
pub(super) mod unstable;
|
||||||
pub(super) mod unversioned;
|
|
||||||
pub(super) mod user_directory;
|
pub(super) mod user_directory;
|
||||||
|
pub(super) mod versions;
|
||||||
pub(super) mod voip;
|
pub(super) mod voip;
|
||||||
pub(super) mod well_known;
|
pub(super) mod well_known;
|
||||||
|
|
||||||
@@ -81,10 +82,11 @@ pub(super) use tag::*;
|
|||||||
pub(super) use thirdparty::*;
|
pub(super) use thirdparty::*;
|
||||||
pub(super) use threads::*;
|
pub(super) use threads::*;
|
||||||
pub(super) use to_device::*;
|
pub(super) use to_device::*;
|
||||||
|
pub(super) use tuwunel::*;
|
||||||
pub(super) use typing::*;
|
pub(super) use typing::*;
|
||||||
pub(super) use unstable::*;
|
pub(super) use unstable::*;
|
||||||
pub(super) use unversioned::*;
|
|
||||||
pub(super) use user_directory::*;
|
pub(super) use user_directory::*;
|
||||||
|
pub(super) use versions::*;
|
||||||
pub(super) use voip::*;
|
pub(super) use voip::*;
|
||||||
pub(super) use well_known::*;
|
pub(super) use well_known::*;
|
||||||
|
|
||||||
|
|||||||
29
src/api/client/tuwunel.rs
Normal file
29
src/api/client/tuwunel.rs
Normal 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
|
||||||
|
})))
|
||||||
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use axum::{Json, extract::State, response::IntoResponse};
|
|
||||||
use futures::StreamExt;
|
|
||||||
use ruma::api::client::discovery::get_supported_versions;
|
use ruma::api::client::discovery::get_supported_versions;
|
||||||
use tuwunel_core::Result;
|
use tuwunel_core::Result;
|
||||||
|
|
||||||
@@ -65,29 +63,3 @@ pub(crate) async fn get_supported_versions_route(
|
|||||||
|
|
||||||
Ok(resp)
|
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
|
|
||||||
})))
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user