Skip to content

Commit c3acd0d

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 <[email protected]>
1 parent ab98028 commit c3acd0d

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ All notable changes to this project will be documented in this file.
88

99
### Refactor
1010

11+
- [**breaking**]: `Client::server_vendor_info()` requires to enable the
12+
`federation-api` feature.
13+
([#5912](https://github.com/matrix-org/matrix-rust-sdk/pull/5912))
1114
- [**breaking**]: `Client::reset_server_info()` has been split into
1215
`reset_supported_versions()` and `reset_well_known()`.
1316
([#5910](https://github.com/matrix-org/matrix-rust-sdk/pull/5910))

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
@@ -73,7 +73,6 @@ use ruma::{
7373
user_directory::search_users,
7474
},
7575
error::FromHttpResponseError,
76-
federation::discovery::get_server_version,
7776
path_builder::PathBuilder,
7877
},
7978
assign,
@@ -604,10 +603,13 @@ impl Client {
604603
/// );
605604
/// # anyhow::Ok(()) };
606605
/// ```
606+
#[cfg(feature = "federation-api")]
607607
pub async fn server_vendor_info(
608608
&self,
609609
request_config: Option<RequestConfig>,
610610
) -> HttpResult<ServerVendorInfo> {
611+
use ruma::api::federation::discovery::get_server_version;
612+
611613
let res = self
612614
.send_inner(get_server_version::v1::Request::new(), request_config, Default::default())
613615
.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)