2025-02-23 01:17:45 -05:00
|
|
|
use axum::{Json, extract::State, response::IntoResponse};
|
2026-05-11 23:13:52 +01:00
|
|
|
use conduwuit::{
|
|
|
|
|
Result,
|
|
|
|
|
matrix::versions::{unstable_features, versions},
|
|
|
|
|
};
|
2024-08-08 17:18:30 +00:00
|
|
|
use futures::StreamExt;
|
2026-04-12 11:12:43 -04:00
|
|
|
use ruma::{api::client::discovery::get_supported_versions, assign};
|
2022-04-06 21:31:29 +02:00
|
|
|
|
2025-04-04 03:30:13 +00:00
|
|
|
use crate::Ruma;
|
2020-07-30 18:14:47 +02:00
|
|
|
|
2020-07-31 14:40:28 +02:00
|
|
|
/// # `GET /_matrix/client/versions`
|
|
|
|
|
///
|
|
|
|
|
/// Get the versions of the specification and unstable features supported by
|
|
|
|
|
/// this server.
|
|
|
|
|
///
|
|
|
|
|
/// - Versions take the form MAJOR.MINOR.PATCH
|
|
|
|
|
/// - Only the latest PATCH release will be reported for each MAJOR.MINOR value
|
2021-08-31 19:14:37 +02:00
|
|
|
/// - Unstable features are namespaced and may include version information in
|
|
|
|
|
/// their name
|
2020-07-31 14:40:28 +02:00
|
|
|
///
|
|
|
|
|
/// Note: Unstable features are used while developing new features. Clients
|
|
|
|
|
/// should avoid using unstable features in their stable releases
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) async fn get_supported_versions_route(
|
2022-12-14 13:09:10 +01:00
|
|
|
_body: Ruma<get_supported_versions::Request>,
|
2022-01-22 16:58:32 +01:00
|
|
|
) -> Result<get_supported_versions::Response> {
|
2026-05-11 23:13:52 +01:00
|
|
|
Ok(assign!(
|
|
|
|
|
get_supported_versions::Response::new(versions()),
|
|
|
|
|
{ unstable_features: unstable_features() }
|
|
|
|
|
))
|
2020-07-30 18:14:47 +02:00
|
|
|
}
|
2023-07-06 10:32:25 +02:00
|
|
|
|
2024-03-27 10:17:11 -04:00
|
|
|
/// # `GET /_conduwuit/server_version`
|
|
|
|
|
///
|
|
|
|
|
/// Conduwuit-specific API to get the server version, results akin to
|
|
|
|
|
/// `/_matrix/federation/v1/version`
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) async fn conduwuit_server_version() -> Result<impl IntoResponse> {
|
2024-03-27 10:17:11 -04:00
|
|
|
Ok(Json(serde_json::json!({
|
2024-12-14 21:58:01 -05:00
|
|
|
"name": conduwuit::version::name(),
|
|
|
|
|
"version": conduwuit::version::version(),
|
2024-01-07 21:24:55 -05:00
|
|
|
})))
|
|
|
|
|
}
|
2024-05-23 11:26:27 -04:00
|
|
|
|
|
|
|
|
/// # `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
|
2026-05-05 09:09:38 -04:00
|
|
|
/// only includes active users (not deactivated, etc)
|
2024-12-15 00:05:47 -05:00
|
|
|
pub(crate) async fn conduwuit_local_user_count(
|
|
|
|
|
State(services): State<crate::State>,
|
|
|
|
|
) -> Result<impl IntoResponse> {
|
2024-08-08 17:18:30 +00:00
|
|
|
let user_count = services.users.list_local_users().count().await;
|
2024-05-23 11:26:27 -04:00
|
|
|
|
|
|
|
|
Ok(Json(serde_json::json!({
|
|
|
|
|
"count": user_count
|
|
|
|
|
})))
|
|
|
|
|
}
|