From 420ca26bf57766c8ffcaefcc94960962ac9b2701 Mon Sep 17 00:00:00 2001 From: Johannes Becker Date: Tue, 12 Jul 2022 10:44:56 +0200 Subject: [PATCH] fix(sdk): Can't assert identity without session --- crates/matrix-sdk/src/client/builder.rs | 7 +++++-- crates/matrix-sdk/src/http_client.rs | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/matrix-sdk/src/client/builder.rs b/crates/matrix-sdk/src/client/builder.rs index 77e5c639f..fa9b17c1f 100644 --- a/crates/matrix-sdk/src/client/builder.rs +++ b/crates/matrix-sdk/src/client/builder.rs @@ -239,8 +239,11 @@ impl ClientBuilder { /// All outgoing http requests will have a GET query key-value appended with /// `user_id` being the key and the `user_id` from the `Session` being - /// the value. Will error if there's no `Session`. This is called - /// [identity assertion] in the Matrix Application Service Spec + /// the value. This is called [identity assertion] in the + /// Matrix Application Service Spec. + /// + /// Requests that don't require authentication might not do identity + /// assertion. /// /// [identity assertion]: https://spec.matrix.org/unstable/application-service-api/#identity-assertion #[doc(hidden)] diff --git a/crates/matrix-sdk/src/http_client.rs b/crates/matrix-sdk/src/http_client.rs index 0d70eeb26..13b4fe25f 100644 --- a/crates/matrix-sdk/src/http_client.rs +++ b/crates/matrix-sdk/src/http_client.rs @@ -125,7 +125,8 @@ impl HttpClient { } trace!("Serializing request"); - let request = if !config.assert_identity { + // We can't assert the identity without a session. + let request = if !config.assert_identity || session.is_none() { let send_access_token = if auth_scheme == AuthScheme::None && !config.force_auth { // Small optimization: Don't take the session lock if we know the auth token // isn't going to be used anyways.