2021-09-13 17:45:56 +00:00
|
|
|
use crate::{ConduitResult, Ruma};
|
2021-03-13 15:30:12 +00:00
|
|
|
use ruma::{
|
|
|
|
api::client::r0::capabilities::{
|
|
|
|
get_capabilities, Capabilities, RoomVersionStability, RoomVersionsCapability,
|
|
|
|
},
|
|
|
|
RoomVersionId,
|
|
|
|
};
|
2020-07-30 16:14:47 +00:00
|
|
|
use std::collections::BTreeMap;
|
|
|
|
|
|
|
|
#[cfg(feature = "conduit_bin")]
|
|
|
|
use rocket::get;
|
|
|
|
|
2020-07-31 12:40:28 +00:00
|
|
|
/// # `GET /_matrix/client/r0/capabilities`
|
|
|
|
///
|
2021-08-31 17:14:37 +00:00
|
|
|
/// Get information on the supported feature set and other relevent capabilities of this server.
|
2021-07-11 20:07:10 +00:00
|
|
|
#[cfg_attr(
|
|
|
|
feature = "conduit_bin",
|
|
|
|
get("/_matrix/client/r0/capabilities", data = "<_body>")
|
|
|
|
)]
|
|
|
|
#[tracing::instrument(skip(_body))]
|
|
|
|
pub async fn get_capabilities_route(
|
|
|
|
_body: Ruma<get_capabilities::Request>,
|
|
|
|
) -> ConduitResult<get_capabilities::Response> {
|
2020-07-30 16:14:47 +00:00
|
|
|
let mut available = BTreeMap::new();
|
2021-07-21 09:29:13 +00:00
|
|
|
available.insert(RoomVersionId::Version5, RoomVersionStability::Stable);
|
2021-03-13 15:30:12 +00:00
|
|
|
available.insert(RoomVersionId::Version6, RoomVersionStability::Stable);
|
2020-07-30 16:14:47 +00:00
|
|
|
|
2021-03-13 15:30:12 +00:00
|
|
|
let mut capabilities = Capabilities::new();
|
|
|
|
capabilities.room_versions = RoomVersionsCapability {
|
|
|
|
default: RoomVersionId::Version6,
|
|
|
|
available,
|
|
|
|
};
|
|
|
|
|
|
|
|
Ok(get_capabilities::Response { capabilities }.into())
|
2020-07-30 16:14:47 +00:00
|
|
|
}
|