From 1f2fd380b2f2eeb6a6ca89bc23d2a150bed49fde Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Wed, 2 Mar 2022 14:33:54 +0100 Subject: [PATCH] Upgrade Ruma to 0.5.0 --- crates/matrix-qrcode/Cargo.toml | 10 +- crates/matrix-sdk-appservice/Cargo.toml | 6 +- crates/matrix-sdk-appservice/src/error.rs | 2 +- crates/matrix-sdk-appservice/src/lib.rs | 6 +- crates/matrix-sdk-base/Cargo.toml | 6 +- crates/matrix-sdk-base/src/client.rs | 16 +- crates/matrix-sdk-base/src/media.rs | 2 +- crates/matrix-sdk-base/src/rooms/normal.rs | 2 +- crates/matrix-sdk-base/src/session.rs | 4 +- .../src/store/indexeddb_store.rs | 12 +- .../src/store/integration_tests.rs | 10 +- .../matrix-sdk-base/src/store/memory_store.rs | 13 +- crates/matrix-sdk-base/src/store/mod.rs | 7 +- .../matrix-sdk-base/src/store/sled_store.rs | 13 +- crates/matrix-sdk-common/Cargo.toml | 6 +- .../src/deserialized_responses.rs | 14 +- crates/matrix-sdk-crypto/Cargo.toml | 4 +- crates/matrix-sdk-crypto/README.md | 2 +- .../matrix-sdk-crypto/benches/crypto_bench.rs | 28 +-- .../src/backups/keys/backup.rs | 2 +- crates/matrix-sdk-crypto/src/backups/mod.rs | 4 +- .../src/gossiping/machine.rs | 2 +- .../src/identities/device.rs | 2 +- .../src/identities/manager.rs | 4 +- .../matrix-sdk-crypto/src/identities/user.rs | 4 +- crates/matrix-sdk-crypto/src/machine.rs | 30 +-- crates/matrix-sdk-crypto/src/olm/account.rs | 17 +- .../matrix-sdk-crypto/src/olm/signing/mod.rs | 30 ++- crates/matrix-sdk-crypto/src/requests.rs | 22 +- .../src/session_manager/group_sessions.rs | 10 +- .../src/session_manager/sessions.rs | 4 +- .../src/verification/machine.rs | 5 +- .../matrix-sdk-crypto/src/verification/mod.rs | 2 +- .../src/verification/qrcode.rs | 2 +- .../src/verification/sas/mod.rs | 2 +- crates/matrix-sdk-test/Cargo.toml | 6 +- crates/matrix-sdk-test/src/lib.rs | 2 +- crates/matrix-sdk/Cargo.toml | 3 +- .../examples/cross_signing_bootstrap.rs | 7 +- crates/matrix-sdk/examples/get_profiles.rs | 4 +- crates/matrix-sdk/src/account.rs | 62 +++--- crates/matrix-sdk/src/client.rs | 188 ++++++++++-------- crates/matrix-sdk/src/config/sync.rs | 6 +- crates/matrix-sdk/src/encryption/mod.rs | 38 ++-- crates/matrix-sdk/src/error.rs | 2 +- crates/matrix-sdk/src/http_client.rs | 14 +- crates/matrix-sdk/src/room/common.rs | 36 ++-- crates/matrix-sdk/src/room/joined.rs | 52 ++--- crates/matrix-sdk/src/room/left.rs | 4 +- crates/matrix-sdk/src/sync.rs | 4 +- 50 files changed, 377 insertions(+), 356 deletions(-) diff --git a/crates/matrix-qrcode/Cargo.toml b/crates/matrix-qrcode/Cargo.toml index b11e0075e..f897ebeaa 100644 --- a/crates/matrix-qrcode/Cargo.toml +++ b/crates/matrix-qrcode/Cargo.toml @@ -24,13 +24,7 @@ base64 = "0.13.0" byteorder = "1.4.3" image = { version = "0.23.14", optional = true } qrcode = { version = "0.12.0", default-features = false } +ruma-identifiers = "0.22.0" +ruma-serde = "0.6.0" rqrr = { version = "0.4.0", optional = true } thiserror = "1.0.25" - -[dependencies.ruma-identifiers] -git = "https://github.com/ruma/ruma/" -rev = "b9f32bc6327542d382d4eb42ec43623495c50e66" - -[dependencies.ruma-serde] -git = "https://github.com/ruma/ruma/" -rev = "b9f32bc6327542d382d4eb42ec43623495c50e66" diff --git a/crates/matrix-sdk-appservice/Cargo.toml b/crates/matrix-sdk-appservice/Cargo.toml index b77cfffa0..41a942a48 100644 --- a/crates/matrix-sdk-appservice/Cargo.toml +++ b/crates/matrix-sdk-appservice/Cargo.toml @@ -28,6 +28,7 @@ dashmap = "4" http = "0.2" matrix-sdk = { version = "0.4", path = "../matrix-sdk", default-features = false, features = ["appservice"] } regex = "1" +ruma = { version = "0.5.0", features = ["client-api-c", "appservice-api-s"] } serde = "1" serde_json = "1" serde_yaml = "0.8" @@ -36,11 +37,6 @@ tracing = "0.1" url = "2" warp = { version = "0.3.1", optional = true, default-features = false } -[dependencies.ruma] -git = "https://github.com/ruma/ruma/" -rev = "b9f32bc6327542d382d4eb42ec43623495c50e66" -features = ["client-api-c", "appservice-api-s"] - [dev-dependencies] matrix-sdk-test = { version = "0.4", path = "../matrix-sdk-test", features = ["appservice"] } mockito = "0.30" diff --git a/crates/matrix-sdk-appservice/src/error.rs b/crates/matrix-sdk-appservice/src/error.rs index 4f0dc7470..b28e35934 100644 --- a/crates/matrix-sdk-appservice/src/error.rs +++ b/crates/matrix-sdk-appservice/src/error.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use ruma::api::client::r0::uiaa::UiaaInfo; +use ruma::api::client::uiaa::UiaaInfo; use thiserror::Error; #[derive(Error, Debug)] diff --git a/crates/matrix-sdk-appservice/src/lib.rs b/crates/matrix-sdk-appservice/src/lib.rs index d783fc6f3..907aee572 100644 --- a/crates/matrix-sdk-appservice/src/lib.rs +++ b/crates/matrix-sdk-appservice/src/lib.rs @@ -105,7 +105,7 @@ use ruma::{ query::{query_room_alias::v1 as query_room, query_user_id::v1 as query_user}, Registration, }, - client::r0::account::register, + client::account::register, }, assign, identifiers, DeviceId, ServerName, UserId, }; @@ -448,7 +448,7 @@ impl AppService { *self.event_handler.rooms.lock().await = Some(handler); } - /// Register a virtual user by sending a [`register::Request`] to the + /// Register a virtual user by sending a [`register::v3::Request`] to the /// homeserver /// /// # Arguments @@ -463,7 +463,7 @@ impl AppService { if self.is_user_registered(localpart.as_ref()).await? { return Ok(()); } - let request = assign!(register::Request::new(), { + let request = assign!(register::v3::Request::new(), { username: Some(localpart.as_ref()), login_type: Some(®ister::LoginType::ApplicationService), }); diff --git a/crates/matrix-sdk-base/Cargo.toml b/crates/matrix-sdk-base/Cargo.toml index bb14f0e0e..aa0d4288d 100644 --- a/crates/matrix-sdk-base/Cargo.toml +++ b/crates/matrix-sdk-base/Cargo.toml @@ -46,6 +46,7 @@ matrix-sdk-common = { version = "0.4.0", path = "../matrix-sdk-common" } matrix-sdk-crypto = { version = "0.4.0", path = "../matrix-sdk-crypto", optional = true } pbkdf2 = { version = "0.10.0", default-features = false, optional = true } rand = { version = "0.8.4", optional = true } +ruma = { version = "0.5.0", features = ["client-api-c", "signatures", "unstable-pre-spec"] } serde = { version = "1.0.126", features = ["rc"] } serde_json = "1.0.64" sha2 = { version = "0.10.1", optional = true } @@ -61,11 +62,6 @@ tokio = { version = "1.7.1", optional = true, default-features = false, features indexed_db_futures = { version = "0.2.0", optional = true } wasm-bindgen = { version = "0.2.74", features = ["serde-serialize"], optional = true } -[dependencies.ruma] -git = "https://github.com/ruma/ruma/" -rev = "b9f32bc6327542d382d4eb42ec43623495c50e66" -features = ["client-api-c", "unstable-pre-spec"] - [dev-dependencies] futures = { version = "0.3.15", default-features = false, features = ["executor"] } http = "0.2.4" diff --git a/crates/matrix-sdk-base/src/client.rs b/crates/matrix-sdk-base/src/client.rs index 40cb62cff..be25ac6db 100644 --- a/crates/matrix-sdk-base/src/client.rs +++ b/crates/matrix-sdk-base/src/client.rs @@ -44,7 +44,7 @@ use matrix_sdk_crypto::{ }; #[cfg(feature = "encryption")] use ruma::{ - api::client::r0::keys::claim_keys::Request as KeysClaimRequest, + api::client::keys::claim_keys::v3::Request as KeysClaimRequest, events::{ room::{encrypted::RoomEncryptedEventContent, history_visibility::HistoryVisibility}, AnySyncMessageEvent, MessageEventContent, @@ -52,7 +52,7 @@ use ruma::{ DeviceId, TransactionId, }; use ruma::{ - api::client::r0::{self as api, push::get_notifications::Notification}, + api::client::{self as api, push::get_notifications::v3::Notification}, events::{ room::member::MembershipState, AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnyStrippedStateEvent, AnySyncEphemeralRoomEvent, AnySyncRoomEvent, AnySyncStateEvent, @@ -355,7 +355,7 @@ impl BaseClient { /// and device id. pub async fn receive_login_response( &self, - response: &api::session::login::Response, + response: &api::session::login::v3::Response, ) -> Result<()> { let session = Session { access_token: response.access_token.clone(), @@ -430,7 +430,7 @@ impl BaseClient { async fn handle_timeline( &self, room: &Room, - ruma_timeline: api::sync::sync_events::Timeline, + ruma_timeline: api::sync::sync_events::v3::Timeline, push_rules: &Ruleset, room_info: &mut RoomInfo, changes: &mut StateChanges, @@ -727,10 +727,10 @@ impl BaseClient { /// * `response` - The response that we received after a successful sync. pub async fn receive_sync_response( &self, - response: api::sync::sync_events::Response, + response: api::sync::sync_events::v3::Response, ) -> Result { #[allow(unused_variables)] - let api::sync::sync_events::Response { + let api::sync::sync_events::v3::Response { next_batch, rooms, presence, @@ -1009,7 +1009,7 @@ impl BaseClient { pub async fn receive_members( &self, room_id: &RoomId, - response: &api::membership::get_member_events::Response, + response: &api::membership::get_member_events::v3::Response, ) -> Result { let members: Vec = response .chunk @@ -1094,7 +1094,7 @@ impl BaseClient { pub async fn receive_filter_upload( &self, filter_name: &str, - response: &api::filter::create_filter::Response, + response: &api::filter::create_filter::v3::Response, ) -> Result<()> { Ok(self.store.save_filter(filter_name, &response.filter_id).await?) } diff --git a/crates/matrix-sdk-base/src/media.rs b/crates/matrix-sdk-base/src/media.rs index 6b33d9fcc..a8e12ceb3 100644 --- a/crates/matrix-sdk-base/src/media.rs +++ b/crates/matrix-sdk-base/src/media.rs @@ -1,7 +1,7 @@ //! Common types for [media content](https://matrix.org/docs/spec/client_server/r0.6.1#id66). use ruma::{ - api::client::r0::media::get_content_thumbnail::Method, + api::client::media::get_content_thumbnail::v3::Method, events::{ room::{ message::{ diff --git a/crates/matrix-sdk-base/src/rooms/normal.rs b/crates/matrix-sdk-base/src/rooms/normal.rs index 79462fdce..25b66d5fa 100644 --- a/crates/matrix-sdk-base/src/rooms/normal.rs +++ b/crates/matrix-sdk-base/src/rooms/normal.rs @@ -20,7 +20,7 @@ use futures_core::stream::Stream; use futures_util::stream::{self, StreamExt}; use matrix_sdk_common::locks::Mutex; use ruma::{ - api::client::r0::sync::sync_events::RoomSummary as RumaSummary, + api::client::sync::sync_events::v3::RoomSummary as RumaSummary, events::{ receipt::Receipt, room::{ diff --git a/crates/matrix-sdk-base/src/session.rs b/crates/matrix-sdk-base/src/session.rs index 57b668521..3386df2ff 100644 --- a/crates/matrix-sdk-base/src/session.rs +++ b/crates/matrix-sdk-base/src/session.rs @@ -45,8 +45,8 @@ pub struct Session { pub device_id: Box, } -impl From for Session { - fn from(response: ruma::api::client::r0::session::login::Response) -> Self { +impl From for Session { + fn from(response: ruma::api::client::session::login::v3::Response) -> Self { Self { access_token: response.access_token, user_id: response.user_id, diff --git a/crates/matrix-sdk-base/src/store/indexeddb_store.rs b/crates/matrix-sdk-base/src/store/indexeddb_store.rs index 112e33a91..293bd83ec 100644 --- a/crates/matrix-sdk-base/src/store/indexeddb_store.rs +++ b/crates/matrix-sdk-base/src/store/indexeddb_store.rs @@ -23,10 +23,11 @@ use ruma::{ receipt::Receipt, room::member::{MembershipState, RoomMemberEventContent}, AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnySyncMessageEvent, AnySyncRoomEvent, - AnySyncStateEvent, EventType, Redact, + AnySyncStateEvent, EventType, }, receipt::ReceiptType, serde::Raw, + signatures::{redact_in_place, CanonicalJsonObject}, EventId, MxcUri, RoomId, RoomVersionId, UserId, }; use serde::{Deserialize, Serialize}; @@ -623,10 +624,11 @@ impl IndexeddbStore { }) .transpose()? { - let inner_event = full_event.event.deserialize()?; - full_event.event = Raw::new(&AnySyncRoomEvent::from( - inner_event.redact(redaction, &room_version), - ))?; + let mut event_json: CanonicalJsonObject = + full_event.event.deserialize_as()?; + redact_in_place(&mut event_json, &room_version) + .map_err(StoreError::Redaction)?; + full_event.event = Raw::new(&event_json)?.cast(); timeline_store.put_key_val_owned( position_key, &self.serialize_event(&full_event)?, diff --git a/crates/matrix-sdk-base/src/store/integration_tests.rs b/crates/matrix-sdk-base/src/store/integration_tests.rs index b982ebd2a..72d1a180e 100644 --- a/crates/matrix-sdk-base/src/store/integration_tests.rs +++ b/crates/matrix-sdk-base/src/store/integration_tests.rs @@ -10,11 +10,11 @@ macro_rules! statestore_integration_tests { use matrix_sdk_test::{async_test, test_json}; use ruma::{ api::{ - client::r0::{ - media::get_content_thumbnail::Method, - message::get_message_events::Response as MessageResponse, - sync::sync_events::Response as SyncResponse, - }, + client::{ + media::get_content_thumbnail::v3::Method, + message::get_message_events::v3::Response as MessageResponse, + sync::sync_events::v3::Response as SyncResponse, + }, IncomingResponse, }, device_id, event_id, diff --git a/crates/matrix-sdk-base/src/store/memory_store.rs b/crates/matrix-sdk-base/src/store/memory_store.rs index 748d44eab..1121ec600 100644 --- a/crates/matrix-sdk-base/src/store/memory_store.rs +++ b/crates/matrix-sdk-base/src/store/memory_store.rs @@ -28,10 +28,11 @@ use ruma::{ receipt::Receipt, room::member::{MembershipState, RoomMemberEventContent}, AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnyStrippedStateEvent, - AnySyncMessageEvent, AnySyncRoomEvent, AnySyncStateEvent, EventType, Redact, + AnySyncMessageEvent, AnySyncRoomEvent, AnySyncStateEvent, EventType, }, receipt::ReceiptType, serde::Raw, + signatures::{redact_in_place, CanonicalJsonObject}, EventId, MxcUri, RoomId, RoomVersionId, UserId, }; #[allow(unused_imports)] @@ -41,6 +42,7 @@ use super::{BoxStream, Result, RoomInfo, StateChanges, StateStore}; use crate::{ deserialized_responses::{MemberEvent, StrippedMemberEvent, SyncRoomEvent}, media::{MediaRequest, UniqueKey}, + StoreError, }; #[allow(clippy::type_complexity)] @@ -352,12 +354,13 @@ impl MemoryStore { if let Some(position) = pos { if let Some(mut full_event) = data.events.get_mut(&position.clone()) { - let inner_event = full_event.event.deserialize()?; + let mut event_json: CanonicalJsonObject = + full_event.event.deserialize_as()?; let v = room_version.get_or_insert_with(make_room_version); - full_event.event = Raw::new(&AnySyncRoomEvent::from( - inner_event.redact(redaction, v), - ))?; + redact_in_place(&mut event_json, v) + .map_err(StoreError::Redaction)?; + full_event.event = Raw::new(&event_json)?.cast(); } } } diff --git a/crates/matrix-sdk-base/src/store/mod.rs b/crates/matrix-sdk-base/src/store/mod.rs index 9db6739d6..7ff465767 100644 --- a/crates/matrix-sdk-base/src/store/mod.rs +++ b/crates/matrix-sdk-base/src/store/mod.rs @@ -28,7 +28,7 @@ pub mod integration_tests; use dashmap::DashMap; use matrix_sdk_common::{async_trait, locks::RwLock, AsyncTraitDeps}; use ruma::{ - api::client::r0::push::get_notifications::Notification, + api::client::push::get_notifications::v3::Notification, events::{ presence::PresenceEvent, receipt::{Receipt, ReceiptEventContent}, @@ -113,6 +113,11 @@ pub enum StoreError { #[cfg(feature = "sled_state_store")] #[error(transparent)] Task(#[from] tokio::task::JoinError), + /// Redacting an event in the store has failed. + /// + /// This should never happen. + #[error("Redaction failed: {0}")] + Redaction(#[source] ruma::signatures::Error), } #[cfg(feature = "indexeddb_state_store")] diff --git a/crates/matrix-sdk-base/src/store/sled_store.rs b/crates/matrix-sdk-base/src/store/sled_store.rs index f602bf32a..8acfd6f63 100644 --- a/crates/matrix-sdk-base/src/store/sled_store.rs +++ b/crates/matrix-sdk-base/src/store/sled_store.rs @@ -30,10 +30,11 @@ use ruma::{ receipt::Receipt, room::member::{MembershipState, RoomMemberEventContent}, AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnySyncMessageEvent, AnySyncRoomEvent, - AnySyncStateEvent, EventType, Redact, + AnySyncStateEvent, EventType, }, receipt::ReceiptType, serde::Raw, + signatures::{redact_in_place, CanonicalJsonObject}, EventId, MxcUri, RoomId, RoomVersionId, UserId, }; use serde::{Deserialize, Serialize}; @@ -1181,11 +1182,11 @@ impl SledStore { }) .transpose()? { - let inner_event = full_event.event.deserialize()?; - - full_event.event = Raw::new(&AnySyncRoomEvent::from( - inner_event.redact(redaction, &room_version), - ))?; + let mut event_json: CanonicalJsonObject = + full_event.event.deserialize_as()?; + redact_in_place(&mut event_json, &room_version) + .map_err(StoreError::Redaction)?; + full_event.event = Raw::new(&event_json)?.cast(); timeline_batch .insert(position_key, self.serialize_event(&full_event)?); } diff --git a/crates/matrix-sdk-common/Cargo.toml b/crates/matrix-sdk-common/Cargo.toml index efe8cfceb..867ef23f0 100644 --- a/crates/matrix-sdk-common/Cargo.toml +++ b/crates/matrix-sdk-common/Cargo.toml @@ -17,13 +17,9 @@ targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"] [dependencies] async-trait = "0.1.50" +ruma = { version = "0.5.0", features = ["client-api-c"] } serde = "1.0.126" -[dependencies.ruma] -git = "https://github.com/ruma/ruma/" -rev = "b9f32bc6327542d382d4eb42ec43623495c50e66" -features = ["client-api-c"] - [target.'cfg(not(target_arch = "wasm32"))'.dependencies] uuid = { version = "0.8.2", default-features = false, features = [ "v4", diff --git a/crates/matrix-sdk-common/src/deserialized_responses.rs b/crates/matrix-sdk-common/src/deserialized_responses.rs index 158bae0bc..5cc77321e 100644 --- a/crates/matrix-sdk-common/src/deserialized_responses.rs +++ b/crates/matrix-sdk-common/src/deserialized_responses.rs @@ -1,9 +1,9 @@ use std::{collections::BTreeMap, convert::TryFrom}; use ruma::{ - api::client::r0::{ - push::get_notifications::Notification, - sync::sync_events::{ + api::client::{ + push::get_notifications::v3::Notification, + sync::sync_events::v3::{ DeviceLists, Ephemeral, GlobalAccountData, InvitedRoom, Presence, RoomAccountData, State, ToDevice, UnreadNotificationsCount as RumaUnreadNotificationsCount, }, @@ -411,23 +411,23 @@ mod test { fn room_event_to_sync_room_event() { let content = RoomMessageEventContent::text_plain("foobar"); - let event: AnyMessageEvent = MessageEvent { + let event = MessageEvent { content, event_id: event_id!("$xxxxx:example.org").to_owned(), room_id: room_id!("!someroom:example.com").to_owned(), origin_server_ts: MilliSecondsSinceUnixEpoch::now(), sender: user_id!("@carl:example.com").to_owned(), unsigned: Unsigned::default(), - } - .into(); + }; let room_event = - RoomEvent { event: Raw::new(&event.clone().into()).unwrap(), encryption_info: None }; + RoomEvent { event: Raw::new(&event).unwrap().cast(), encryption_info: None }; let converted_room_event: SyncRoomEvent = room_event.into(); let converted_event: AnySyncRoomEvent = converted_room_event.event.deserialize().unwrap(); + let event: AnyMessageEvent = event.into(); let sync_event: AnySyncMessageEvent = event.into(); let sync_event: AnySyncRoomEvent = sync_event.into(); diff --git a/crates/matrix-sdk-crypto/Cargo.toml b/crates/matrix-sdk-crypto/Cargo.toml index a01a88d3d..9879f6ede 100644 --- a/crates/matrix-sdk-crypto/Cargo.toml +++ b/crates/matrix-sdk-crypto/Cargo.toml @@ -50,9 +50,9 @@ zeroize = { version = "1.3.0", features = ["zeroize_derive"] } ## Feature indexeddb-state-store indexed_db_futures = { version = "0.2.0", optional = true } wasm-bindgen = { version = "0.2.74", features = ["serde-serialize"], optional = true } + [dependencies.ruma] -git = "https://github.com/ruma/ruma/" -rev = "b9f32bc6327542d382d4eb42ec43623495c50e66" +version = "0.5.0" features = ["client-api-c", "rand", "unstable-msc2676", "unstable-msc2677"] [dev-dependencies] diff --git a/crates/matrix-sdk-crypto/README.md b/crates/matrix-sdk-crypto/README.md index 8ce11a3e8..a37c3cccc 100644 --- a/crates/matrix-sdk-crypto/README.md +++ b/crates/matrix-sdk-crypto/README.md @@ -21,7 +21,7 @@ use std::{collections::BTreeMap, convert::TryFrom}; use matrix_sdk_crypto::{OlmMachine, OlmError}; use ruma::{ - api::client::r0::sync::sync_events::{ToDevice, DeviceLists}, + api::client::sync::sync_events::v3::{ToDevice, DeviceLists}, device_id, user_id, }; diff --git a/crates/matrix-sdk-crypto/benches/crypto_bench.rs b/crates/matrix-sdk-crypto/benches/crypto_bench.rs index 3fe4a45e8..153f9d2a7 100644 --- a/crates/matrix-sdk-crypto/benches/crypto_bench.rs +++ b/crates/matrix-sdk-crypto/benches/crypto_bench.rs @@ -5,9 +5,9 @@ use matrix_sdk_crypto::{EncryptionSettings, OlmMachine}; use matrix_sdk_test::response_from_file; use ruma::{ api::{ - client::r0::{ + client::{ keys::{claim_keys, get_keys}, - to_device::send_event_to_device::Response as ToDeviceResponse, + to_device::send_event_to_device::v3::Response as ToDeviceResponse, }, IncomingResponse, }, @@ -24,26 +24,28 @@ fn alice_device_id() -> &'static DeviceId { device_id!("JLAFKJWSCS") } -fn keys_query_response() -> get_keys::Response { +fn keys_query_response() -> get_keys::v3::Response { let data = include_bytes!("./keys_query.json"); let data: Value = serde_json::from_slice(data).unwrap(); let data = response_from_file(&data); - get_keys::Response::try_from_http_response(data).expect("Can't parse the keys upload response") -} - -fn keys_claim_response() -> claim_keys::Response { - let data = include_bytes!("./keys_claim.json"); - let data: Value = serde_json::from_slice(data).unwrap(); - let data = response_from_file(&data); - claim_keys::Response::try_from_http_response(data) + get_keys::v3::Response::try_from_http_response(data) .expect("Can't parse the keys upload response") } -fn huge_keys_query_response() -> get_keys::Response { +fn keys_claim_response() -> claim_keys::v3::Response { + let data = include_bytes!("./keys_claim.json"); + let data: Value = serde_json::from_slice(data).unwrap(); + let data = response_from_file(&data); + claim_keys::v3::Response::try_from_http_response(data) + .expect("Can't parse the keys upload response") +} + +fn huge_keys_query_response() -> get_keys::v3::Response { let data = include_bytes!("./keys_query_2000_members.json"); let data: Value = serde_json::from_slice(data).unwrap(); let data = response_from_file(&data); - get_keys::Response::try_from_http_response(data).expect("Can't parse the keys query response") + get_keys::v3::Response::try_from_http_response(data) + .expect("Can't parse the keys query response") } pub fn keys_query(c: &mut Criterion) { diff --git a/crates/matrix-sdk-crypto/src/backups/keys/backup.rs b/crates/matrix-sdk-crypto/src/backups/keys/backup.rs index 81e8361f3..4d47cbd0e 100644 --- a/crates/matrix-sdk-crypto/src/backups/keys/backup.rs +++ b/crates/matrix-sdk-crypto/src/backups/keys/backup.rs @@ -19,7 +19,7 @@ use std::{ use olm_rs::pk::OlmPkEncryption; use ruma::{ - api::client::r0::backup::{KeyBackupData, KeyBackupDataInit, SessionDataInit}, + api::client::backup::{KeyBackupData, KeyBackupDataInit, SessionDataInit}, DeviceKeyId, UserId, }; use zeroize::Zeroizing; diff --git a/crates/matrix-sdk-crypto/src/backups/mod.rs b/crates/matrix-sdk-crypto/src/backups/mod.rs index 651819958..f7facab27 100644 --- a/crates/matrix-sdk-crypto/src/backups/mod.rs +++ b/crates/matrix-sdk-crypto/src/backups/mod.rs @@ -30,7 +30,7 @@ use std::{ use matrix_sdk_common::locks::RwLock; use ruma::{ - api::client::r0::backup::RoomKeyBackup, serde::Raw, DeviceKeyAlgorithm, DeviceKeyId, RoomId, + api::client::backup::RoomKeyBackup, serde::Raw, DeviceKeyAlgorithm, DeviceKeyId, RoomId, TransactionId, UserId, }; use serde::{Deserialize, Serialize}; @@ -115,7 +115,7 @@ impl BackupMachine { /// and the given Ruma struct will lose the unspecced fields after a /// serialization cycle. /// - /// [`BackupAlgorithm`]: ruma::api::client::r0::backup::BackupAlgorithm + /// [`BackupAlgorithm`]: ruma::api::client::backup::BackupAlgorithm /// [`/room_keys/version`]: https://spec.matrix.org/unstable/client-server-api/#get_matrixclientv3room_keysversion pub async fn verify_backup( &self, diff --git a/crates/matrix-sdk-crypto/src/gossiping/machine.rs b/crates/matrix-sdk-crypto/src/gossiping/machine.rs index d1fdd0ddb..8baab8feb 100644 --- a/crates/matrix-sdk-crypto/src/gossiping/machine.rs +++ b/crates/matrix-sdk-crypto/src/gossiping/machine.rs @@ -24,7 +24,7 @@ use std::{collections::BTreeMap, sync::Arc}; use dashmap::{mapref::entry::Entry, DashMap, DashSet}; use ruma::{ - api::client::r0::keys::claim_keys::Request as KeysClaimRequest, + api::client::keys::claim_keys::v3::Request as KeysClaimRequest, events::{ forwarded_room_key::{ToDeviceForwardedRoomKeyEvent, ToDeviceForwardedRoomKeyEventContent}, room_key_request::{Action, RequestedKeyInfo, ToDeviceRoomKeyRequestEvent}, diff --git a/crates/matrix-sdk-crypto/src/identities/device.rs b/crates/matrix-sdk-crypto/src/identities/device.rs index 6b46073c9..d4823d2e2 100644 --- a/crates/matrix-sdk-crypto/src/identities/device.rs +++ b/crates/matrix-sdk-crypto/src/identities/device.rs @@ -25,7 +25,7 @@ use std::{ use atomic::Atomic; use matrix_sdk_common::locks::Mutex; use ruma::{ - api::client::r0::keys::upload_signatures::Request as SignatureUploadRequest, + api::client::keys::upload_signatures::v3::Request as SignatureUploadRequest, encryption::{DeviceKeys, SignedKey}, events::{ forwarded_room_key::ToDeviceForwardedRoomKeyEventContent, diff --git a/crates/matrix-sdk-crypto/src/identities/manager.rs b/crates/matrix-sdk-crypto/src/identities/manager.rs index 104d7a565..c54befbc4 100644 --- a/crates/matrix-sdk-crypto/src/identities/manager.rs +++ b/crates/matrix-sdk-crypto/src/identities/manager.rs @@ -22,7 +22,7 @@ use std::{ use futures_util::future::join_all; use matrix_sdk_common::executor::spawn; use ruma::{ - api::client::r0::keys::get_keys::Response as KeysQueryResponse, encryption::DeviceKeys, + api::client::keys::get_keys::v3::Response as KeysQueryResponse, encryption::DeviceKeys, serde::Raw, DeviceId, UserId, }; use tracing::{debug, info, trace, warn}; @@ -544,7 +544,7 @@ pub(crate) mod test { use matrix_sdk_common::locks::Mutex; use matrix_sdk_test::async_test; use ruma::{ - api::{client::r0::keys::get_keys::Response as KeyQueryResponse, IncomingResponse}, + api::{client::keys::get_keys::v3::Response as KeyQueryResponse, IncomingResponse}, device_id, user_id, DeviceId, UserId, }; use serde_json::json; diff --git a/crates/matrix-sdk-crypto/src/identities/user.rs b/crates/matrix-sdk-crypto/src/identities/user.rs index cb7a10117..c1d40739c 100644 --- a/crates/matrix-sdk-crypto/src/identities/user.rs +++ b/crates/matrix-sdk-crypto/src/identities/user.rs @@ -23,7 +23,7 @@ use std::{ }; use ruma::{ - api::client::r0::keys::upload_signatures::Request as SignatureUploadRequest, + api::client::keys::upload_signatures::v3::Request as SignatureUploadRequest, encryption::{CrossSigningKey, DeviceKeys, KeyUsage}, events::{ key::verification::VerificationMethod, room::message::KeyVerificationRequestEventContent, @@ -941,7 +941,7 @@ pub(crate) mod test { use matrix_sdk_common::locks::Mutex; use matrix_sdk_test::async_test; - use ruma::{api::client::r0::keys::get_keys::Response as KeyQueryResponse, user_id}; + use ruma::{api::client::keys::get_keys::v3::Response as KeyQueryResponse, user_id}; use super::{ReadOnlyOwnUserIdentity, ReadOnlyUserIdentities, ReadOnlyUserIdentity}; use crate::{ diff --git a/crates/matrix-sdk-crypto/src/machine.rs b/crates/matrix-sdk-crypto/src/machine.rs index 5e895e3ef..1fc314861 100644 --- a/crates/matrix-sdk-crypto/src/machine.rs +++ b/crates/matrix-sdk-crypto/src/machine.rs @@ -26,14 +26,14 @@ use matrix_sdk_common::{ locks::Mutex, }; use ruma::{ - api::client::r0::{ + api::client::{ keys::{ - claim_keys::{Request as KeysClaimRequest, Response as KeysClaimResponse}, - get_keys::Response as KeysQueryResponse, + claim_keys::v3::{Request as KeysClaimRequest, Response as KeysClaimResponse}, + get_keys::v3::Response as KeysQueryResponse, upload_keys, - upload_signatures::Request as UploadSignaturesRequest, + upload_signatures::v3::Request as UploadSignaturesRequest, }, - sync::sync_events::{DeviceLists, ToDevice}, + sync::sync_events::v3::{DeviceLists, ToDevice}, }, assign, events::{ @@ -483,7 +483,7 @@ impl OlmMachine { /// performed. async fn receive_keys_upload_response( &self, - response: &upload_keys::Response, + response: &upload_keys::v3::Response, ) -> OlmResult<()> { self.account.receive_keys_upload_response(response).await } @@ -557,14 +557,14 @@ impl OlmMachine { /// /// [`receive_keys_upload_response`]: #method.receive_keys_upload_response /// [`OlmMachine`]: struct.OlmMachine.html - async fn keys_for_upload(&self) -> Option { + async fn keys_for_upload(&self) -> Option { let (device_keys, one_time_keys) = self.account.keys_for_upload().await?; let device_keys = device_keys .map(|d| Raw::from_json(to_raw_value(&d).expect("Coulnd't serialize device keys"))); Some( - assign!(upload_keys::Request::new(), { device_keys, one_time_keys, fallback_keys: BTreeMap::new(), }), + assign!(upload_keys::v3::Request::new(), { device_keys, one_time_keys, fallback_keys: BTreeMap::new(), }), ) } @@ -1559,7 +1559,7 @@ pub(crate) mod test { use matrix_sdk_test::{async_test, test_json}; use ruma::{ api::{ - client::r0::keys::{claim_keys, get_keys, upload_keys}, + client::keys::{claim_keys, get_keys, upload_keys}, IncomingResponse, }, device_id, @@ -1607,15 +1607,15 @@ pub(crate) mod test { Response::builder().status(200).body(json.to_string().as_bytes().to_vec()).unwrap() } - fn keys_upload_response() -> upload_keys::Response { + fn keys_upload_response() -> upload_keys::v3::Response { let data = response_from_file(&test_json::KEYS_UPLOAD); - upload_keys::Response::try_from_http_response(data) + upload_keys::v3::Response::try_from_http_response(data) .expect("Can't parse the keys upload response") } - fn keys_query_response() -> get_keys::Response { + fn keys_query_response() -> get_keys::v3::Response { let data = response_from_file(&test_json::KEYS_QUERY); - get_keys::Response::try_from_http_response(data) + get_keys::v3::Response::try_from_http_response(data) .expect("Can't parse the keys upload response") } @@ -1683,7 +1683,7 @@ pub(crate) mod test { let mut one_time_keys = BTreeMap::new(); one_time_keys.insert(bob.user_id().to_owned(), bob_keys); - let response = claim_keys::Response::new(one_time_keys); + let response = claim_keys::v3::Response::new(one_time_keys); alice.receive_keys_claim_response(&response).await.unwrap(); @@ -1915,7 +1915,7 @@ pub(crate) mod test { let mut one_time_keys = BTreeMap::new(); one_time_keys.insert(bob_machine.user_id().to_owned(), bob_keys); - let response = claim_keys::Response::new(one_time_keys); + let response = claim_keys::v3::Response::new(one_time_keys); alice_machine.receive_keys_claim_response(&response).await.unwrap(); diff --git a/crates/matrix-sdk-crypto/src/olm/account.rs b/crates/matrix-sdk-crypto/src/olm/account.rs index 151eebe93..15d96b6f7 100644 --- a/crates/matrix-sdk-crypto/src/olm/account.rs +++ b/crates/matrix-sdk-crypto/src/olm/account.rs @@ -31,7 +31,10 @@ use olm_rs::{ PicklingMode, }; use ruma::{ - api::client::r0::keys::{upload_keys, upload_signatures::Request as SignatureUploadRequest}, + api::client::keys::{ + upload_keys, + upload_signatures::v3::{Request as SignatureUploadRequest, SignedKeys}, + }, encryption::{CrossSigningKey, DeviceKeys, OneTimeKey, SignedKey}, events::{ room::encrypted::{ @@ -250,7 +253,7 @@ impl Account { pub async fn receive_keys_upload_response( &self, - response: &upload_keys::Response, + response: &upload_keys::v3::Response, ) -> OlmResult<()> { if !self.inner.shared() { debug!("Marking account as shared"); @@ -829,17 +832,15 @@ impl ReadOnlyAccount { master_key: MasterPubkey, ) -> Result { let public_key = - master_key.get_first_key().ok_or(SignatureError::MissingSigningKey)?.to_string(); + master_key.get_first_key().ok_or(SignatureError::MissingSigningKey)?.into(); let mut cross_signing_key: CrossSigningKey = master_key.into(); cross_signing_key.signatures.clear(); self.sign_cross_signing_key(&mut cross_signing_key).await?; - let mut signed_keys = BTreeMap::new(); - signed_keys - .entry(self.user_id().to_owned()) - .or_insert_with(BTreeMap::new) - .insert(public_key, serde_json::to_value(cross_signing_key)?); + let mut user_signed_keys = SignedKeys::new(); + user_signed_keys.add_cross_signing_keys(public_key, Raw::new(&cross_signing_key)?); + let signed_keys = [(self.user_id().to_owned(), user_signed_keys)].into(); Ok(SignatureUploadRequest::new(signed_keys)) } diff --git a/crates/matrix-sdk-crypto/src/olm/signing/mod.rs b/crates/matrix-sdk-crypto/src/olm/signing/mod.rs index 32e403bd5..84be14269 100644 --- a/crates/matrix-sdk-crypto/src/olm/signing/mod.rs +++ b/crates/matrix-sdk-crypto/src/olm/signing/mod.rs @@ -14,20 +14,18 @@ mod pk_signing; -use std::{ - collections::BTreeMap, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, +use std::sync::{ + atomic::{AtomicBool, Ordering}, + Arc, }; use matrix_sdk_common::locks::Mutex; use pk_signing::{MasterSigning, PickledSignings, SelfSigning, Signing, SigningError, UserSigning}; use ruma::{ - api::client::r0::keys::upload_signatures::Request as SignatureUploadRequest, + api::client::keys::upload_signatures::v3::{Request as SignatureUploadRequest, SignedKeys}, encryption::{DeviceKeys, KeyUsage}, events::secret::request::SecretName, + serde::Raw, UserId, }; use serde::{Deserialize, Serialize}; @@ -404,17 +402,17 @@ impl PrivateCrossSigningIdentity { .sign_user(user_identity) .await?; - let mut signed_keys = BTreeMap::new(); - - signed_keys.entry(user_identity.user_id().to_owned()).or_insert_with(BTreeMap::new).insert( + let mut user_signed_keys = SignedKeys::new(); + user_signed_keys.add_cross_signing_keys( user_identity .master_key() .get_first_key() .ok_or(SignatureError::MissingSigningKey)? - .to_owned(), - serde_json::to_value(master_key)?, + .into(), + Raw::new(&master_key)?, ); + let signed_keys = [(user_identity.user_id().to_owned(), user_signed_keys)].into(); Ok(SignatureUploadRequest::new(signed_keys)) } @@ -449,12 +447,10 @@ impl PrivateCrossSigningIdentity { .sign_device(device_keys) .await?; - let mut signed_keys = BTreeMap::new(); - signed_keys - .entry((*self.user_id).to_owned()) - .or_insert_with(BTreeMap::new) - .insert(device_keys.device_id.to_string(), serde_json::to_value(device_keys)?); + let mut user_signed_keys = SignedKeys::new(); + user_signed_keys.add_device_keys(device_keys.device_id.clone(), Raw::new(device_keys)?); + let signed_keys = [((*self.user_id).to_owned(), user_signed_keys)].into(); Ok(SignatureUploadRequest::new(signed_keys)) } diff --git a/crates/matrix-sdk-crypto/src/requests.rs b/crates/matrix-sdk-crypto/src/requests.rs index 620fc55af..3714de645 100644 --- a/crates/matrix-sdk-crypto/src/requests.rs +++ b/crates/matrix-sdk-crypto/src/requests.rs @@ -15,19 +15,19 @@ use std::{collections::BTreeMap, iter, sync::Arc, time::Duration}; use ruma::{ - api::client::r0::{ - backup::{add_backup_keys::Response as KeysBackupResponse, RoomKeyBackup}, + api::client::{ + backup::{add_backup_keys::v3::Response as KeysBackupResponse, RoomKeyBackup}, keys::{ - claim_keys::{Request as KeysClaimRequest, Response as KeysClaimResponse}, - get_keys::Response as KeysQueryResponse, - upload_keys::{Request as KeysUploadRequest, Response as KeysUploadResponse}, - upload_signatures::{ + claim_keys::v3::{Request as KeysClaimRequest, Response as KeysClaimResponse}, + get_keys::v3::Response as KeysQueryResponse, + upload_keys::v3::{Request as KeysUploadRequest, Response as KeysUploadResponse}, + upload_signatures::v3::{ Request as SignatureUploadRequest, Response as SignatureUploadResponse, }, - upload_signing_keys::Response as SigningKeysUploadResponse, + upload_signing_keys::v3::Response as SigningKeysUploadResponse, }, - message::send_message_event::Response as RoomMessageResponse, - to_device::send_event_to_device::Response as ToDeviceResponse, + message::send_message_event::v3::Response as RoomMessageResponse, + to_device::send_event_to_device::v3::Response as ToDeviceResponse, }, encryption::CrossSigningKey, events::{AnyMessageEventContent, AnyToDeviceEventContent, EventContent, EventType}, @@ -38,7 +38,7 @@ use ruma::{ use serde::{Deserialize, Serialize}; /// Customized version of -/// `ruma_client_api::r0::to_device::send_event_to_device::Request` +/// `ruma_client_api::to_device::send_event_to_device::v3::Request` #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ToDeviceRequest { /// Type of event being sent to each device. @@ -144,7 +144,7 @@ pub struct UploadSigningKeysRequest { } /// Customized version of -/// `ruma_client_api::r0::keys::get_keys::Request`, without any +/// `ruma_client_api::keys::get_keys::v3::Request`, without any /// references. #[derive(Clone, Debug)] pub struct KeysQueryRequest { diff --git a/crates/matrix-sdk-crypto/src/session_manager/group_sessions.rs b/crates/matrix-sdk-crypto/src/session_manager/group_sessions.rs index fb67c4ac4..005878876 100644 --- a/crates/matrix-sdk-crypto/src/session_manager/group_sessions.rs +++ b/crates/matrix-sdk-crypto/src/session_manager/group_sessions.rs @@ -592,7 +592,7 @@ mod test { use matrix_sdk_test::{async_test, response_from_file}; use ruma::{ api::{ - client::r0::keys::{claim_keys, get_keys}, + client::keys::{claim_keys, get_keys}, IncomingResponse, }, device_id, room_id, user_id, DeviceId, TransactionId, UserId, @@ -609,19 +609,19 @@ mod test { device_id!("JLAFKJWSCS") } - fn keys_query_response() -> get_keys::Response { + fn keys_query_response() -> get_keys::v3::Response { let data = include_bytes!("../../benches/keys_query.json"); let data: Value = serde_json::from_slice(data).unwrap(); let data = response_from_file(&data); - get_keys::Response::try_from_http_response(data) + get_keys::v3::Response::try_from_http_response(data) .expect("Can't parse the keys upload response") } - fn keys_claim_response() -> claim_keys::Response { + fn keys_claim_response() -> claim_keys::v3::Response { let data = include_bytes!("../../benches/keys_claim.json"); let data: Value = serde_json::from_slice(data).unwrap(); let data = response_from_file(&data); - claim_keys::Response::try_from_http_response(data) + claim_keys::v3::Response::try_from_http_response(data) .expect("Can't parse the keys upload response") } diff --git a/crates/matrix-sdk-crypto/src/session_manager/sessions.rs b/crates/matrix-sdk-crypto/src/session_manager/sessions.rs index f8d4de5a6..84d62d5f2 100644 --- a/crates/matrix-sdk-crypto/src/session_manager/sessions.rs +++ b/crates/matrix-sdk-crypto/src/session_manager/sessions.rs @@ -20,7 +20,7 @@ use std::{ use dashmap::{DashMap, DashSet}; use ruma::{ - api::client::r0::keys::claim_keys::{ + api::client::keys::claim_keys::v3::{ Request as KeysClaimRequest, Response as KeysClaimResponse, }, assign, @@ -338,7 +338,7 @@ mod test { use matrix_sdk_common::locks::Mutex; use matrix_sdk_test::async_test; use ruma::{ - api::client::r0::keys::claim_keys::Response as KeyClaimResponse, device_id, user_id, + api::client::keys::claim_keys::v3::Response as KeyClaimResponse, device_id, user_id, DeviceId, UserId, }; diff --git a/crates/matrix-sdk-crypto/src/verification/machine.rs b/crates/matrix-sdk-crypto/src/verification/machine.rs index 03d815a11..2be7e80af 100644 --- a/crates/matrix-sdk-crypto/src/verification/machine.rs +++ b/crates/matrix-sdk-crypto/src/verification/machine.rs @@ -251,8 +251,9 @@ impl VerificationMachine { let event = ToDeviceEvent { content, sender: self.own_user_id().to_owned() }; events.push( - Raw::new(&AnyToDeviceEvent::KeyVerificationCancel(event)) - .expect("Failed to serialize m.key_verification.cancel event"), + Raw::new(&event) + .expect("Failed to serialize m.key_verification.cancel event") + .cast(), ); } diff --git a/crates/matrix-sdk-crypto/src/verification/mod.rs b/crates/matrix-sdk-crypto/src/verification/mod.rs index dd81d428e..905b425ef 100644 --- a/crates/matrix-sdk-crypto/src/verification/mod.rs +++ b/crates/matrix-sdk-crypto/src/verification/mod.rs @@ -36,7 +36,7 @@ use ruma::events::key::verification::done::{ KeyVerificationDoneEventContent, ToDeviceKeyVerificationDoneEventContent, }; use ruma::{ - api::client::r0::keys::upload_signatures::Request as SignatureUploadRequest, + api::client::keys::upload_signatures::v3::Request as SignatureUploadRequest, events::{ key::verification::{ cancel::{ diff --git a/crates/matrix-sdk-crypto/src/verification/qrcode.rs b/crates/matrix-sdk-crypto/src/verification/qrcode.rs index 0f311a9e9..047290a4b 100644 --- a/crates/matrix-sdk-crypto/src/verification/qrcode.rs +++ b/crates/matrix-sdk-crypto/src/verification/qrcode.rs @@ -19,7 +19,7 @@ use matrix_qrcode::{ SelfVerificationNoMasterKey, VerificationData, }; use ruma::{ - api::client::r0::keys::upload_signatures::Request as SignatureUploadRequest, + api::client::keys::upload_signatures::v3::Request as SignatureUploadRequest, events::{ key::verification::{ cancel::CancelCode, diff --git a/crates/matrix-sdk-crypto/src/verification/sas/mod.rs b/crates/matrix-sdk-crypto/src/verification/sas/mod.rs index 734ee7574..388f8d7a3 100644 --- a/crates/matrix-sdk-crypto/src/verification/sas/mod.rs +++ b/crates/matrix-sdk-crypto/src/verification/sas/mod.rs @@ -22,7 +22,7 @@ use inner_sas::InnerSas; #[cfg(test)] use matrix_sdk_common::instant::Instant; use ruma::{ - api::client::r0::keys::upload_signatures::Request as SignatureUploadRequest, + api::client::keys::upload_signatures::v3::Request as SignatureUploadRequest, events::{ key::verification::{cancel::CancelCode, ShortAuthenticationString}, AnyMessageEventContent, AnyToDeviceEventContent, diff --git a/crates/matrix-sdk-test/Cargo.toml b/crates/matrix-sdk-test/Cargo.toml index 951182a99..cfd3ce57c 100644 --- a/crates/matrix-sdk-test/Cargo.toml +++ b/crates/matrix-sdk-test/Cargo.toml @@ -18,10 +18,6 @@ appservice = [] http = "0.2.4" lazy_static = "1.4.0" matrix-sdk-test-macros = { version = "0.1.0", path = "../matrix-sdk-test-macros" } +ruma = { version = "0.5.0", features = ["client-api-c"] } serde = "1.0.126" serde_json = "1.0.64" - -[dependencies.ruma] -git = "https://github.com/ruma/ruma/" -rev = "b9f32bc6327542d382d4eb42ec43623495c50e66" -features = ["client-api-c"] diff --git a/crates/matrix-sdk-test/src/lib.rs b/crates/matrix-sdk-test/src/lib.rs index bf9a8cfee..2d968c768 100644 --- a/crates/matrix-sdk-test/src/lib.rs +++ b/crates/matrix-sdk-test/src/lib.rs @@ -3,7 +3,7 @@ use std::{collections::HashMap, panic}; use http::Response; pub use matrix_sdk_test_macros::async_test; use ruma::{ - api::{client::r0::sync::sync_events::Response as SyncResponse, IncomingResponse}, + api::{client::sync::sync_events::v3::Response as SyncResponse, IncomingResponse}, events::{ presence::PresenceEvent, AnyGlobalAccountDataEvent, AnySyncEphemeralRoomEvent, AnySyncRoomEvent, AnySyncStateEvent, diff --git a/crates/matrix-sdk/Cargo.toml b/crates/matrix-sdk/Cargo.toml index 98497eb2b..12dfe2833 100644 --- a/crates/matrix-sdk/Cargo.toml +++ b/crates/matrix-sdk/Cargo.toml @@ -99,8 +99,7 @@ version = "0.11.3" default_features = false [dependencies.ruma] -git = "https://github.com/ruma/ruma/" -rev = "b9f32bc6327542d382d4eb42ec43623495c50e66" +version = "0.5.0" features = ["client-api-c", "compat", "rand", "unstable-msc2448", "unstable-pre-spec"] [dependencies.tokio-stream] diff --git a/crates/matrix-sdk/examples/cross_signing_bootstrap.rs b/crates/matrix-sdk/examples/cross_signing_bootstrap.rs index 445805ab7..c9a9838b0 100644 --- a/crates/matrix-sdk/examples/cross_signing_bootstrap.rs +++ b/crates/matrix-sdk/examples/cross_signing_bootstrap.rs @@ -15,11 +15,14 @@ async fn bootstrap(client: Client, user_id: Box, password: String) { io::stdin().read_line(&mut input).expect("error: unable to read user input"); if let Err(e) = client.bootstrap_cross_signing(None).await { - use matrix_sdk::ruma::{api::client::r0::uiaa, assign}; + use matrix_sdk::ruma::{api::client::uiaa, assign}; if let Some(response) = e.uiaa_response() { let auth_data = uiaa::AuthData::Password(assign!( - uiaa::Password::new(uiaa::UserIdentifier::MatrixId(user_id.as_str()), &password), + uiaa::Password::new( + uiaa::UserIdentifier::UserIdOrLocalpart(user_id.as_str()), + &password, + ), { session: response.session.as_deref() } )); diff --git a/crates/matrix-sdk/examples/get_profiles.rs b/crates/matrix-sdk/examples/get_profiles.rs index 030ff6444..02c9853e4 100644 --- a/crates/matrix-sdk/examples/get_profiles.rs +++ b/crates/matrix-sdk/examples/get_profiles.rs @@ -1,7 +1,7 @@ use std::{env, process::exit}; use matrix_sdk::{ - ruma::{api::client::r0::profile, MxcUri, UserId}, + ruma::{api::client::profile, MxcUri, UserId}, Client, Result as MatrixResult, }; use url::Url; @@ -19,7 +19,7 @@ struct UserProfile { async fn get_profile(client: Client, mxid: &UserId) -> MatrixResult { // First construct the request you want to make // See https://docs.rs/ruma-client-api/0.9.0/ruma_client_api/index.html for all available Endpoints - let request = profile::get_profile::Request::new(mxid); + let request = profile::get_profile::v3::Request::new(mxid); // Start the request using matrix_sdk::Client::send let resp = client.send(request, None).await?; diff --git a/crates/matrix-sdk/src/account.rs b/crates/matrix-sdk/src/account.rs index 65ecb8f42..1db85f5ab 100644 --- a/crates/matrix-sdk/src/account.rs +++ b/crates/matrix-sdk/src/account.rs @@ -19,7 +19,7 @@ use std::io::Read; use matrix_sdk_base::media::{MediaFormat, MediaRequest, MediaType}; use mime::Mime; use ruma::{ - api::client::r0::{ + api::client::{ account::{ add_3pid, change_password, deactivate, delete_3pid, get_3pids, request_3pid_management_token_via_email, request_3pid_management_token_via_msisdn, @@ -70,7 +70,7 @@ impl Account { /// ``` pub async fn get_display_name(&self) -> Result> { let user_id = self.client.user_id().await.ok_or(Error::AuthenticationRequired)?; - let request = get_display_name::Request::new(&user_id); + let request = get_display_name::v3::Request::new(&user_id); let response = self.client.send(request, None).await?; Ok(response.displayname) } @@ -93,7 +93,7 @@ impl Account { /// ``` pub async fn set_display_name(&self, name: Option<&str>) -> Result<()> { let user_id = self.client.user_id().await.ok_or(Error::AuthenticationRequired)?; - let request = set_display_name::Request::new(&user_id, name); + let request = set_display_name::v3::Request::new(&user_id, name); self.client.send(request, None).await?; Ok(()) } @@ -118,7 +118,7 @@ impl Account { /// ``` pub async fn get_avatar_url(&self) -> Result>> { let user_id = self.client.user_id().await.ok_or(Error::AuthenticationRequired)?; - let request = get_avatar_url::Request::new(&user_id); + let request = get_avatar_url::v3::Request::new(&user_id); let config = Some(RequestConfig::new().force_auth()); @@ -131,7 +131,7 @@ impl Account { /// The avatar is unset if `url` is `None`. pub async fn set_avatar_url(&self, url: Option<&MxcUri>) -> Result<()> { let user_id = self.client.user_id().await.ok_or(Error::AuthenticationRequired)?; - let request = set_avatar_url::Request::new(&user_id, url); + let request = set_avatar_url::v3::Request::new(&user_id, url); self.client.send(request, None).await?; Ok(()) } @@ -231,9 +231,9 @@ impl Account { /// } /// # Result::<_, matrix_sdk::Error>::Ok(()) }); /// ``` - pub async fn get_profile(&self) -> Result { + pub async fn get_profile(&self) -> Result { let user_id = self.client.user_id().await.ok_or(Error::AuthenticationRequired)?; - let request = get_profile::Request::new(&user_id); + let request = get_profile::v3::Request::new(&user_id); Ok(self.client.send(request, None).await?) } @@ -260,8 +260,8 @@ impl Account { /// # use std::convert::TryFrom; /// # use matrix_sdk::Client; /// # use matrix_sdk::ruma::{ - /// # api::client::r0::{ - /// # account::change_password::{Request as ChangePasswordRequest}, + /// # api::client::{ + /// # account::change_password::v3::{Request as ChangePasswordRequest}, /// # uiaa::{AuthData, Dummy}, /// # }, /// # assign, @@ -278,14 +278,14 @@ impl Account { /// # Result::<_, matrix_sdk::Error>::Ok(()) }); /// ``` /// [uiaa]: https://spec.matrix.org/v1.2/client-server-api/#user-interactive-authentication-api - /// [`UiaaResponse`]: ruma::api::client::r0::uiaa::UiaaResponse + /// [`UiaaResponse`]: ruma::api::client::uiaa::UiaaResponse /// [`ErrorKind::WeakPassword`]: ruma::api::client::error::ErrorKind::WeakPassword pub async fn change_password( &self, new_password: &str, auth_data: Option>, - ) -> Result { - let request = assign!(change_password::Request::new(new_password), { + ) -> Result { + let request = assign!(change_password::v3::Request::new(new_password), { auth: auth_data, }); Ok(self.client.send(request, None).await?) @@ -309,8 +309,8 @@ impl Account { /// # use std::convert::TryFrom; /// # use matrix_sdk::Client; /// # use matrix_sdk::ruma::{ - /// # api::client::r0::{ - /// # account::change_password::{Request as ChangePasswordRequest}, + /// # api::client::{ + /// # account::change_password::v3::{Request as ChangePasswordRequest}, /// # uiaa::{AuthData, Dummy}, /// # }, /// # assign, @@ -329,13 +329,13 @@ impl Account { /// ``` /// [3pid]: https://spec.matrix.org/v1.2/appendices/#3pid-types /// [uiaa]: https://spec.matrix.org/v1.2/client-server-api/#user-interactive-authentication-api - /// [`UiaaResponse`]: ruma::api::client::r0::uiaa::UiaaResponse + /// [`UiaaResponse`]: ruma::api::client::uiaa::UiaaResponse pub async fn deactivate( &self, id_server: Option<&str>, auth_data: Option>, - ) -> Result { - let request = assign!(deactivate::Request::new(), { + ) -> Result { + let request = assign!(deactivate::v3::Request::new(), { id_server, auth: auth_data, }); @@ -364,8 +364,8 @@ impl Account { /// # Result::<_, matrix_sdk::Error>::Ok(()) }); /// ``` /// [3pid]: https://spec.matrix.org/v1.2/appendices/#3pid-types - pub async fn get_3pids(&self) -> Result { - let request = get_3pids::Request::new(); + pub async fn get_3pids(&self) -> Result { + let request = get_3pids::v3::Request::new(); Ok(self.client.send(request, None).await?) } @@ -438,8 +438,8 @@ impl Account { client_secret: &ClientSecret, email: &str, send_attempt: UInt, - ) -> Result { - let request = request_3pid_management_token_via_email::Request::new( + ) -> Result { + let request = request_3pid_management_token_via_email::v3::Request::new( client_secret, email, send_attempt, @@ -521,8 +521,8 @@ impl Account { country: &str, phone_number: &str, send_attempt: UInt, - ) -> Result { - let request = request_3pid_management_token_via_msisdn::Request::new( + ) -> Result { + let request = request_3pid_management_token_via_msisdn::v3::Request::new( client_secret, country, phone_number, @@ -559,14 +559,14 @@ impl Account { /// /// [3pid]: https://spec.matrix.org/v1.2/appendices/#3pid-types /// [uiaa]: https://spec.matrix.org/v1.2/client-server-api/#user-interactive-authentication-api - /// [`UiaaResponse`]: ruma::api::client::r0::uiaa::UiaaResponse + /// [`UiaaResponse`]: ruma::api::client::uiaa::UiaaResponse pub async fn add_3pid( &self, client_secret: &ClientSecret, sid: &SessionId, auth_data: Option>, - ) -> Result { - let request = assign!(add_3pid::Request::new(client_secret, sid), { + ) -> Result { + let request = assign!(add_3pid::v3::Request::new(client_secret, sid), { auth: auth_data, }); Ok(self.client.send(request, None).await?) @@ -599,7 +599,7 @@ impl Account { /// # use futures::executor::block_on; /// # use matrix_sdk::Client; /// # use matrix_sdk::ruma::thirdparty::Medium; - /// # use matrix_sdk::ruma::api::client::r0::account::ThirdPartyIdRemovalStatus; + /// # use matrix_sdk::ruma::api::client::account::ThirdPartyIdRemovalStatus; /// # use url::Url; /// # block_on(async { /// # let homeserver = Url::parse("http://localhost:8080")?; @@ -619,15 +619,15 @@ impl Account { /// # Result::<_, matrix_sdk::Error>::Ok(()) }); /// ``` /// [3pid]: https://spec.matrix.org/v1.2/appendices/#3pid-types - /// [`ThirdPartyIdRemovalStatus::Success`]: ruma::api::client::r0::account::ThirdPartyIdRemovalStatus::Success - /// [`ThirdPartyIdRemovalStatus::NoSupport`]: ruma::api::client::r0::account::ThirdPartyIdRemovalStatus::NoSupport + /// [`ThirdPartyIdRemovalStatus::Success`]: ruma::api::client::account::ThirdPartyIdRemovalStatus::Success + /// [`ThirdPartyIdRemovalStatus::NoSupport`]: ruma::api::client::account::ThirdPartyIdRemovalStatus::NoSupport pub async fn delete_3pid( &self, address: &str, medium: Medium, id_server: Option<&str>, - ) -> Result { - let request = assign!(delete_3pid::Request::new(medium, address), { + ) -> Result { + let request = assign!(delete_3pid::v3::Request::new(medium, address), { id_server: id_server, }); Ok(self.client.send(request, None).await?) diff --git a/crates/matrix-sdk/src/client.rs b/crates/matrix-sdk/src/client.rs index e0f7e9a1f..fe9afa9eb 100644 --- a/crates/matrix-sdk/src/client.rs +++ b/crates/matrix-sdk/src/client.rs @@ -41,25 +41,22 @@ use ruma::TransactionId; use ruma::{ api::{ client::{ - r0::{ - account::{register, whoami}, - capabilities::{get_capabilities, Capabilities}, - device::{delete_devices, get_devices}, - directory::{get_public_rooms, get_public_rooms_filtered}, - filter::{create_filter::Request as FilterUploadRequest, FilterDefinition}, - media::{create_content, get_content, get_content_thumbnail}, - membership::{join_room_by_id, join_room_by_id_or_alias}, - push::get_notifications::Notification, - room::create_room, - session::{get_login_types, login, sso_login}, - sync::sync_events, - uiaa::{AuthData, UserIdentifier}, - }, - session::sso_login_with_provider::v3 as sso_login_with_provider, - unversioned::{discover_homeserver, get_supported_versions}, + account::{register, whoami}, + capabilities::{get_capabilities, Capabilities}, + device::{delete_devices, get_devices}, + directory::{get_public_rooms, get_public_rooms_filtered}, + discover::{discover_homeserver, get_supported_versions}, + filter::{create_filter::v3::Request as FilterUploadRequest, FilterDefinition}, + media::{create_content, get_content, get_content_thumbnail}, + membership::{join_room_by_id, join_room_by_id_or_alias}, + push::get_notifications::v3::Notification, + room::create_room, + session::{get_login_types, login, sso_login, sso_login_with_provider}, + sync::sync_events, + uiaa::{AuthData, UserIdentifier}, }, error::FromHttpResponseError, - OutgoingRequest, SendAccessToken, + MatrixVersion, OutgoingRequest, SendAccessToken, }, assign, presence::PresenceState, @@ -367,7 +364,7 @@ impl Client { /// # Result::<_, anyhow::Error>::Ok(()) }); /// ``` pub async fn get_capabilities(&self) -> HttpResult { - let res = self.send(get_capabilities::Request::new(), None).await?; + let res = self.send(get_capabilities::v3::Request::new(), None).await?; Ok(res.capabilities) } @@ -722,8 +719,8 @@ impl Client { /// /// This should be the first step when trying to login so you can call the /// appropriate method for the next step. - pub async fn get_login_types(&self) -> HttpResult { - let request = get_login_types::Request::new(); + pub async fn get_login_types(&self) -> HttpResult { + let request = get_login_types::v3::Request::new(); self.send(request, None).await } @@ -751,11 +748,20 @@ impl Client { let homeserver = self.homeserver().await; let request = if let Some(id) = idp_id { - sso_login_with_provider::Request::new(id, redirect_url) - .try_into_http_request::>(homeserver.as_str(), SendAccessToken::None) + sso_login_with_provider::v3::Request::new(id, redirect_url) + .try_into_http_request::>( + homeserver.as_str(), + SendAccessToken::None, + // FIXME: Use versions reported by server + &[MatrixVersion::V1_0], + ) } else { - sso_login::Request::new(redirect_url) - .try_into_http_request::>(homeserver.as_str(), SendAccessToken::None) + sso_login::v3::Request::new(redirect_url).try_into_http_request::>( + homeserver.as_str(), + SendAccessToken::None, + // FIXME: Use versions reported by server + &[MatrixVersion::V1_0], + ) }; match request { @@ -816,16 +822,16 @@ impl Client { password: &str, device_id: Option<&str>, initial_device_display_name: Option<&str>, - ) -> Result { + ) -> Result { let homeserver = self.homeserver().await; info!(homeserver = homeserver.as_str(), user = user.as_ref(), "Logging in"); - let login_info = login::LoginInfo::Password(login::Password::new( - UserIdentifier::MatrixId(user.as_ref()), + let login_info = login::v3::LoginInfo::Password(login::v3::Password::new( + UserIdentifier::UserIdOrLocalpart(user.as_ref()), password, )); - let request = assign!(login::Request::new(login_info), { + let request = assign!(login::v3::Request::new(login_info), { device_id: device_id.map(|d| d.into()), initial_device_display_name, }); @@ -927,7 +933,7 @@ impl Client { device_id: Option<&str>, initial_device_display_name: Option<&str>, idp_id: Option<&str>, - ) -> Result + ) -> Result where C: Future>, { @@ -1101,12 +1107,12 @@ impl Client { token: &str, device_id: Option<&str>, initial_device_display_name: Option<&str>, - ) -> Result { + ) -> Result { info!("Logging in to {}", self.homeserver().await); let request = assign!( - login::Request::new( - login::LoginInfo::Token(login::Token::new(token)), + login::v3::Request::new( + login::v3::LoginInfo::Token(login::v3::Token::new(token)), ), { device_id: device_id.map(|d| d.into()), initial_device_display_name, @@ -1125,7 +1131,7 @@ impl Client { /// # Arguments /// /// * `response` - A successful login response. - async fn receive_login_response(&self, response: &login::Response) -> Result<()> { + async fn receive_login_response(&self, response: &login::v3::Response) -> Result<()> { if self.inner.use_discovery_response { if let Some(well_known) = &response.well_known { if let Ok(homeserver) = Url::parse(&well_known.homeserver.base_url) { @@ -1205,7 +1211,7 @@ impl Client { /// # Arguments /// /// * `registration` - The easiest way to create this request is using the - /// `register::Request` + /// [`register::v3::Request`] /// itself. /// /// @@ -1214,8 +1220,8 @@ impl Client { /// # use std::convert::TryFrom; /// # use matrix_sdk::Client; /// # use matrix_sdk::ruma::{ - /// # api::client::r0::{ - /// # account::register::{Request as RegistrationRequest, RegistrationKind}, + /// # api::client::{ + /// # account::register::{v3::Request as RegistrationRequest, RegistrationKind}, /// # uiaa, /// # }, /// # assign, DeviceId, @@ -1239,8 +1245,8 @@ impl Client { #[instrument(skip(registration))] pub async fn register( &self, - registration: impl Into>, - ) -> HttpResult { + registration: impl Into>, + ) -> HttpResult { let homeserver = self.homeserver().await; info!("Registering to {}", homeserver); @@ -1272,11 +1278,11 @@ impl Client { /// ```no_run /// # use matrix_sdk::{ /// # Client, config::SyncSettings, - /// # ruma::api::client::r0::{ + /// # ruma::api::client::{ /// # filter::{ /// # FilterDefinition, LazyLoadOptions, RoomEventFilter, RoomFilter, /// # }, - /// # sync::sync_events::Filter, + /// # sync::sync_events::v3::Filter, /// # } /// # }; /// # use futures::executor::block_on; @@ -1331,8 +1337,11 @@ impl Client { /// # Arguments /// /// * `room_id` - The `RoomId` of the room to be joined. - pub async fn join_room_by_id(&self, room_id: &RoomId) -> HttpResult { - let request = join_room_by_id::Request::new(room_id); + pub async fn join_room_by_id( + &self, + room_id: &RoomId, + ) -> HttpResult { + let request = join_room_by_id::v3::Request::new(room_id); self.send(request, None).await } @@ -1349,8 +1358,8 @@ impl Client { &self, alias: &RoomOrAliasId, server_names: &[Box], - ) -> HttpResult { - let request = assign!(join_room_by_id_or_alias::Request::new(alias), { + ) -> HttpResult { + let request = assign!(join_room_by_id_or_alias::v3::Request::new(alias), { server_name: server_names, }); self.send(request, None).await @@ -1392,10 +1401,10 @@ impl Client { limit: Option, since: Option<&str>, server: Option<&ServerName>, - ) -> HttpResult { + ) -> HttpResult { let limit = limit.map(UInt::from); - let request = assign!(get_public_rooms::Request::new(), { + let request = assign!(get_public_rooms::v3::Request::new(), { limit, since, server, @@ -1416,8 +1425,8 @@ impl Client { /// # Examples /// ```no_run /// use matrix_sdk::Client; - /// # use matrix_sdk::ruma::api::client::r0::room::{ - /// # create_room::Request as CreateRoomRequest, + /// # use matrix_sdk::ruma::api::client::room::{ + /// # create_room::v3::Request as CreateRoomRequest, /// # Visibility, /// # }; /// # use url::Url; @@ -1432,8 +1441,8 @@ impl Client { /// ``` pub async fn create_room( &self, - room: impl Into>, - ) -> HttpResult { + room: impl Into>, + ) -> HttpResult { let request = room.into(); self.send(request, None).await } @@ -1455,7 +1464,7 @@ impl Client { /// # let homeserver = Url::parse("http://example.com")?; /// use matrix_sdk::{ /// ruma::{ - /// api::client::r0::directory::get_public_rooms_filtered::Request, + /// api::client::directory::get_public_rooms_filtered::v3::Request, /// directory::Filter, /// assign, /// } @@ -1475,8 +1484,8 @@ impl Client { /// ``` pub async fn public_rooms_filtered( &self, - room_search: impl Into>, - ) -> HttpResult { + room_search: impl Into>, + ) -> HttpResult { let request = room_search.into(); self.send(request, None).await } @@ -1516,7 +1525,7 @@ impl Client { &self, content_type: &Mime, reader: &mut (impl Read + ?Sized), - ) -> Result { + ) -> Result { let mut data = Vec::new(); reader.read_to_end(&mut data)?; @@ -1525,7 +1534,7 @@ impl Client { MIN_UPLOAD_REQUEST_TIMEOUT, ); - let request = assign!(create_content::Request::new(&data), { + let request = assign!(create_content::v3::Request::new(&data), { content_type: Some(content_type.essence_str()), }); @@ -1558,13 +1567,13 @@ impl Client { /// # block_on(async { /// # let homeserver = Url::parse("http://localhost:8080")?; /// # let mut client = Client::new(homeserver).await?; - /// use matrix_sdk::ruma::{api::client::r0::profile, user_id}; + /// use matrix_sdk::ruma::{api::client::profile, user_id}; /// /// // First construct the request you want to make /// // See https://docs.rs/ruma-client-api/latest/ruma_client_api/index.html /// // for all available Endpoints /// let user_id = user_id!("@example:localhost"); - /// let request = profile::get_profile::Request::new(&user_id); + /// let request = profile::get_profile::v3::Request::new(&user_id); /// /// // Start the request using Client::send() /// let response = client.send(request, None).await?; @@ -1608,8 +1617,8 @@ impl Client { /// } /// # Result::<_, matrix_sdk::Error>::Ok(()) }); /// ``` - pub async fn devices(&self) -> HttpResult { - let request = get_devices::Request::new(); + pub async fn devices(&self) -> HttpResult { + let request = get_devices::v3::Request::new(); self.send(request, None).await } @@ -1631,7 +1640,7 @@ impl Client { /// # use matrix_sdk::{ /// # ruma::{ /// # api::{ - /// # client::r0::uiaa, + /// # client::uiaa, /// # error::{FromHttpResponseError, ServerError}, /// # }, /// # assign, device_id, @@ -1650,8 +1659,12 @@ impl Client { /// if let Err(e) = client.delete_devices(devices, None).await { /// if let Some(info) = e.uiaa_response() { /// let auth_data = uiaa::AuthData::Password(assign!( - /// uiaa::Password::new(uiaa::UserIdentifier::MatrixId("example"), "wordpass"), - /// { session: info.session.as_deref() } + /// uiaa::Password::new( + /// uiaa::UserIdentifier::UserIdOrLocalpart("example"), + /// "wordpass", + /// ), { + /// session: info.session.as_deref(), + /// } /// )); /// /// client @@ -1664,8 +1677,8 @@ impl Client { &self, devices: &[Box], auth_data: Option>, - ) -> HttpResult { - let mut request = delete_devices::Request::new(devices); + ) -> HttpResult { + let mut request = delete_devices::v3::Request::new(devices); request.auth = auth_data; self.send(request, None).await @@ -1757,7 +1770,7 @@ impl Client { /// [`timeout`]: crate::config::SyncSettings#method.timeout /// [`full_state`]: crate::config::SyncSettings#method.full_state /// [`filter`]: crate::config::SyncSettings#method.filter - /// [`Filter`]: ruma::api::client::r0::sync::sync_events::Filter + /// [`Filter`]: ruma::api::client::sync::sync_events::v3::Filter /// [`next_batch`]: SyncResponse#structfield.next_batch /// [`get_or_upload_filter()`]: #method.get_or_upload_filter /// [long polling]: #long-polling @@ -1778,7 +1791,7 @@ impl Client { error!(error =? e, "Error while sending outgoing E2EE requests"); }; - let request = assign!(sync_events::Request::new(), { + let request = assign!(sync_events::v3::Request::new(), { filter: sync_settings.filter.as_ref(), since: sync_settings.token.as_deref(), full_state: sync_settings.full_state, @@ -2034,7 +2047,7 @@ impl Client { let content: Vec = match &request.media_type { MediaType::Encrypted(file) => { let content: Vec = - self.send(get_content::Request::from_url(&file.url)?, None).await?.file; + self.send(get_content::v3::Request::from_url(&file.url)?, None).await?.file; #[cfg(feature = "encryption")] let content = { @@ -2055,13 +2068,17 @@ impl Client { MediaType::Uri(uri) => { if let MediaFormat::Thumbnail(size) = &request.format { self.send( - get_content_thumbnail::Request::from_url(uri, size.width, size.height)?, + get_content_thumbnail::v3::Request::from_url( + uri, + size.width, + size.height, + )?, None, ) .await? .file } else { - self.send(get_content::Request::from_url(uri)?, None).await?.file + self.send(get_content::v3::Request::from_url(uri)?, None).await?.file } } }; @@ -2208,8 +2225,8 @@ impl Client { } /// Gets information about the owner of a given access token. - pub async fn whoami(&self) -> HttpResult { - let request = whoami::Request::new(); + pub async fn whoami(&self) -> HttpResult { + let request = whoami::v3::Request::new(); self.send(request, None).await } @@ -2322,17 +2339,15 @@ pub(crate) mod test { api::{ client::{ self as client_api, - r0::{ - account::register::{RegistrationKind, Request as RegistrationRequest}, - directory::{ - get_public_rooms, - get_public_rooms_filtered::{self, Request as PublicRoomsFilterRequest}, - }, - media::get_content_thumbnail::Method, - membership::Invite3pidInit, - session::get_login_types::LoginType, - uiaa::{self, UiaaResponse}, + account::register::{v3::Request as RegistrationRequest, RegistrationKind}, + directory::{ + get_public_rooms, + get_public_rooms_filtered::{self, v3::Request as PublicRoomsFilterRequest}, }, + media::get_content_thumbnail::v3::Method, + membership::Invite3pidInit, + session::get_login_types::v3::LoginType, + uiaa::{self, UiaaResponse}, }, error::{FromHttpResponseError, ServerError}, }, @@ -2512,7 +2527,7 @@ pub(crate) mod test { let homeserver = Url::from_str(&mockito::server_url()).unwrap(); let client = Client::new(homeserver).await.unwrap(); - let idp = crate::client::get_login_types::IdentityProvider::new( + let idp = crate::client::get_login_types::v3::IdentityProvider::new( "some-id".to_string(), "idp-name".to_string(), ); @@ -2861,7 +2876,7 @@ pub(crate) mod test { .with_body(test_json::PUBLIC_ROOMS.to_string()) .create(); - let get_public_rooms::Response { chunk, .. } = + let get_public_rooms::v3::Response { chunk, .. } = client.public_rooms(Some(10), None, None).await.unwrap(); assert_eq!(chunk.len(), 1); } @@ -2880,7 +2895,7 @@ pub(crate) mod test { let filter = assign!(Filter::new(), { generic_search_term }); let request = assign!(PublicRoomsFilterRequest::new(), { filter }); - let get_public_rooms_filtered::Response { chunk, .. } = + let get_public_rooms_filtered::v3::Response { chunk, .. } = client.public_rooms_filtered(request).await.unwrap(); assert_eq!(chunk.len(), 1); } @@ -3581,7 +3596,10 @@ pub(crate) mod test { auth_parameters.insert("password".to_owned(), "wordpass".into()); let auth_data = uiaa::AuthData::Password(assign!( - uiaa::Password::new(uiaa::UserIdentifier::MatrixId("example"), "wordpass"), + uiaa::Password::new( + uiaa::UserIdentifier::UserIdOrLocalpart("example"), + "wordpass", + ), { session: info.session.as_deref() } )); diff --git a/crates/matrix-sdk/src/config/sync.rs b/crates/matrix-sdk/src/config/sync.rs index 86187458b..e9194040e 100644 --- a/crates/matrix-sdk/src/config/sync.rs +++ b/crates/matrix-sdk/src/config/sync.rs @@ -14,14 +14,14 @@ use std::time::Duration; -use ruma::api::client::r0::sync::sync_events; +use ruma::api::client::sync::sync_events; const DEFAULT_SYNC_TIMEOUT: Duration = Duration::from_secs(30); #[derive(Debug, Clone)] /// Settings for a sync call. pub struct SyncSettings<'a> { - pub(crate) filter: Option>, + pub(crate) filter: Option>, pub(crate) timeout: Option, pub(crate) token: Option, pub(crate) full_state: bool, @@ -76,7 +76,7 @@ impl<'a> SyncSettings<'a> { /// * `filter` - The filter configuration that should be used for the sync /// call. #[must_use] - pub fn filter(mut self, filter: sync_events::Filter<'a>) -> Self { + pub fn filter(mut self, filter: sync_events::v3::Filter<'a>) -> Self { self.filter = Some(filter); self } diff --git a/crates/matrix-sdk/src/encryption/mod.rs b/crates/matrix-sdk/src/encryption/mod.rs index c576acfd0..a52ad7957 100644 --- a/crates/matrix-sdk/src/encryption/mod.rs +++ b/crates/matrix-sdk/src/encryption/mod.rs @@ -266,11 +266,11 @@ use matrix_sdk_base::{ }; use matrix_sdk_common::instant::Duration; use ruma::{ - api::client::r0::{ - backup::add_backup_keys::Response as KeysBackupResponse, - keys::{get_keys, upload_keys, upload_signing_keys::Request as UploadSigningKeysRequest}, + api::client::{ + backup::add_backup_keys::v3::Response as KeysBackupResponse, + keys::{get_keys, upload_keys, upload_signing_keys::v3::Request as UploadSigningKeysRequest}, message::send_message_event, - to_device::send_event_to_device::{ + to_device::send_event_to_device::v3::{ Request as RumaToDeviceRequest, Response as ToDeviceResponse, }, uiaa::AuthData, @@ -500,7 +500,7 @@ impl Client { /// ```no_run /// # use std::{convert::TryFrom, collections::BTreeMap}; /// # use matrix_sdk::{ - /// # ruma::{api::client::r0::uiaa, assign}, + /// # ruma::{api::client::uiaa, assign}, /// # Client, /// # }; /// # use url::Url; @@ -512,8 +512,12 @@ impl Client { /// if let Err(e) = client.bootstrap_cross_signing(None).await { /// if let Some(response) = e.uiaa_response() { /// let auth_data = uiaa::AuthData::Password(assign!( - /// uiaa::Password::new(uiaa::UserIdentifier::MatrixId("example"), "wordpass"), - /// { session: response.session.as_deref() } + /// uiaa::Password::new( + /// uiaa::UserIdentifier::UserIdOrLocalpart("example"), + /// "wordpass", + /// ), { + /// session: response.session.as_deref(), + /// } /// )); /// /// client @@ -720,8 +724,8 @@ impl Client { &self, request_id: &TransactionId, device_keys: BTreeMap, Vec>>, - ) -> Result { - let request = assign!(get_keys::Request::new(), { device_keys }); + ) -> Result { + let request = assign!(get_keys::v3::Request::new(), { device_keys }); let response = self.send(request, None).await?; self.mark_request_as_sent(request_id, &response).await?; @@ -852,12 +856,12 @@ impl Client { async fn send_account_data( &self, content: ruma::events::AnyGlobalAccountDataEventContent, - ) -> Result { + ) -> Result { let own_user = self.user_id().await.ok_or_else(|| Error::from(HttpError::AuthenticationRequired))?; let data = serde_json::value::to_raw_value(&content)?; - let request = ruma::api::client::r0::config::set_global_account_data::Request::new( + let request = ruma::api::client::config::set_global_account_data::v3::Request::new( &data, ruma::events::EventContent::event_type(&content), &own_user, @@ -869,7 +873,7 @@ impl Client { #[cfg(feature = "encryption")] pub(crate) async fn create_dm_room(&self, user_id: Box) -> Result> { use ruma::{ - api::client::r0::room::create_room::RoomPreset, + api::client::room::create_room::v3::RoomPreset, events::AnyGlobalAccountDataEventContent, }; @@ -880,7 +884,7 @@ impl Client { let invite = &[user_id.clone()]; let request = assign!( - ruma::api::client::r0::room::create_room::Request::new(), + ruma::api::client::room::create_room::v3::Request::new(), { invite, is_direct: true, @@ -960,8 +964,8 @@ impl Client { pub(crate) async fn keys_upload( &self, request_id: &TransactionId, - request: &upload_keys::Request, - ) -> Result { + request: &upload_keys::v3::Request, + ) -> Result { debug!( device_keys = request.device_keys.is_some(), one_time_key_count = request.one_time_keys.len(), @@ -978,7 +982,7 @@ impl Client { pub(crate) async fn room_send_helper( &self, request: &RoomMessageRequest, - ) -> Result { + ) -> Result { let content = request.content.clone(); let txn_id = &request.txn_id; let room_id = &request.room_id; @@ -1072,7 +1076,7 @@ impl Client { &self, request: &matrix_sdk_base::crypto::KeysBackupRequest, ) -> Result { - let request = ruma::api::client::r0::backup::add_backup_keys::Request::new( + let request = ruma::api::client::backup::add_backup_keys::v3::Request::new( &request.version, request.rooms.to_owned(), ); diff --git a/crates/matrix-sdk/src/error.rs b/crates/matrix-sdk/src/error.rs index 00a0e7595..6c43c371b 100644 --- a/crates/matrix-sdk/src/error.rs +++ b/crates/matrix-sdk/src/error.rs @@ -28,7 +28,7 @@ use reqwest::Error as ReqwestError; use ruma::{ api::{ client::{ - r0::uiaa::{UiaaInfo, UiaaResponse as UiaaError}, + uiaa::{UiaaInfo, UiaaResponse as UiaaError}, Error as RumaClientApiError, }, error::{FromHttpResponseError, IntoHttpError, MatrixError as RumaApiError, ServerError}, diff --git a/crates/matrix-sdk/src/http_client.rs b/crates/matrix-sdk/src/http_client.rs index 6325c3197..f1081050a 100644 --- a/crates/matrix-sdk/src/http_client.rs +++ b/crates/matrix-sdk/src/http_client.rs @@ -19,8 +19,8 @@ use http::Response as HttpResponse; use matrix_sdk_common::{async_trait, locks::RwLock, AsyncTraitDeps}; use reqwest::{Client, Response}; use ruma::api::{ - client::r0::media::create_content, error::FromHttpResponseError, AuthScheme, IncomingResponse, - OutgoingRequest, OutgoingRequestAppserviceExt, SendAccessToken, + client::media::create_content, error::FromHttpResponseError, AuthScheme, IncomingResponse, + MatrixVersion, OutgoingRequest, OutgoingRequestAppserviceExt, SendAccessToken, }; use tracing::trace; use url::Url; @@ -164,6 +164,8 @@ impl HttpClient { .try_into_http_request::( &self.homeserver.read().await.to_string(), access_token, + // FIXME: Use versions reported by server + &[MatrixVersion::V1_0], )? .map(|body| body.freeze()); @@ -194,6 +196,8 @@ impl HttpClient { &self.homeserver.read().await.to_string(), access_token, &user_id, + // FIXME: Use versions reported by server + &[MatrixVersion::V1_0], )? .map(|body| body.freeze()); @@ -202,11 +206,11 @@ impl HttpClient { pub async fn upload( &self, - request: create_content::Request<'_>, + request: create_content::v3::Request<'_>, config: Option, - ) -> Result { + ) -> Result { let response = self.send_request(request, self.session.clone(), config).await?; - Ok(create_content::Response::try_from_http_response(response)?) + Ok(create_content::v3::Response::try_from_http_response(response)?) } pub async fn send( diff --git a/crates/matrix-sdk/src/room/common.rs b/crates/matrix-sdk/src/room/common.rs index 355449808..60f8f6102 100644 --- a/crates/matrix-sdk/src/room/common.rs +++ b/crates/matrix-sdk/src/room/common.rs @@ -7,10 +7,10 @@ use matrix_sdk_base::{ }; use matrix_sdk_common::locks::Mutex; use ruma::{ - api::client::r0::{ + api::client::{ filter::{LazyLoadOptions, RoomEventFilter}, membership::{get_member_events, join_room_by_id, leave_room}, - message::get_message_events::{self, Direction}, + message::get_message_events::{self, v3::Direction}, room::get_room_event, tag::{create_tag, delete_tag}, }, @@ -81,7 +81,7 @@ impl Common { /// /// Only invited and joined rooms can be left pub(crate) async fn leave(&self) -> Result<()> { - let request = leave_room::Request::new(self.inner.room_id()); + let request = leave_room::v3::Request::new(self.inner.room_id()); let _response = self.client.send(request, None).await?; Ok(()) @@ -91,7 +91,7 @@ impl Common { /// /// Only invited and left rooms can be joined via this method pub(crate) async fn join(&self) -> Result<()> { - let request = join_room_by_id::Request::new(self.inner.room_id()); + let request = join_room_by_id::v3::Request::new(self.inner.room_id()); let _response = self.client.send(request, None).await?; Ok(()) @@ -150,7 +150,7 @@ impl Common { /// # use std::convert::TryFrom; /// use matrix_sdk::{room::MessagesOptions, Client}; /// # use matrix_sdk::ruma::{ - /// # api::client::r0::filter::RoomEventFilter, + /// # api::client::filter::RoomEventFilter, /// # room_id, /// # }; /// # use url::Url; @@ -220,7 +220,7 @@ impl Common { /// # use std::convert::TryFrom; /// use matrix_sdk::{room::MessagesOptions, Client}; /// # use matrix_sdk::ruma::{ - /// # api::client::r0::filter::RoomEventFilter, + /// # api::client::filter::RoomEventFilter, /// # room_id, /// # }; /// # use url::Url; @@ -299,7 +299,7 @@ impl Common { /// # use std::convert::TryFrom; /// use matrix_sdk::{room::MessagesOptions, Client}; /// # use matrix_sdk::ruma::{ - /// # api::client::r0::filter::RoomEventFilter, + /// # api::client::filter::RoomEventFilter, /// # room_id, /// # }; /// # use url::Url; @@ -358,7 +358,7 @@ impl Common { /// # use std::convert::TryFrom; /// use matrix_sdk::{room::MessagesOptions, Client}; /// # use matrix_sdk::ruma::{ - /// # api::client::r0::filter::RoomEventFilter, + /// # api::client::filter::RoomEventFilter, /// # room_id, /// # }; /// # use url::Url; @@ -434,7 +434,7 @@ impl Common { /// Fetch the event with the given `EventId` in this room. pub async fn event(&self, event_id: &EventId) -> Result { - let request = get_room_event::Request::new(self.room_id(), event_id); + let request = get_room_event::v3::Request::new(self.room_id(), event_id); let event = self.client.send(request, None).await?.event; #[cfg(feature = "encryption")] @@ -460,7 +460,7 @@ impl Common { let _guard = mutex.lock().await; - let request = get_member_events::Request::new(self.inner.room_id()); + let request = get_member_events::v3::Request::new(self.inner.room_id()); let response = self.client.send(request, None).await?; let response = @@ -680,7 +680,7 @@ impl Common { /// Adds a tag to the room, or updates it if it already exists. /// - /// Returns the [`create_tag::Response`] from the server. + /// Returns the [`create_tag::v3::Response`] from the server. /// /// # Arguments /// * `tag` - The tag to add or update. @@ -712,22 +712,22 @@ impl Common { &self, tag: TagName, tag_info: TagInfo, - ) -> HttpResult { + ) -> HttpResult { let user_id = self.client.user_id().await.ok_or(HttpError::AuthenticationRequired)?; let request = - create_tag::Request::new(&user_id, self.inner.room_id(), tag.as_ref(), tag_info); + create_tag::v3::Request::new(&user_id, self.inner.room_id(), tag.as_ref(), tag_info); self.client.send(request, None).await } /// Removes a tag from the room. /// - /// Returns the [`delete_tag::Response`] from the server. + /// Returns the [`delete_tag::v3::Response`] from the server. /// /// # Arguments /// * `tag` - The tag to remove. - pub async fn remove_tag(&self, tag: TagName) -> HttpResult { + pub async fn remove_tag(&self, tag: TagName) -> HttpResult { let user_id = self.client.user_id().await.ok_or(HttpError::AuthenticationRequired)?; - let request = delete_tag::Request::new(&user_id, self.inner.room_id(), tag.as_ref()); + let request = delete_tag::v3::Request::new(&user_id, self.inner.room_id(), tag.as_ref()); self.client.send(request, None).await } } @@ -784,8 +784,8 @@ impl<'a> MessagesOptions<'a> { Self::new(from, Direction::Forward) } - fn into_request(self, room_id: &'a RoomId) -> get_message_events::Request { - assign!(get_message_events::Request::new(room_id, self.from, self.dir), { + fn into_request(self, room_id: &'a RoomId) -> get_message_events::v3::Request { + assign!(get_message_events::v3::Request::new(room_id, self.from, self.dir), { to: self.to, limit: self.limit, filter: self.filter, diff --git a/crates/matrix-sdk/src/room/joined.rs b/crates/matrix-sdk/src/room/joined.rs index 87bdeb2f0..2ca1273fb 100644 --- a/crates/matrix-sdk/src/room/joined.rs +++ b/crates/matrix-sdk/src/room/joined.rs @@ -12,10 +12,10 @@ use matrix_sdk_common::instant::{Duration, Instant}; use matrix_sdk_common::locks::Mutex; use mime::{self, Mime}; use ruma::{ - api::client::r0::{ + api::client::{ membership::{ ban_user, - invite_user::{self, InvitationRecipient}, + invite_user::{self, v3::InvitationRecipient}, kick_user, Invite3pid, }, message::send_message_event, @@ -23,7 +23,7 @@ use ruma::{ receipt::create_receipt, redact::redact_event, state::send_state_event, - typing::create_typing_event::{Request as TypingRequest, Typing}, + typing::create_typing_event::v3::{Request as TypingRequest, Typing}, }, assign, events::{room::message::RoomMessageEventContent, MessageEventContent, StateEventContent}, @@ -96,7 +96,8 @@ impl Joined { /// /// * `reason` - The reason for banning this user. pub async fn ban_user(&self, user_id: &UserId, reason: Option<&str>) -> Result<()> { - let request = assign!(ban_user::Request::new(self.inner.room_id(), user_id), { reason }); + let request = + assign!(ban_user::v3::Request::new(self.inner.room_id(), user_id), { reason }); self.client.send(request, None).await?; Ok(()) } @@ -110,7 +111,8 @@ impl Joined { /// /// * `reason` - Optional reason why the room member is being kicked out. pub async fn kick_user(&self, user_id: &UserId, reason: Option<&str>) -> Result<()> { - let request = assign!(kick_user::Request::new(self.inner.room_id(), user_id), { reason }); + let request = + assign!(kick_user::v3::Request::new(self.inner.room_id(), user_id), { reason }); self.client.send(request, None).await?; Ok(()) } @@ -123,7 +125,7 @@ impl Joined { pub async fn invite_user_by_id(&self, user_id: &UserId) -> Result<()> { let recipient = InvitationRecipient::UserId { user_id }; - let request = invite_user::Request::new(self.inner.room_id(), recipient); + let request = invite_user::v3::Request::new(self.inner.room_id(), recipient); self.client.send(request, None).await?; Ok(()) @@ -136,7 +138,7 @@ impl Joined { /// * `invite_id` - A third party id of a user to invite to the room. pub async fn invite_user_by_3pid(&self, invite_id: Invite3pid<'_>) -> Result<()> { let recipient = InvitationRecipient::ThirdPartyId(invite_id); - let request = invite_user::Request::new(self.inner.room_id(), recipient); + let request = invite_user::v3::Request::new(self.inner.room_id(), recipient); self.client.send(request, None).await?; Ok(()) @@ -158,7 +160,7 @@ impl Joined { /// /// ```no_run /// use std::time::Duration; - /// use matrix_sdk::ruma::api::client::r0::typing::create_typing_event::Typing; + /// use matrix_sdk::ruma::api::client::typing::create_typing_event::v3::Typing; /// /// # use matrix_sdk::{ /// # Client, config::SyncSettings, @@ -228,7 +230,7 @@ impl Joined { /// on. pub async fn read_receipt(&self, event_id: &EventId) -> Result<()> { let request = - create_receipt::Request::new(self.inner.room_id(), ReceiptType::Read, event_id); + create_receipt::v3::Request::new(self.inner.room_id(), ReceiptType::Read, event_id); self.client.send(request, None).await?; Ok(()) @@ -248,9 +250,10 @@ impl Joined { fully_read: &EventId, read_receipt: Option<&EventId>, ) -> Result<()> { - let request = assign!(set_read_marker::Request::new(self.inner.room_id(), fully_read), { - read_receipt - }); + let request = + assign!(set_read_marker::v3::Request::new(self.inner.room_id(), fully_read), { + read_receipt + }); self.client.send(request, None).await?; Ok(()) @@ -465,7 +468,7 @@ impl Joined { &self, content: impl MessageEventContent, txn_id: Option<&TransactionId>, - ) -> Result { + ) -> Result { let event_type = content.event_type(); let content = serde_json::to_value(&content)?; @@ -534,7 +537,7 @@ impl Joined { content: Value, event_type: &str, txn_id: Option<&TransactionId>, - ) -> Result { + ) -> Result { let txn_id: Box = txn_id.map_or_else(TransactionId::new, ToOwned::to_owned); #[cfg(not(feature = "encryption"))] @@ -577,7 +580,7 @@ impl Joined { (serde_json::value::to_raw_value(&content)?, event_type) }; - let request = send_message_event::Request::new_raw( + let request = send_message_event::v3::Request::new_raw( self.inner.room_id(), &txn_id, event_type, @@ -642,7 +645,7 @@ impl Joined { content_type: &Mime, reader: &mut R, config: AttachmentConfig<'_, T>, - ) -> Result { + ) -> Result { let reader = &mut BufReader::new(reader); #[cfg(feature = "image_proc")] @@ -721,7 +724,7 @@ impl Joined { content_type: &Mime, reader: &mut R, config: AttachmentConfig<'_, T>, - ) -> Result { + ) -> Result { #[cfg(feature = "encryption")] let content = if self.is_encrypted() { self.client @@ -805,8 +808,9 @@ impl Joined { &self, content: impl StateEventContent, state_key: &str, - ) -> Result { - let request = send_state_event::Request::new(self.inner.room_id(), state_key, &content)?; + ) -> Result { + let request = + send_state_event::v3::Request::new(self.inner.room_id(), state_key, &content)?; let response = self.client.send(request, None).await?; Ok(response) } @@ -849,9 +853,9 @@ impl Joined { content: Value, event_type: &str, state_key: &str, - ) -> Result { + ) -> Result { let content = Raw::from_json(serde_json::value::to_raw_value(&content)?); - let request = send_state_event::Request::new_raw( + let request = send_state_event::v3::Request::new_raw( self.inner.room_id(), event_type, state_key, @@ -863,7 +867,7 @@ impl Joined { /// Strips all information out of an event of the room. /// - /// Returns the [`redact_event::Response`] from the server. + /// Returns the [`redact_event::v3::Response`] from the server. /// /// This cannot be undone. Users may redact their own events, and any user /// with a power level greater than or equal to the redact power level of @@ -899,10 +903,10 @@ impl Joined { event_id: &EventId, reason: Option<&str>, txn_id: Option>, - ) -> HttpResult { + ) -> HttpResult { let txn_id = txn_id.unwrap_or_else(TransactionId::new); let request = - assign!(redact_event::Request::new(self.inner.room_id(), event_id, &txn_id), { + assign!(redact_event::v3::Request::new(self.inner.room_id(), event_id, &txn_id), { reason }); diff --git a/crates/matrix-sdk/src/room/left.rs b/crates/matrix-sdk/src/room/left.rs index 59f56e8f2..f71d0b9ee 100644 --- a/crates/matrix-sdk/src/room/left.rs +++ b/crates/matrix-sdk/src/room/left.rs @@ -1,6 +1,6 @@ use std::ops::Deref; -use ruma::api::client::r0::membership::forget_room; +use ruma::api::client::membership::forget_room; use crate::{room::Common, BaseRoom, Client, Result, RoomType}; @@ -40,7 +40,7 @@ impl Left { /// /// This communicates to the homeserver that it should forget the room. pub async fn forget(&self) -> Result<()> { - let request = forget_room::Request::new(self.inner.room_id()); + let request = forget_room::v3::Request::new(self.inner.room_id()); let _response = self.client.send(request, None).await?; self.client.store().remove_room(self.inner.room_id()).await?; diff --git a/crates/matrix-sdk/src/sync.rs b/crates/matrix-sdk/src/sync.rs index 398fbd914..f4d3f29b5 100644 --- a/crates/matrix-sdk/src/sync.rs +++ b/crates/matrix-sdk/src/sync.rs @@ -5,7 +5,7 @@ use matrix_sdk_base::{ deserialized_responses::{JoinedRoom, LeftRoom, SyncResponse}, instant::Instant, }; -use ruma::api::client::r0::sync::sync_events; +use ruma::api::client::sync::sync_events; use tracing::{error, warn}; use crate::{event_handler::EventKind, Client, Result}; @@ -15,7 +15,7 @@ use crate::{event_handler::EventKind, Client, Result}; impl Client { pub(crate) async fn process_sync( &self, - response: sync_events::Response, + response: sync_events::v3::Response, ) -> Result { let response = self.base_client().receive_sync_response(response).await?; let SyncResponse {