conduit/src/client_server/capabilities.rs

36 lines
1.2 KiB
Rust
Raw Normal View History

2020-07-30 16:14:47 +00:00
use crate::ConduitResult;
use ruma::{api::client::r0::capabilities::get_capabilities, RoomVersionId};
use std::collections::BTreeMap;
#[cfg(feature = "conduit_bin")]
use rocket::get;
2020-07-31 12:40:28 +00:00
/// # `GET /_matrix/client/r0/capabilities`
///
/// Get information on this server's supported feature set and other relevent capabilities.
2020-07-30 16:14:47 +00:00
#[cfg_attr(feature = "conduit_bin", get("/_matrix/client/r0/capabilities"))]
2021-02-28 11:41:03 +00:00
#[tracing::instrument]
pub async fn get_capabilities_route() -> ConduitResult<get_capabilities::Response> {
2020-07-30 16:14:47 +00:00
let mut available = BTreeMap::new();
available.insert(
RoomVersionId::Version5,
get_capabilities::RoomVersionStability::Stable,
);
available.insert(
RoomVersionId::Version6,
get_capabilities::RoomVersionStability::Stable,
);
Ok(get_capabilities::Response {
capabilities: get_capabilities::Capabilities {
change_password: get_capabilities::ChangePasswordCapability::default(), // enabled by default
room_versions: get_capabilities::RoomVersionsCapability {
default: RoomVersionId::Version6,
2020-07-30 16:14:47 +00:00
available,
},
2020-07-30 16:14:47 +00:00
custom_capabilities: BTreeMap::new(),
},
}
.into())
}