mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-17 04:58:41 -04:00
Allow configuring assert_identity on the client level only
Completely removing it from RequestConfig is left up to a future refactoring.
This commit is contained in:
@@ -311,19 +311,16 @@ impl AppService {
|
||||
async fn create_and_cache_client(
|
||||
&self,
|
||||
localpart: &str,
|
||||
config: ClientConfig,
|
||||
mut config: ClientConfig,
|
||||
) -> Result<Client> {
|
||||
let user_id = UserId::parse_with_server_name(localpart, &self.server_name)?;
|
||||
|
||||
// The `as_token` in the `Session` maps to the [`MainUser`]
|
||||
// (`sender_localpart`) by default, so we don't need to assert identity
|
||||
// in that case
|
||||
let config = if localpart != self.registration.sender_localpart {
|
||||
let request_config = config.get_request_config().assert_identity();
|
||||
config.request_config(request_config)
|
||||
} else {
|
||||
config
|
||||
};
|
||||
if localpart != self.registration.sender_localpart {
|
||||
config = config.assert_identity();
|
||||
}
|
||||
|
||||
let client =
|
||||
Client::with_config(self.homeserver_url.clone(), config.appservice_mode()).await?;
|
||||
|
||||
@@ -236,4 +236,17 @@ impl ClientConfig {
|
||||
self.use_discovery_response = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// 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
|
||||
///
|
||||
/// [identity assertion]: https://spec.matrix.org/unstable/application-service-api/#identity-assertion
|
||||
#[cfg(feature = "appservice")]
|
||||
#[must_use]
|
||||
pub fn assert_identity(mut self) -> Self {
|
||||
self.request_config.assert_identity = true;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,17 +121,4 @@ impl RequestConfig {
|
||||
self.force_auth = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// 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
|
||||
///
|
||||
/// [identity assertion]: https://spec.matrix.org/unstable/application-service-api/#identity-assertion
|
||||
#[cfg(feature = "appservice")]
|
||||
#[must_use]
|
||||
pub fn assert_identity(mut self) -> Self {
|
||||
self.assert_identity = true;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user