mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2025-12-24 00:01:03 -05:00
Upgrade Ruma
A new batch of breaking changes, allowing to stop providing dummy `SupportedVersions` where they are not necessary. Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
committed by
Damir Jelić
parent
dcd8aa13f0
commit
f78f1795eb
18
Cargo.lock
generated
18
Cargo.lock
generated
@@ -4822,7 +4822,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma"
|
||||
version = "0.13.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=670349f66f7e3f403c6730967768472dcf1bcf60#670349f66f7e3f403c6730967768472dcf1bcf60"
|
||||
source = "git+https://github.com/ruma/ruma?rev=bbb4a14e14864d364b78d605532db580eb2b28f0#bbb4a14e14864d364b78d605532db580eb2b28f0"
|
||||
dependencies = [
|
||||
"assign",
|
||||
"js_int",
|
||||
@@ -4839,7 +4839,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-client-api"
|
||||
version = "0.21.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=670349f66f7e3f403c6730967768472dcf1bcf60#670349f66f7e3f403c6730967768472dcf1bcf60"
|
||||
source = "git+https://github.com/ruma/ruma?rev=bbb4a14e14864d364b78d605532db580eb2b28f0#bbb4a14e14864d364b78d605532db580eb2b28f0"
|
||||
dependencies = [
|
||||
"as_variant",
|
||||
"assign",
|
||||
@@ -4862,7 +4862,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-common"
|
||||
version = "0.16.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=670349f66f7e3f403c6730967768472dcf1bcf60#670349f66f7e3f403c6730967768472dcf1bcf60"
|
||||
source = "git+https://github.com/ruma/ruma?rev=bbb4a14e14864d364b78d605532db580eb2b28f0#bbb4a14e14864d364b78d605532db580eb2b28f0"
|
||||
dependencies = [
|
||||
"as_variant",
|
||||
"base64",
|
||||
@@ -4895,7 +4895,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-events"
|
||||
version = "0.31.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=670349f66f7e3f403c6730967768472dcf1bcf60#670349f66f7e3f403c6730967768472dcf1bcf60"
|
||||
source = "git+https://github.com/ruma/ruma?rev=bbb4a14e14864d364b78d605532db580eb2b28f0#bbb4a14e14864d364b78d605532db580eb2b28f0"
|
||||
dependencies = [
|
||||
"as_variant",
|
||||
"indexmap",
|
||||
@@ -4921,7 +4921,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-federation-api"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=670349f66f7e3f403c6730967768472dcf1bcf60#670349f66f7e3f403c6730967768472dcf1bcf60"
|
||||
source = "git+https://github.com/ruma/ruma?rev=bbb4a14e14864d364b78d605532db580eb2b28f0#bbb4a14e14864d364b78d605532db580eb2b28f0"
|
||||
dependencies = [
|
||||
"headers",
|
||||
"http",
|
||||
@@ -4941,7 +4941,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-html"
|
||||
version = "0.5.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=670349f66f7e3f403c6730967768472dcf1bcf60#670349f66f7e3f403c6730967768472dcf1bcf60"
|
||||
source = "git+https://github.com/ruma/ruma?rev=bbb4a14e14864d364b78d605532db580eb2b28f0#bbb4a14e14864d364b78d605532db580eb2b28f0"
|
||||
dependencies = [
|
||||
"as_variant",
|
||||
"html5ever",
|
||||
@@ -4952,7 +4952,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-identifiers-validation"
|
||||
version = "0.11.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=670349f66f7e3f403c6730967768472dcf1bcf60#670349f66f7e3f403c6730967768472dcf1bcf60"
|
||||
source = "git+https://github.com/ruma/ruma?rev=bbb4a14e14864d364b78d605532db580eb2b28f0#bbb4a14e14864d364b78d605532db580eb2b28f0"
|
||||
dependencies = [
|
||||
"js_int",
|
||||
"thiserror 2.0.16",
|
||||
@@ -4961,7 +4961,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-macros"
|
||||
version = "0.16.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=670349f66f7e3f403c6730967768472dcf1bcf60#670349f66f7e3f403c6730967768472dcf1bcf60"
|
||||
source = "git+https://github.com/ruma/ruma?rev=bbb4a14e14864d364b78d605532db580eb2b28f0#bbb4a14e14864d364b78d605532db580eb2b28f0"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"proc-macro-crate",
|
||||
@@ -4976,7 +4976,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-signatures"
|
||||
version = "0.18.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=670349f66f7e3f403c6730967768472dcf1bcf60#670349f66f7e3f403c6730967768472dcf1bcf60"
|
||||
source = "git+https://github.com/ruma/ruma?rev=bbb4a14e14864d364b78d605532db580eb2b28f0#bbb4a14e14864d364b78d605532db580eb2b28f0"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"ed25519-dalek",
|
||||
|
||||
@@ -66,7 +66,7 @@ rand = "0.8.5"
|
||||
regex = "1.11.2"
|
||||
reqwest = { version = "0.12.23", default-features = false }
|
||||
rmp-serde = "1.3.0"
|
||||
ruma = { git = "https://github.com/ruma/ruma", rev = "670349f66f7e3f403c6730967768472dcf1bcf60", features = [
|
||||
ruma = { git = "https://github.com/ruma/ruma", rev = "bbb4a14e14864d364b78d605532db580eb2b28f0", features = [
|
||||
"client-api-c",
|
||||
"compat-upload-signatures",
|
||||
"compat-arbitrary-length-ids",
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
//! Types to interact with the native Matrix authentication API.
|
||||
|
||||
use std::fmt;
|
||||
#[cfg(feature = "sso-login")]
|
||||
use std::future::Future;
|
||||
use std::{borrow::Cow, fmt};
|
||||
|
||||
use matrix_sdk_base::{SessionMeta, store::RoomLoadSettings};
|
||||
use ruma::{
|
||||
@@ -112,13 +112,13 @@ impl MatrixAuth {
|
||||
.try_into_http_request::<Vec<u8>>(
|
||||
homeserver.as_str(),
|
||||
SendAccessToken::None,
|
||||
&supported_versions,
|
||||
Cow::Owned(supported_versions),
|
||||
)
|
||||
} else {
|
||||
sso_login::v3::Request::new(redirect_url.to_owned()).try_into_http_request::<Vec<u8>>(
|
||||
homeserver.as_str(),
|
||||
SendAccessToken::None,
|
||||
&supported_versions,
|
||||
Cow::Owned(supported_versions),
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
@@ -113,6 +113,8 @@ impl RendezvousChannel {
|
||||
client: HttpClient,
|
||||
rendezvous_server: &Url,
|
||||
) -> Result<Self, HttpError> {
|
||||
use std::borrow::Cow;
|
||||
|
||||
use ruma::api::{SupportedVersions, client::rendezvous::create_rendezvous_session};
|
||||
|
||||
let request = create_rendezvous_session::unstable::Request::default();
|
||||
@@ -122,7 +124,10 @@ impl RendezvousChannel {
|
||||
None,
|
||||
rendezvous_server.to_string(),
|
||||
None,
|
||||
&SupportedVersions { versions: Default::default(), features: Default::default() },
|
||||
Cow::Owned(SupportedVersions {
|
||||
versions: Default::default(),
|
||||
features: Default::default(),
|
||||
}),
|
||||
Default::default(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -14,10 +14,7 @@
|
||||
|
||||
use ruma::{
|
||||
OwnedServerName, ServerName,
|
||||
api::{
|
||||
MatrixVersion, SupportedVersions,
|
||||
client::discovery::{discover_homeserver, get_supported_versions},
|
||||
},
|
||||
api::client::discovery::{discover_homeserver, get_supported_versions},
|
||||
};
|
||||
use tracing::debug;
|
||||
use url::Url;
|
||||
@@ -185,10 +182,7 @@ async fn discover_homeserver(
|
||||
Some(RequestConfig::short_retry()),
|
||||
server.to_string(),
|
||||
None,
|
||||
&SupportedVersions {
|
||||
versions: [MatrixVersion::V1_0].into(),
|
||||
features: Default::default(),
|
||||
},
|
||||
(),
|
||||
Default::default(),
|
||||
)
|
||||
.await
|
||||
@@ -212,10 +206,7 @@ pub(super) async fn get_supported_versions(
|
||||
Some(RequestConfig::short_retry()),
|
||||
homeserver_url.to_string(),
|
||||
None,
|
||||
&SupportedVersions {
|
||||
versions: [MatrixVersion::V1_0].into(),
|
||||
features: Default::default(),
|
||||
},
|
||||
(),
|
||||
Default::default(),
|
||||
)
|
||||
.await
|
||||
|
||||
@@ -24,6 +24,7 @@ use ruma::api::{
|
||||
OutgoingRequest,
|
||||
client::{error::ErrorKind, media},
|
||||
error::FromHttpResponseError,
|
||||
path_builder::PathBuilder,
|
||||
};
|
||||
use tracing::{error, trace};
|
||||
|
||||
@@ -33,7 +34,7 @@ use crate::{
|
||||
authentication::oauth::OAuthError,
|
||||
config::RequestConfig,
|
||||
error::{HttpError, HttpResult},
|
||||
http_client::SupportedAuthScheme,
|
||||
http_client::{SupportedAuthScheme, SupportedPathBuilder},
|
||||
media::MediaError,
|
||||
};
|
||||
|
||||
@@ -79,6 +80,8 @@ impl<R> IntoFuture for SendRequest<R>
|
||||
where
|
||||
R: OutgoingRequest + Clone + Debug + SendOutsideWasm + SyncOutsideWasm + 'static,
|
||||
R::Authentication: SupportedAuthScheme,
|
||||
R::PathBuilder: SupportedPathBuilder,
|
||||
for<'a> <R::PathBuilder as PathBuilder>::Input<'a>: SendOutsideWasm + SyncOutsideWasm,
|
||||
R::IncomingResponse: SendOutsideWasm + SyncOutsideWasm,
|
||||
HttpError: From<FromHttpResponseError<R::EndpointError>>,
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ use ruma::{
|
||||
DeviceId, OwnedDeviceId, OwnedEventId, OwnedRoomId, OwnedRoomOrAliasId, OwnedServerName,
|
||||
RoomAliasId, RoomId, RoomOrAliasId, ServerName, UInt, UserId,
|
||||
api::{
|
||||
FeatureFlag, MatrixVersion, OutgoingRequest, SupportedVersions,
|
||||
FeatureFlag, MatrixVersion, Metadata, OutgoingRequest, SupportedVersions,
|
||||
client::{
|
||||
account::whoami,
|
||||
alias::{create_alias, delete_alias, get_alias},
|
||||
@@ -71,6 +71,7 @@ use ruma::{
|
||||
},
|
||||
error::FromHttpResponseError,
|
||||
federation::discovery::get_server_version,
|
||||
path_builder::PathBuilder,
|
||||
},
|
||||
assign,
|
||||
events::direct::DirectUserIdentifier,
|
||||
@@ -99,7 +100,7 @@ use crate::{
|
||||
EventHandler, EventHandlerContext, EventHandlerDropGuard, EventHandlerHandle,
|
||||
EventHandlerStore, ObservableEventHandler, SyncEvent,
|
||||
},
|
||||
http_client::{HttpClient, SupportedAuthScheme},
|
||||
http_client::{HttpClient, SupportedAuthScheme, SupportedPathBuilder},
|
||||
latest_events::LatestEvents,
|
||||
media::MediaError,
|
||||
notification_settings::NotificationSettings,
|
||||
@@ -1895,6 +1896,8 @@ impl Client {
|
||||
where
|
||||
Request: OutgoingRequest + Clone + Debug,
|
||||
Request::Authentication: SupportedAuthScheme,
|
||||
Request::PathBuilder: SupportedPathBuilder,
|
||||
for<'a> <Request::PathBuilder as PathBuilder>::Input<'a>: SendOutsideWasm + SyncOutsideWasm,
|
||||
HttpError: From<FromHttpResponseError<Request::EndpointError>>,
|
||||
{
|
||||
SendRequest {
|
||||
@@ -1914,10 +1917,13 @@ impl Client {
|
||||
where
|
||||
Request: OutgoingRequest + Debug,
|
||||
Request::Authentication: SupportedAuthScheme,
|
||||
Request::PathBuilder: SupportedPathBuilder,
|
||||
for<'a> <Request::PathBuilder as PathBuilder>::Input<'a>: SendOutsideWasm + SyncOutsideWasm,
|
||||
HttpError: From<FromHttpResponseError<Request::EndpointError>>,
|
||||
{
|
||||
let homeserver = self.homeserver().to_string();
|
||||
let access_token = self.access_token();
|
||||
let path_builder_input = Request::PathBuilder::get_path_builder_input(self).await?;
|
||||
|
||||
self.inner
|
||||
.http_client
|
||||
@@ -1926,7 +1932,7 @@ impl Client {
|
||||
config,
|
||||
homeserver,
|
||||
access_token.as_deref(),
|
||||
&self.supported_versions().await?,
|
||||
path_builder_input,
|
||||
send_progress,
|
||||
)
|
||||
.await
|
||||
@@ -1946,19 +1952,7 @@ impl Client {
|
||||
request_config: Option<RequestConfig>,
|
||||
) -> HttpResult<get_supported_versions::Response> {
|
||||
let server_versions = self
|
||||
.inner
|
||||
.http_client
|
||||
.send(
|
||||
get_supported_versions::Request::new(),
|
||||
request_config,
|
||||
self.homeserver().to_string(),
|
||||
None,
|
||||
&SupportedVersions {
|
||||
versions: [MatrixVersion::V1_0].into(),
|
||||
features: Default::default(),
|
||||
},
|
||||
Default::default(),
|
||||
)
|
||||
.send_inner(get_supported_versions::Request::new(), request_config, Default::default())
|
||||
.await?;
|
||||
|
||||
Ok(server_versions)
|
||||
@@ -1983,10 +1977,7 @@ impl Client {
|
||||
Some(RequestConfig::short_retry()),
|
||||
server_url_string,
|
||||
None,
|
||||
&SupportedVersions {
|
||||
versions: [MatrixVersion::V1_0].into(),
|
||||
features: Default::default(),
|
||||
},
|
||||
(),
|
||||
Default::default(),
|
||||
)
|
||||
.await;
|
||||
@@ -2925,8 +2916,8 @@ impl Client {
|
||||
|
||||
// Use the authenticated endpoint when the server supports it.
|
||||
let supported_versions = self.supported_versions().await?;
|
||||
let use_auth =
|
||||
authenticated_media::get_media_config::v1::Request::is_supported(&supported_versions);
|
||||
let use_auth = authenticated_media::get_media_config::v1::Request::PATH_BUILDER
|
||||
.is_supported(&supported_versions);
|
||||
|
||||
let upload_size = if use_auth {
|
||||
self.send(authenticated_media::get_media_config::v1::Request::default())
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
use std::{
|
||||
any::type_name,
|
||||
borrow::Cow,
|
||||
fmt::Debug,
|
||||
num::NonZeroUsize,
|
||||
sync::{
|
||||
@@ -27,14 +28,16 @@ use bytes::{Bytes, BytesMut};
|
||||
use bytesize::ByteSize;
|
||||
use eyeball::SharedObservable;
|
||||
use http::Method;
|
||||
use matrix_sdk_base::SendOutsideWasm;
|
||||
use ruma::api::{
|
||||
OutgoingRequest, SendAccessToken, SupportedVersions, auth_scheme,
|
||||
OutgoingRequest, SendAccessToken, auth_scheme,
|
||||
error::{FromHttpResponseError, IntoHttpError},
|
||||
path_builder,
|
||||
};
|
||||
use tokio::sync::{Semaphore, SemaphorePermit};
|
||||
use tracing::{debug, field::debug, instrument, trace};
|
||||
|
||||
use crate::{config::RequestConfig, error::HttpError};
|
||||
use crate::{HttpResult, config::RequestConfig, error::HttpError};
|
||||
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
mod native;
|
||||
@@ -101,7 +104,7 @@ impl HttpClient {
|
||||
config: RequestConfig,
|
||||
homeserver: String,
|
||||
access_token: Option<&str>,
|
||||
supported_versions: &SupportedVersions,
|
||||
path_builder_input: <R::PathBuilder as path_builder::PathBuilder>::Input<'_>,
|
||||
) -> Result<http::Request<Bytes>, IntoHttpError>
|
||||
where
|
||||
R: OutgoingRequest + Debug,
|
||||
@@ -120,7 +123,7 @@ impl HttpClient {
|
||||
};
|
||||
|
||||
let request = request
|
||||
.try_into_http_request::<BytesMut>(&homeserver, send_access_token, supported_versions)?
|
||||
.try_into_http_request::<BytesMut>(&homeserver, send_access_token, path_builder_input)?
|
||||
.map(|body| body.freeze());
|
||||
|
||||
Ok(request)
|
||||
@@ -128,7 +131,7 @@ impl HttpClient {
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[instrument(
|
||||
skip(self, request, config, homeserver, access_token, supported_versions, send_progress),
|
||||
skip(self, request, config, homeserver, access_token, path_builder_input, send_progress),
|
||||
fields(
|
||||
uri,
|
||||
method,
|
||||
@@ -146,7 +149,7 @@ impl HttpClient {
|
||||
config: Option<RequestConfig>,
|
||||
homeserver: String,
|
||||
access_token: Option<&str>,
|
||||
supported_versions: &SupportedVersions,
|
||||
path_builder_input: <R::PathBuilder as path_builder::PathBuilder>::Input<'_>,
|
||||
send_progress: SharedObservable<TransmissionProgress>,
|
||||
) -> Result<R::IncomingResponse, HttpError>
|
||||
where
|
||||
@@ -170,7 +173,7 @@ impl HttpClient {
|
||||
span.record("config", debug(config)).record("request_id", request_id);
|
||||
|
||||
let request = self
|
||||
.serialize_request(request, config, homeserver, access_token, supported_versions)
|
||||
.serialize_request(request, config, homeserver, access_token, path_builder_input)
|
||||
.map_err(HttpError::IntoHttp)?;
|
||||
|
||||
let method = request.method();
|
||||
@@ -260,6 +263,31 @@ impl SupportedAuthScheme for auth_scheme::AppserviceToken {}
|
||||
|
||||
impl SupportedAuthScheme for auth_scheme::AppserviceTokenOptional {}
|
||||
|
||||
/// Marker trait to identify the authentication schemes that the
|
||||
/// [`Client`](crate::Client) supports.
|
||||
///
|
||||
/// This trait can also be implemented for custom
|
||||
/// [`PathBuilder`](path_builder::PathBuilder)s if necessary.
|
||||
pub trait SupportedPathBuilder: path_builder::PathBuilder {
|
||||
fn get_path_builder_input(
|
||||
client: &crate::Client,
|
||||
) -> impl Future<Output = HttpResult<Self::Input<'static>>> + SendOutsideWasm;
|
||||
}
|
||||
|
||||
impl SupportedPathBuilder for path_builder::VersionHistory {
|
||||
async fn get_path_builder_input(
|
||||
client: &crate::Client,
|
||||
) -> HttpResult<Cow<'static, ruma::api::SupportedVersions>> {
|
||||
client.supported_versions().await.map(Cow::Owned)
|
||||
}
|
||||
}
|
||||
|
||||
impl SupportedPathBuilder for path_builder::SinglePath {
|
||||
async fn get_path_builder_input(_client: &crate::Client) -> HttpResult<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(test, not(target_family = "wasm")))]
|
||||
mod tests {
|
||||
use std::{
|
||||
|
||||
@@ -29,7 +29,7 @@ use mime::Mime;
|
||||
use ruma::{
|
||||
MilliSecondsSinceUnixEpoch, MxcUri, OwnedMxcUri, TransactionId, UInt,
|
||||
api::{
|
||||
OutgoingRequest,
|
||||
Metadata,
|
||||
client::{authenticated_media, error::ErrorKind, media},
|
||||
},
|
||||
assign,
|
||||
@@ -442,8 +442,8 @@ impl Media {
|
||||
|
||||
// Use the authenticated endpoints when the server supports it.
|
||||
let supported_versions = self.client.supported_versions().await?;
|
||||
let use_auth =
|
||||
authenticated_media::get_content::v1::Request::is_supported(&supported_versions);
|
||||
let use_auth = authenticated_media::get_content::v1::Request::PATH_BUILDER
|
||||
.is_supported(&supported_versions);
|
||||
|
||||
let content: Vec<u8> = match &request.source {
|
||||
MediaSource::Encrypted(file) => {
|
||||
|
||||
Reference in New Issue
Block a user