diff --git a/crates/matrix-sdk/src/client/mod.rs b/crates/matrix-sdk/src/client/mod.rs index 938f3a853..d82d10d56 100644 --- a/crates/matrix-sdk/src/client/mod.rs +++ b/crates/matrix-sdk/src/client/mod.rs @@ -3010,8 +3010,8 @@ pub(crate) mod tests { RoomState, }; use matrix_sdk_test::{ - async_test, GlobalAccountDataTestEvent, JoinedRoomBuilder, StateTestEvent, - SyncResponseBuilder, DEFAULT_TEST_ROOM_ID, + async_test, event_factory::EventFactory, GlobalAccountDataTestEvent, JoinedRoomBuilder, + StateTestEvent, SyncResponseBuilder, DEFAULT_TEST_ROOM_ID, }; #[cfg(target_family = "wasm")] wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); @@ -3029,7 +3029,7 @@ pub(crate) mod tests { ignored_user_list::IgnoredUserListEventContent, media_preview_config::{InviteAvatars, MediaPreviewConfigEventContent, MediaPreviews}, }, - owned_room_id, room_alias_id, room_id, RoomId, ServerName, UserId, + owned_room_id, owned_user_id, room_alias_id, room_id, RoomId, ServerName, UserId, }; use serde_json::json; use stream_assert::{assert_next_matches, assert_pending}; @@ -3054,10 +3054,13 @@ pub(crate) mod tests { let server = MatrixMockServer::new().await; let client = server.client_builder().build().await; + let f = EventFactory::new(); server .mock_sync() .ok_and_run(&client, |builder| { - builder.add_global_account_data_event(GlobalAccountDataTestEvent::IgnoredUserList); + builder.add_global_account_data( + f.ignored_user_list([owned_user_id!("@someone:example.org")]).into_raw(), + ); }) .await; diff --git a/testing/matrix-sdk-test/src/event_factory.rs b/testing/matrix-sdk-test/src/event_factory.rs index 592b1940f..3739caf64 100644 --- a/testing/matrix-sdk-test/src/event_factory.rs +++ b/testing/matrix-sdk-test/src/event_factory.rs @@ -39,6 +39,7 @@ use ruma::{ notify::{ApplicationType, CallNotifyEventContent, NotifyType}, }, direct::{DirectEventContent, OwnedDirectUserIdentifier}, + ignored_user_list::IgnoredUserListEventContent, member_hints::MemberHintsEventContent, poll::{ unstable_end::UnstablePollEndEventContent, @@ -999,6 +1000,16 @@ impl EventFactory { builder } + /// Create a new `m.ignored_user_list` global account data event. + pub fn ignored_user_list( + &self, + users: impl IntoIterator, + ) -> EventBuilder { + let mut builder = self.event(IgnoredUserListEventContent::users(users)); + builder.is_global = true; + builder + } + /// Set the next server timestamp. /// /// Timestamps will continue to increase by 1 (millisecond) from that value. diff --git a/testing/matrix-sdk-test/src/sync_builder/mod.rs b/testing/matrix-sdk-test/src/sync_builder/mod.rs index 2fcbcaed9..e3a5535dc 100644 --- a/testing/matrix-sdk-test/src/sync_builder/mod.rs +++ b/testing/matrix-sdk-test/src/sync_builder/mod.rs @@ -152,7 +152,6 @@ impl SyncResponseBuilder { ) -> &mut Self { let val = match event { GlobalAccountDataTestEvent::PushRules => test_json::PUSH_RULES.to_owned(), - GlobalAccountDataTestEvent::IgnoredUserList => test_json::IGNORED_USER_LIST.to_owned(), GlobalAccountDataTestEvent::Custom(json) => json, }; diff --git a/testing/matrix-sdk-test/src/sync_builder/test_event.rs b/testing/matrix-sdk-test/src/sync_builder/test_event.rs index 246e5fe3a..d0ada91d7 100644 --- a/testing/matrix-sdk-test/src/sync_builder/test_event.rs +++ b/testing/matrix-sdk-test/src/sync_builder/test_event.rs @@ -150,7 +150,6 @@ impl From for Raw { /// Test events that can be added to the global account data. pub enum GlobalAccountDataTestEvent { PushRules, - IgnoredUserList, Custom(JsonValue), } @@ -158,9 +157,6 @@ impl From for JsonValue { fn from(val: GlobalAccountDataTestEvent) -> Self { match val { GlobalAccountDataTestEvent::PushRules => test_json::sync_events::PUSH_RULES.to_owned(), - GlobalAccountDataTestEvent::IgnoredUserList => { - test_json::sync_events::IGNORED_USER_LIST.to_owned() - } GlobalAccountDataTestEvent::Custom(json) => json, } } diff --git a/testing/matrix-sdk-test/src/test_json/mod.rs b/testing/matrix-sdk-test/src/test_json/mod.rs index 9393cb9e8..2d9fbd011 100644 --- a/testing/matrix-sdk-test/src/test_json/mod.rs +++ b/testing/matrix-sdk-test/src/test_json/mod.rs @@ -29,10 +29,9 @@ pub use sync::{ VOIP_SYNC, }; pub use sync_events::{ - ALIAS, ALIASES, ENCRYPTION, IGNORED_USER_LIST, MEMBER, MEMBER_ADDITIONAL, MEMBER_BAN, - MEMBER_INVITE, MEMBER_LEAVE, MEMBER_NAME_CHANGE, MEMBER_STRIPPED, NAME, NAME_STRIPPED, - POWER_LEVELS, PRESENCE, PUSH_RULES, REDACTED_INVALID, REDACTED_STATE, TAG, TOPIC, - TOPIC_REDACTION, + ALIAS, ALIASES, ENCRYPTION, MEMBER, MEMBER_ADDITIONAL, MEMBER_BAN, MEMBER_INVITE, MEMBER_LEAVE, + MEMBER_NAME_CHANGE, MEMBER_STRIPPED, NAME, NAME_STRIPPED, POWER_LEVELS, PRESENCE, PUSH_RULES, + REDACTED_INVALID, REDACTED_STATE, TAG, TOPIC, TOPIC_REDACTION, }; /// An empty response. diff --git a/testing/matrix-sdk-test/src/test_json/sync_events.rs b/testing/matrix-sdk-test/src/test_json/sync_events.rs index ae73f7b71..dab8fe725 100644 --- a/testing/matrix-sdk-test/src/test_json/sync_events.rs +++ b/testing/matrix-sdk-test/src/test_json/sync_events.rs @@ -723,14 +723,3 @@ pub static MARKED_UNREAD: Lazy = Lazy::new(|| { "type": "m.marked_unread", }) }); - -pub static IGNORED_USER_LIST: Lazy = Lazy::new(|| { - json!({ - "content": { - "ignored_users": { - "@someone:example.org": {}, - }, - }, - "type": "m.ignored_user_list", - }) -});