Skip to content

Commit 3541142

Browse files
committed
feat(ui) Use the types from http instead of ruma directly.
1 parent 5b0fd1a commit 3541142

File tree

9 files changed

+38
-39
lines changed

9 files changed

+38
-39
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/matrix-sdk-ui/src/encryption_sync_service.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ use async_stream::stream;
3232
use futures_core::stream::Stream;
3333
use futures_util::{pin_mut, StreamExt};
3434
use matrix_sdk::{Client, SlidingSync, LEASE_DURATION_MS};
35-
use ruma::{api::client::sync::sync_events::v4, assign};
35+
use matrix_sdk_base::sliding_sync::http;
36+
use ruma::assign;
3637
use tokio::sync::OwnedMutexGuard;
3738
use tracing::{debug, instrument, trace, Span};
3839

@@ -104,9 +105,11 @@ impl EncryptionSyncService {
104105
.map_err(Error::SlidingSync)?
105106
//.share_pos() // TODO(bnjbvr) This is racy, needs cross-process lock :')
106107
.with_to_device_extension(
107-
assign!(v4::ToDeviceConfig::default(), { enabled: Some(true)}),
108+
assign!(http::ss::extensions::RequestToDevice::default(), { enabled: Some(true)}),
108109
)
109-
.with_e2ee_extension(assign!(v4::E2EEConfig::default(), { enabled: Some(true)}));
110+
.with_e2ee_extension(
111+
assign!(http::ss::extensions::RequestE2EE::default(), { enabled: Some(true)}),
112+
);
110113

111114
if let Some((poll_timeout, network_timeout)) = poll_and_network_timeouts {
112115
builder = builder.poll_timeout(poll_timeout).network_timeout(network_timeout);

crates/matrix-sdk-ui/src/notification_client.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@ use matrix_sdk::{room::Room, Client, ClientBuildError, SlidingSyncList, SlidingS
2222
use matrix_sdk_base::{
2323
crypto::{vodozemac, MegolmError},
2424
deserialized_responses::TimelineEvent,
25+
sliding_sync::http,
2526
RoomState, StoreError,
2627
};
2728
use ruma::{
28-
api::client::sync::sync_events::v4::{
29-
AccountDataConfig, RoomSubscription, SyncRequestListFilters,
30-
},
3129
assign,
3230
events::{
3331
room::{member::StrippedRoomMemberEvent, message::SyncRoomMessageEvent},
@@ -358,7 +356,7 @@ impl NotificationClient {
358356
.sync_mode(SlidingSyncMode::new_selective().add_range(0..=16))
359357
.timeline_limit(8)
360358
.required_state(required_state.clone())
361-
.filters(Some(assign!(SyncRequestListFilters::default(), {
359+
.filters(Some(assign!(http::ss::RequestListFilters::default(), {
362360
is_invite: Some(true),
363361
is_tombstoned: Some(false),
364362
not_room_types: vec!["m.space".to_owned()],
@@ -371,15 +369,15 @@ impl NotificationClient {
371369
.poll_timeout(Duration::from_secs(1))
372370
.network_timeout(Duration::from_secs(3))
373371
.with_account_data_extension(
374-
assign!(AccountDataConfig::default(), { enabled: Some(true) }),
372+
assign!(http::ss::extensions::RequestAccountData::default(), { enabled: Some(true) }),
375373
)
376374
.add_list(invites)
377375
.build()
378376
.await?;
379377

380378
sync.subscribe_to_room(
381379
room_id.to_owned(),
382-
Some(assign!(RoomSubscription::default(), {
380+
Some(assign!(http::ss::RequestRoomSubscription::default(), {
383381
required_state,
384382
timeline_limit: Some(uint!(16))
385383
})),

crates/matrix-sdk-ui/src/room_list_service/mod.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,10 @@ use matrix_sdk::{
6666
event_cache::EventCacheError, Client, Error as SlidingSyncError, SlidingSync, SlidingSyncList,
6767
SlidingSyncMode,
6868
};
69+
use matrix_sdk_base::sliding_sync::http;
6970
pub use room::*;
7071
pub use room_list::*;
7172
use ruma::{
72-
api::client::sync::sync_events::v4::{
73-
AccountDataConfig, E2EEConfig, ReceiptsConfig, RoomReceiptConfig, SyncRequestListFilters,
74-
ToDeviceConfig, TypingConfig,
75-
},
7673
assign,
7774
events::{StateEventType, TimelineEventType},
7875
OwnedRoomId, RoomId,
@@ -123,21 +120,21 @@ impl RoomListService {
123120
.sliding_sync("room-list")
124121
.map_err(Error::SlidingSync)?
125122
.with_account_data_extension(
126-
assign!(AccountDataConfig::default(), { enabled: Some(true) }),
123+
assign!(http::ss::extensions::RequestAccountData::default(), { enabled: Some(true) }),
127124
)
128-
.with_receipt_extension(assign!(ReceiptsConfig::default(), {
125+
.with_receipt_extension(assign!(http::ss::extensions::RequestReceipts::default(), {
129126
enabled: Some(true),
130-
rooms: Some(vec![RoomReceiptConfig::AllSubscribed])
127+
rooms: Some(vec![http::ss::extensions::RequestReceiptsRoom::AllSubscribed])
131128
}))
132-
.with_typing_extension(assign!(TypingConfig::default(), {
129+
.with_typing_extension(assign!(http::ss::extensions::RequestTyping::default(), {
133130
enabled: Some(true),
134131
}));
135132

136133
if with_encryption {
137134
builder = builder
138-
.with_e2ee_extension(assign!(E2EEConfig::default(), { enabled: Some(true) }))
135+
.with_e2ee_extension(assign!(http::ss::extensions::RequestE2EE::default(), { enabled: Some(true) }))
139136
.with_to_device_extension(
140-
assign!(ToDeviceConfig::default(), { enabled: Some(true) }),
137+
assign!(http::ss::extensions::RequestToDevice::default(), { enabled: Some(true) }),
141138
);
142139
}
143140

@@ -158,7 +155,7 @@ impl RoomListService {
158155
])
159156
.sort(vec!["by_recency".to_owned(), "by_name".to_owned()])
160157
.include_heroes(Some(true))
161-
.filters(Some(assign!(SyncRequestListFilters::default(), {
158+
.filters(Some(assign!(http::ss::RequestListFilters::default(), {
162159
// As defined in the [SlidingSync MSC](https://github.com/matrix-org/matrix-spec-proposals/blob/9450ced7fb9cf5ea9077d029b3adf36aebfa8709/proposals/3575-sync.md?plain=1#L444)
163160
// If unset, both invited and joined rooms are returned. If false, no invited rooms are
164161
// returned. If true, only invited rooms are returned.

crates/matrix-sdk-ui/src/room_list_service/room.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ use std::{ops::Deref, sync::Arc};
1919

2020
use async_once_cell::OnceCell as AsyncOnceCell;
2121
use matrix_sdk::SlidingSync;
22-
use ruma::{api::client::sync::sync_events::v4::RoomSubscription, events::StateEventType, RoomId};
22+
use matrix_sdk_base::sliding_sync::http;
23+
use ruma::{events::StateEventType, RoomId};
2324

2425
use super::Error;
2526
use crate::{
@@ -91,7 +92,7 @@ impl Room {
9192
///
9293
/// It means that all events from this room will be received every time, no
9394
/// matter how the `RoomList` is configured.
94-
pub fn subscribe(&self, settings: Option<RoomSubscription>) {
95+
pub fn subscribe(&self, settings: Option<http::ss::RequestRoomSubscription>) {
9596
let mut settings = settings.unwrap_or_default();
9697

9798
// Make sure to always include the room creation event in the required state

crates/matrix-sdk-ui/src/timeline/event_item/mod.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -558,12 +558,11 @@ mod tests {
558558
use assert_matches2::assert_let;
559559
use matrix_sdk::test_utils::logged_in_client;
560560
use matrix_sdk_base::{
561-
deserialized_responses::SyncTimelineEvent, latest_event::LatestEvent, MinimalStateEvent,
562-
OriginalMinimalStateEvent,
561+
deserialized_responses::SyncTimelineEvent, latest_event::LatestEvent, sliding_sync::http,
562+
MinimalStateEvent, OriginalMinimalStateEvent,
563563
};
564564
use matrix_sdk_test::{async_test, sync_timeline_event};
565565
use ruma::{
566-
api::client::sync::sync_events::v4,
567566
events::{
568567
room::{
569568
member::RoomMemberEventContent,
@@ -619,7 +618,7 @@ mod tests {
619618
let user_id = user_id!("@t:o.uk");
620619
let event = message_event(room_id, user_id, "**My M**", "<b>My M</b>", 122344);
621620
let client = logged_in_client(None).await;
622-
let mut room = v4::SlidingSyncRoom::new();
621+
let mut room = http::ss::ResponseRoom::new();
623622
room.timeline.push(member_event(room_id, user_id, "Alice Margatroid", "mxc://e.org/SEs"));
624623

625624
// And the room is stored in the client so it can be extracted when needed
@@ -662,7 +661,7 @@ mod tests {
662661
.unwrap(),
663662
);
664663

665-
let room = v4::SlidingSyncRoom::new();
664+
let room = http::ss::ResponseRoom::new();
666665
// Do not push the `member_event` inside the room. Let's say it's flying in the
667666
// `StateChanges`.
668667

@@ -717,8 +716,8 @@ mod tests {
717716
})
718717
}
719718

720-
fn response_with_room(room_id: &RoomId, room: v4::SlidingSyncRoom) -> v4::Response {
721-
let mut response = v4::Response::new("6".to_owned());
719+
fn response_with_room(room_id: &RoomId, room: http::ss::ResponseRoom) -> http::ss::Response {
720+
let mut response = http::ss::Response::new("6".to_owned());
722721
response.rooms.insert(room_id.to_owned(), room);
723722
response
724723
}

crates/matrix-sdk-ui/tests/integration/room_list_service.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use assert_matches::assert_matches;
77
use eyeball_im::VectorDiff;
88
use futures_util::{pin_mut, FutureExt, StreamExt};
99
use matrix_sdk::{test_utils::logged_in_client_with_server, Client};
10-
use matrix_sdk_base::sync::UnreadNotificationsCount;
10+
use matrix_sdk_base::{
11+
sliding_sync::http::ss::RequestRoomSubscription, sync::UnreadNotificationsCount,
12+
};
1113
use matrix_sdk_test::async_test;
1214
use matrix_sdk_ui::{
1315
room_list_service::{
@@ -18,7 +20,6 @@ use matrix_sdk_ui::{
1820
RoomListService,
1921
};
2022
use ruma::{
21-
api::client::sync::sync_events::v4::RoomSubscription,
2223
assign, event_id,
2324
events::{room::message::RoomMessageEventContent, StateEventType},
2425
mxc_uri, room_id, uint,
@@ -2102,7 +2103,7 @@ async fn test_room_subscription() -> Result<(), Error> {
21022103

21032104
// Subscribe.
21042105

2105-
room1.subscribe(Some(assign!(RoomSubscription::default(), {
2106+
room1.subscribe(Some(assign!(RequestRoomSubscription::default(), {
21062107
required_state: vec![
21072108
(StateEventType::RoomName, "".to_owned()),
21082109
(StateEventType::RoomTopic, "".to_owned()),

testing/matrix-sdk-integration-testing/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ futures = { version = "0.3.29", features = ["executor"] }
1616
futures-core = { workspace = true }
1717
futures-util = { workspace = true }
1818
http = { workspace = true }
19+
matrix-sdk-base = { workspace = true, default-features = true, features = ["testing", "qrcode"] }
1920
matrix-sdk = { workspace = true, default-features = true, features = ["testing", "qrcode"] }
2021
matrix-sdk-ui = { workspace = true, default-features = true }
2122
matrix-sdk-test = { workspace = true }

testing/matrix-sdk-integration-testing/src/tests/sliding_sync/room.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ use matrix_sdk::{
1616
api::client::{
1717
receipt::create_receipt::v3::ReceiptType,
1818
room::create_room::v3::{Request as CreateRoomRequest, RoomPreset},
19-
sync::sync_events::v4::{
20-
AccountDataConfig, E2EEConfig, ReceiptsConfig, ToDeviceConfig,
21-
},
2219
},
2320
assign,
2421
events::{
@@ -36,6 +33,7 @@ use matrix_sdk::{
3633
},
3734
Client, RoomInfo, RoomMemberships, RoomState, SlidingSyncList, SlidingSyncMode,
3835
};
36+
use matrix_sdk_base::sliding_sync::http;
3937
use matrix_sdk_ui::{
4038
room_list_service::filters::new_filter_all, sync_service::SyncService, RoomListService,
4139
};
@@ -373,12 +371,12 @@ async fn test_room_notification_count() -> Result<()> {
373371
spawn({
374372
let sync = alice
375373
.sliding_sync("main")?
376-
.with_receipt_extension(assign!(ReceiptsConfig::default(), { enabled: Some(true) }))
374+
.with_receipt_extension(assign!(http::ss::extensions::RequestReceipts::default(), { enabled: Some(true) }))
377375
.with_account_data_extension(
378-
assign!(AccountDataConfig::default(), { enabled: Some(true) }),
376+
assign!(http::ss::extensions::RequestAccountData::default(), { enabled: Some(true) }),
379377
)
380-
.with_e2ee_extension(assign!(E2EEConfig::default(), { enabled: Some(true) }))
381-
.with_to_device_extension(assign!(ToDeviceConfig::default(), { enabled: Some(true) }))
378+
.with_e2ee_extension(assign!(http::ss::extensions::RequestE2EE::default(), { enabled: Some(true) }))
379+
.with_to_device_extension(assign!(http::ss::extensions::RequestToDevice::default(), { enabled: Some(true) }))
382380
.add_list(
383381
SlidingSyncList::builder("all")
384382
.sync_mode(SlidingSyncMode::new_selective().add_range(0..=20))

0 commit comments

Comments
 (0)