From f33d10468d3a747d836116e9f54e4561b25be84c Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 5 Feb 2025 15:25:49 +0100 Subject: [PATCH] refactor(base): Remove the `sliding_sync::http` re-export. This patch removes the `pub use ruma::api::client::sync::sync_events::v5 as http` re-export in `matrix_sdk_base::sliding_sync`. --- crates/matrix-sdk-base/src/sliding_sync.rs | 12 +++++++----- crates/matrix-sdk-ui/src/encryption_sync_service.rs | 3 +-- crates/matrix-sdk-ui/src/notification_client.rs | 5 ++--- crates/matrix-sdk-ui/src/room_list_service/mod.rs | 6 ++++-- crates/matrix-sdk-ui/src/timeline/event_item/mod.rs | 5 +++-- crates/matrix-sdk/src/sliding_sync/README.md | 6 ++---- crates/matrix-sdk/src/sliding_sync/builder.rs | 3 +-- crates/matrix-sdk/src/sliding_sync/client.rs | 6 ++++-- crates/matrix-sdk/src/sliding_sync/list/builder.rs | 3 +-- crates/matrix-sdk/src/sliding_sync/list/mod.rs | 3 +-- crates/matrix-sdk/src/sliding_sync/list/sticky.rs | 3 +-- crates/matrix-sdk/src/sliding_sync/mod.rs | 6 ++++-- crates/matrix-sdk/src/sliding_sync/room.rs | 4 ++-- crates/matrix-sdk/tests/integration/room_preview.rs | 13 ++++++++----- .../src/tests/sliding_sync/room.rs | 5 ++--- 15 files changed, 43 insertions(+), 40 deletions(-) diff --git a/crates/matrix-sdk-base/src/sliding_sync.rs b/crates/matrix-sdk-base/src/sliding_sync.rs index 6e1bb78ac0c..c044a7abd5a 100644 --- a/crates/matrix-sdk-base/src/sliding_sync.rs +++ b/crates/matrix-sdk-base/src/sliding_sync.rs @@ -20,9 +20,11 @@ use std::ops::Deref; #[cfg(feature = "e2e-encryption")] use matrix_sdk_common::deserialized_responses::TimelineEvent; -pub use ruma::api::client::sync::sync_events::v5 as http; use ruma::{ - api::client::sync::sync_events::v3::{self, InvitedRoom, KnockedRoom}, + api::client::sync::sync_events::{ + v3::{self, InvitedRoom, KnockedRoom}, + v5 as http, + }, events::{ room::member::MembershipState, AnyRoomAccountDataEvent, AnyStrippedStateEvent, AnySyncStateEvent, @@ -31,7 +33,7 @@ use ruma::{ JsOption, OwnedRoomId, RoomId, UserId, }; #[cfg(feature = "e2e-encryption")] -use ruma::{api::client::sync::sync_events::v5, events::AnyToDeviceEvent, events::StateEventType}; +use ruma::{events::AnyToDeviceEvent, events::StateEventType}; use tracing::{instrument, trace, warn}; use super::BaseClient; @@ -65,8 +67,8 @@ impl BaseClient { /// Returns whether any change happened. pub async fn process_sliding_sync_e2ee( &self, - to_device: Option<&v5::response::ToDevice>, - e2ee: &v5::response::E2EE, + to_device: Option<&http::response::ToDevice>, + e2ee: &http::response::E2EE, ) -> Result>>> { if to_device.is_none() && e2ee.is_empty() { return Ok(None); diff --git a/crates/matrix-sdk-ui/src/encryption_sync_service.rs b/crates/matrix-sdk-ui/src/encryption_sync_service.rs index e3d7d0f830d..49661366938 100644 --- a/crates/matrix-sdk-ui/src/encryption_sync_service.rs +++ b/crates/matrix-sdk-ui/src/encryption_sync_service.rs @@ -32,8 +32,7 @@ use async_stream::stream; use futures_core::stream::Stream; use futures_util::{pin_mut, StreamExt}; use matrix_sdk::{sleep::sleep, Client, SlidingSync, LEASE_DURATION_MS}; -use matrix_sdk_base::sliding_sync::http; -use ruma::assign; +use ruma::{api::client::sync::sync_events::v5 as http, assign}; use tokio::sync::OwnedMutexGuard; use tracing::{debug, instrument, trace, Span}; diff --git a/crates/matrix-sdk-ui/src/notification_client.rs b/crates/matrix-sdk-ui/src/notification_client.rs index 7b4b7256cd9..b7b9f46cffd 100644 --- a/crates/matrix-sdk-ui/src/notification_client.rs +++ b/crates/matrix-sdk-ui/src/notification_client.rs @@ -21,10 +21,9 @@ use futures_util::{pin_mut, StreamExt as _}; use matrix_sdk::{ room::Room, sleep::sleep, Client, ClientBuildError, SlidingSyncList, SlidingSyncMode, }; -use matrix_sdk_base::{ - deserialized_responses::TimelineEvent, sliding_sync::http, RoomState, StoreError, -}; +use matrix_sdk_base::{deserialized_responses::TimelineEvent, RoomState, StoreError}; use ruma::{ + api::client::sync::sync_events::v5 as http, assign, directory::RoomTypeFilter, events::{ diff --git a/crates/matrix-sdk-ui/src/room_list_service/mod.rs b/crates/matrix-sdk-ui/src/room_list_service/mod.rs index 6b7e5dd6d73..8021d229d23 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/mod.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/mod.rs @@ -66,10 +66,12 @@ use matrix_sdk::{ event_cache::EventCacheError, timeout::timeout, Client, Error as SlidingSyncError, SlidingSync, SlidingSyncList, SlidingSyncMode, }; -use matrix_sdk_base::sliding_sync::http; pub use room::*; pub use room_list::*; -use ruma::{assign, directory::RoomTypeFilter, events::StateEventType, OwnedRoomId, RoomId, UInt}; +use ruma::{ + api::client::sync::sync_events::v5 as http, assign, directory::RoomTypeFilter, + events::StateEventType, OwnedRoomId, RoomId, UInt, +}; pub use state::*; use thiserror::Error; use tracing::debug; diff --git a/crates/matrix-sdk-ui/src/timeline/event_item/mod.rs b/crates/matrix-sdk-ui/src/timeline/event_item/mod.rs index 044bf863702..e454710d401 100644 --- a/crates/matrix-sdk-ui/src/timeline/event_item/mod.rs +++ b/crates/matrix-sdk-ui/src/timeline/event_item/mod.rs @@ -800,13 +800,14 @@ mod tests { use assert_matches2::assert_let; use matrix_sdk::test_utils::logged_in_client; use matrix_sdk_base::{ - deserialized_responses::TimelineEvent, latest_event::LatestEvent, sliding_sync::http, - MinimalStateEvent, OriginalMinimalStateEvent, + deserialized_responses::TimelineEvent, latest_event::LatestEvent, MinimalStateEvent, + OriginalMinimalStateEvent, }; use matrix_sdk_test::{ async_test, event_factory::EventFactory, sync_state_event, sync_timeline_event, }; use ruma::{ + api::client::sync::sync_events::v5 as http, event_id, events::{ room::{ diff --git a/crates/matrix-sdk/src/sliding_sync/README.md b/crates/matrix-sdk/src/sliding_sync/README.md index 9a60ba48e11..234d7c28762 100644 --- a/crates/matrix-sdk/src/sliding_sync/README.md +++ b/crates/matrix-sdk/src/sliding_sync/README.md @@ -68,8 +68,7 @@ are **inclusive**) like so: ```rust # use matrix_sdk::sliding_sync::{SlidingSyncList, SlidingSyncMode}; -use matrix_sdk_base::sliding_sync::http; -use ruma::assign; +use ruma::{api::client::sync::sync_events::v5 as http, assign}; let list_builder = SlidingSyncList::builder("main_list") .sync_mode(SlidingSyncMode::new_selective().add_range(0..=9)) @@ -326,8 +325,7 @@ whenever a new set of timeline items is received by the server. ```rust,no_run use matrix_sdk::{Client, sliding_sync::{SlidingSyncList, SlidingSyncMode, Version}}; -use matrix_sdk_base::sliding_sync::http; -use ruma::{assign, events::StateEventType}; +use ruma::{api::client::sync::sync_events::v5 as http, assign, events::StateEventType}; use tracing::{warn, error, info, debug}; use futures_util::{pin_mut, StreamExt}; use url::Url; diff --git a/crates/matrix-sdk/src/sliding_sync/builder.rs b/crates/matrix-sdk/src/sliding_sync/builder.rs index 6e603d954f4..7c40b540bb5 100644 --- a/crates/matrix-sdk/src/sliding_sync/builder.rs +++ b/crates/matrix-sdk/src/sliding_sync/builder.rs @@ -5,9 +5,8 @@ use std::{ time::Duration, }; -use matrix_sdk_base::sliding_sync::http; use matrix_sdk_common::timer; -use ruma::OwnedRoomId; +use ruma::{api::client::sync::sync_events::v5 as http, OwnedRoomId}; use tokio::sync::{broadcast::channel, Mutex as AsyncMutex, RwLock as AsyncRwLock}; use super::{ diff --git a/crates/matrix-sdk/src/sliding_sync/client.rs b/crates/matrix-sdk/src/sliding_sync/client.rs index d8c4b7d273c..434e49870f6 100644 --- a/crates/matrix-sdk/src/sliding_sync/client.rs +++ b/crates/matrix-sdk/src/sliding_sync/client.rs @@ -1,9 +1,11 @@ use std::collections::BTreeMap; use imbl::Vector; -use matrix_sdk_base::{sliding_sync::http, sync::SyncResponse, PreviousEventsProvider}; +use matrix_sdk_base::{sync::SyncResponse, PreviousEventsProvider}; use ruma::{ - api::client::discovery::get_supported_versions, events::AnyToDeviceEvent, serde::Raw, + api::client::{discovery::get_supported_versions, sync::sync_events::v5 as http}, + events::AnyToDeviceEvent, + serde::Raw, OwnedRoomId, }; use tracing::error; diff --git a/crates/matrix-sdk/src/sliding_sync/list/builder.rs b/crates/matrix-sdk/src/sliding_sync/list/builder.rs index 312acbe93de..00069a8b3b7 100644 --- a/crates/matrix-sdk/src/sliding_sync/list/builder.rs +++ b/crates/matrix-sdk/src/sliding_sync/list/builder.rs @@ -7,8 +7,7 @@ use std::{ }; use eyeball::{Observable, SharedObservable}; -use matrix_sdk_base::sliding_sync::http; -use ruma::events::StateEventType; +use ruma::{api::client::sync::sync_events::v5 as http, events::StateEventType}; use tokio::sync::broadcast::Sender; use super::{ diff --git a/crates/matrix-sdk/src/sliding_sync/list/mod.rs b/crates/matrix-sdk/src/sliding_sync/list/mod.rs index 1471dfc7bf9..f51bb2506e8 100644 --- a/crates/matrix-sdk/src/sliding_sync/list/mod.rs +++ b/crates/matrix-sdk/src/sliding_sync/list/mod.rs @@ -11,8 +11,7 @@ use std::{ use eyeball::{Observable, SharedObservable, Subscriber}; use futures_core::Stream; -use matrix_sdk_base::sliding_sync::http; -use ruma::{assign, TransactionId}; +use ruma::{api::client::sync::sync_events::v5 as http, assign, TransactionId}; use serde::{Deserialize, Serialize}; use tokio::sync::broadcast::Sender; use tracing::{instrument, warn}; diff --git a/crates/matrix-sdk/src/sliding_sync/list/sticky.rs b/crates/matrix-sdk/src/sliding_sync/list/sticky.rs index f5b12798be8..495f7916b99 100644 --- a/crates/matrix-sdk/src/sliding_sync/list/sticky.rs +++ b/crates/matrix-sdk/src/sliding_sync/list/sticky.rs @@ -1,5 +1,4 @@ -use matrix_sdk_base::sliding_sync::http; -use ruma::events::StateEventType; +use ruma::{api::client::sync::sync_events::v5 as http, events::StateEventType}; use crate::sliding_sync::sticky_parameters::StickyData; diff --git a/crates/matrix-sdk/src/sliding_sync/mod.rs b/crates/matrix-sdk/src/sliding_sync/mod.rs index 20ea02a45bd..f63c1e35450 100644 --- a/crates/matrix-sdk/src/sliding_sync/mod.rs +++ b/crates/matrix-sdk/src/sliding_sync/mod.rs @@ -35,9 +35,11 @@ use std::{ use async_stream::stream; pub use client::{Version, VersionBuilder}; use futures_core::stream::Stream; -pub use matrix_sdk_base::sliding_sync::http; use matrix_sdk_common::{deserialized_responses::TimelineEvent, executor::spawn, timer}; -use ruma::{api::client::error::ErrorKind, assign, OwnedRoomId, RoomId}; +use ruma::{ + api::client::{error::ErrorKind, sync::sync_events::v5 as http}, + assign, OwnedRoomId, RoomId, +}; use serde::{Deserialize, Serialize}; use tokio::{ select, diff --git a/crates/matrix-sdk/src/sliding_sync/room.rs b/crates/matrix-sdk/src/sliding_sync/room.rs index 49ce04a0fe7..7b3eaa47da8 100644 --- a/crates/matrix-sdk/src/sliding_sync/room.rs +++ b/crates/matrix-sdk/src/sliding_sync/room.rs @@ -4,8 +4,8 @@ use std::{ }; use eyeball_im::Vector; -use matrix_sdk_base::{deserialized_responses::TimelineEvent, sliding_sync::http}; -use ruma::{OwnedRoomId, RoomId}; +use matrix_sdk_base::deserialized_responses::TimelineEvent; +use ruma::{api::client::sync::sync_events::v5 as http, OwnedRoomId, RoomId}; use serde::{Deserialize, Serialize}; /// The state of a [`SlidingSyncRoom`]. diff --git a/crates/matrix-sdk/tests/integration/room_preview.rs b/crates/matrix-sdk/tests/integration/room_preview.rs index 39fd06a2f23..9b05d6fe9a1 100644 --- a/crates/matrix-sdk/tests/integration/room_preview.rs +++ b/crates/matrix-sdk/tests/integration/room_preview.rs @@ -1,12 +1,15 @@ use js_int::uint; use matrix_sdk::{config::SyncSettings, test_utils::logged_in_client_with_server}; -use matrix_sdk_base::{sliding_sync, RoomState}; +use matrix_sdk_base::RoomState; use matrix_sdk_test::{ async_test, InvitedRoomBuilder, JoinedRoomBuilder, KnockedRoomBuilder, SyncResponseBuilder, }; use ruma::{ - api::client::sync::sync_events::v5::response::Hero, assign, - events::room::member::MembershipState, owned_user_id, room_id, space::SpaceRoomJoinRule, + api::client::sync::sync_events::{v5 as sliding_sync_http, v5::response::Hero}, + assign, + events::room::member::MembershipState, + owned_user_id, room_id, + space::SpaceRoomJoinRule, RoomId, }; use serde_json::json; @@ -120,7 +123,7 @@ async fn test_room_preview_computes_name_if_room_is_known() { let room_id = room_id!("!room:localhost"); // Given a room with no name but a hero - let room = assign!(sliding_sync::http::response::Room::new(), { + let room = assign!(sliding_sync_http::response::Room::new(), { name: None, heroes: Some(vec![assign!(Hero::new(owned_user_id!("@alice:matrix.org")), { name: Some("Alice".to_owned()), @@ -129,7 +132,7 @@ async fn test_room_preview_computes_name_if_room_is_known() { joined_count: Some(uint!(1)), invited_count: Some(uint!(1)), }); - let mut response = sliding_sync::http::Response::new("0".to_owned()); + let mut response = sliding_sync_http::Response::new("0".to_owned()); response.rooms.insert(room_id.to_owned(), room); client.process_sliding_sync_test_helper(&response).await.expect("Failed to process sync"); diff --git a/testing/matrix-sdk-integration-testing/src/tests/sliding_sync/room.rs b/testing/matrix-sdk-integration-testing/src/tests/sliding_sync/room.rs index fa7b3296a13..2945904022d 100644 --- a/testing/matrix-sdk-integration-testing/src/tests/sliding_sync/room.rs +++ b/testing/matrix-sdk-integration-testing/src/tests/sliding_sync/room.rs @@ -40,9 +40,8 @@ use matrix_sdk::{ test_utils::{logged_in_client_with_server, mocks::MatrixMockServer}, Client, Room, RoomInfo, RoomMemberships, RoomState, SlidingSyncList, SlidingSyncMode, }; -use matrix_sdk_base::{ - ruma::{owned_room_id, room_alias_id}, - sliding_sync::http, +use matrix_sdk_base::ruma::{ + api::client::sync::sync_events::v5 as http, owned_room_id, room_alias_id, }; use matrix_sdk_test::async_test; use matrix_sdk_ui::{