Skip to content

Commit 3828d81

Browse files
committed
refactor(sdk): Put ruma-federation-api dependency behind a feature
In theory clients shouldn't make requests to the server-server API. A way to work around it for this specific case would be to implement MSC4383. In the meantime, clients that don't want to use `Client::server_vendor_info()` won't have to build the extra dependencies added by ruma-federation-api. The feature is enabled for the bindings, so it isn't a breaking change for matrix-sdk-ffi. Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
1 parent e90e862 commit 3828d81

File tree

5 files changed

+14
-3
lines changed

5 files changed

+14
-3
lines changed

bindings/matrix-sdk-ffi/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ matrix-sdk = { workspace = true, features = [
5757
"markdown",
5858
"socks",
5959
"uniffi",
60+
"federation-api",
6061
] }
6162
matrix-sdk-base.workspace = true
6263
matrix-sdk-common.workspace = true

crates/matrix-sdk/CHANGELOG.md

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

77
## [Unreleased] - ReleaseDate
88

9+
### Refactor
10+
11+
- [**breaking**]: `Client::server_vendor_info()` requires to enable the
12+
`federation-api` feature.
13+
914
## [0.15.0] - 2025-11-27
1015

1116
### Features

crates/matrix-sdk/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ rustls-tls = ["reqwest/rustls-tls"]
6161
socks = ["reqwest/socks"]
6262
local-server = ["dep:axum", "dep:rand", "dep:tower"]
6363
sso-login = ["local-server"]
64+
# Enable methods that make calls to the federation API.
65+
federation-api = ["ruma/federation-api-c"]
6466

6567
uniffi = ["dep:uniffi", "matrix-sdk-base/uniffi", "dep:matrix-sdk-ffi-macros"]
6668

6769
experimental-widgets = ["dep:uuid", "experimental-send-custom-to-device"]
6870

69-
docsrs = ["e2e-encryption", "sqlite", "indexeddb", "sso-login", "qrcode"]
71+
docsrs = ["e2e-encryption", "sqlite", "indexeddb", "sso-login", "qrcode", "federation-api"]
7072

7173
# Add support for inline media galleries via msgtypes
7274
unstable-msc4274 = ["ruma/unstable-msc4274", "matrix-sdk-base/unstable-msc4274"]
@@ -116,7 +118,6 @@ pin-project-lite.workspace = true
116118
rand = { workspace = true, optional = true }
117119
ruma = { workspace = true, features = [
118120
"rand",
119-
"federation-api-c",
120121
"unstable-msc2448",
121122
"unstable-msc4191",
122123
"unstable-msc3930",

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ use ruma::{
7171
user_directory::search_users,
7272
},
7373
error::FromHttpResponseError,
74-
federation::discovery::get_server_version,
7574
path_builder::PathBuilder,
7675
},
7776
assign,
@@ -599,10 +598,13 @@ impl Client {
599598
/// );
600599
/// # anyhow::Ok(()) };
601600
/// ```
601+
#[cfg(feature = "federation-api")]
602602
pub async fn server_vendor_info(
603603
&self,
604604
request_config: Option<RequestConfig>,
605605
) -> HttpResult<ServerVendorInfo> {
606+
use ruma::api::federation::discovery::get_server_version;
607+
606608
let res = self
607609
.send_inner(get_server_version::v1::Request::new(), request_config, Default::default())
608610
.await?;

crates/matrix-sdk/tests/integration/client.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,6 +1513,7 @@ async fn test_room_sync_state_after() {
15131513
assert_eq!(*member.membership(), MembershipState::Leave);
15141514
}
15151515

1516+
#[cfg(feature = "federation-api")]
15161517
#[async_test]
15171518
async fn test_server_vendor_info() {
15181519
let server = MatrixMockServer::new().await;
@@ -1567,6 +1568,7 @@ async fn test_server_version_without_auth() {
15671568
.expect("We should not fail here since we did not provide an auth token.");
15681569
}
15691570

1571+
#[cfg(feature = "federation-api")]
15701572
#[async_test]
15711573
async fn test_server_vendor_info_with_missing_fields() {
15721574
let server = MatrixMockServer::new().await;

0 commit comments

Comments
 (0)