mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2024-11-28 05:45:48 +00:00
feat: add /_conduwuit/local_user_count
endpoint
only enabled if federation is enabled Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
32161801ed
commit
1c7c5bc09c
|
@ -155,7 +155,20 @@ pub(crate) async fn syncv3_client_server_json() -> Result<impl IntoResponse> {
|
|||
/// `/_matrix/federation/v1/version`
|
||||
pub(crate) async fn conduwuit_server_version() -> Result<impl IntoResponse> {
|
||||
Ok(Json(serde_json::json!({
|
||||
"name": "Conduwuit",
|
||||
"name": "conduwuit",
|
||||
"version": conduwuit_version(),
|
||||
})))
|
||||
}
|
||||
|
||||
/// # `GET /_conduwuit/local_user_count`
|
||||
///
|
||||
/// conduwuit-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 conduwuit_local_user_count() -> Result<impl IntoResponse> {
|
||||
let user_count = services().users.list_local_users()?.len();
|
||||
|
||||
Ok(Json(serde_json::json!({
|
||||
"count": user_count
|
||||
})))
|
||||
}
|
||||
|
|
|
@ -220,11 +220,13 @@ pub fn build(router: Router, server: &Server) -> Router {
|
|||
.ruma_route(server_server::claim_keys_route)
|
||||
.ruma_route(server_server::get_hierarchy_route)
|
||||
.ruma_route(server_server::well_known_server)
|
||||
.route("/_conduwuit/local_user_count", get(client_server::conduwuit_local_user_count))
|
||||
} else {
|
||||
router
|
||||
.route("/_matrix/federation/*path", any(federation_disabled))
|
||||
.route("/.well-known/matrix/server", any(federation_disabled))
|
||||
.route("/_matrix/key/*path", any(federation_disabled))
|
||||
.route("/_conduwuit/local_user_count", any(federation_disabled))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue