Skip to content

Commit cfa54fc

Browse files
committed
feat: add missing APIs to HomeserverCapabilities
Add `m.room_versions` & `m.account_moderation` that were missed in the first implementation. Signed-off-by: Bryant Mairs <bryant@mai.rs>
1 parent 1f3dea7 commit cfa54fc

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

crates/matrix-sdk/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ All notable changes to this project will be documented in this file.
88

99
### Features
1010

11+
- Add `room_versions()` & `account_moderation()` to `HomeserverCapabilities`.
12+
([#6413](https://github.com/matrix-org/matrix-rust-sdk/pull/6413))
1113
- Enable sending redaction events through the send queue via `RoomSendQueue::redact`.
1214
This includes local echoes for redaction events through the new `LocalEchoContent::Redaction`
1315
variant.

crates/matrix-sdk/src/client/homeserver_capabilities.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ use matrix_sdk_base::{StateStoreDataKey, StateStoreDataValue};
22
use ruma::{
33
api::client::discovery::{
44
get_capabilities,
5-
get_capabilities::v3::{Capabilities, ProfileFieldsCapability},
5+
get_capabilities::v3::{
6+
AccountModerationCapability, Capabilities, ProfileFieldsCapability,
7+
RoomVersionsCapability,
8+
},
69
},
710
profile::ProfileFieldName,
811
};
@@ -109,6 +112,22 @@ impl HomeserverCapabilities {
109112
Ok(ProfileFieldsCapability::new(false))
110113
}
111114

115+
/// Returns the room versions supported by the server.
116+
///
117+
/// Spec: <https://spec.matrix.org/latest/client-server-api/#mroom_versions-capability>
118+
pub async fn room_versions(&self) -> crate::Result<RoomVersionsCapability> {
119+
let capabilities = self.load_or_fetch_homeserver_capabilities().await?;
120+
Ok(capabilities.room_versions)
121+
}
122+
123+
/// Returns whether the user can perform account moderation actions.
124+
///
125+
/// Spec: <https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3capabilities_response-200_accountmoderationcapability>
126+
pub async fn account_moderation(&self) -> crate::Result<AccountModerationCapability> {
127+
let capabilities = self.load_or_fetch_homeserver_capabilities().await?;
128+
Ok(capabilities.account_moderation)
129+
}
130+
112131
/// Returns whether or not the server automatically forgets rooms which the
113132
/// user has left.
114133
///

0 commit comments

Comments
 (0)