From 77c2a4ed4f46fb77d752d1f244513fd23c0b479b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Wed, 12 May 2021 16:21:44 +0200 Subject: [PATCH] matrix-sdk: Bump ruma --- matrix_sdk/src/client.rs | 2 +- matrix_sdk/src/event_handler/mod.rs | 76 ++++++++++++------- matrix_sdk/src/room/joined.rs | 8 +- matrix_sdk_appservice/tests/tests.rs | 6 +- matrix_sdk_base/src/client.rs | 18 +++-- matrix_sdk_base/src/rooms/normal.rs | 4 +- matrix_sdk_base/src/store/memory_store.rs | 15 ++-- matrix_sdk_base/src/store/mod.rs | 22 +++--- matrix_sdk_base/src/store/sled_store/mod.rs | 10 +-- matrix_sdk_common/Cargo.toml | 2 +- .../src/deserialized_responses.rs | 15 ++-- matrix_sdk_common/src/lib.rs | 2 +- matrix_sdk_crypto/src/machine.rs | 4 +- matrix_sdk_test/src/lib.rs | 8 +- matrix_sdk_test/src/test_json/sync.rs | 49 +++++++----- 15 files changed, 140 insertions(+), 101 deletions(-) diff --git a/matrix_sdk/src/client.rs b/matrix_sdk/src/client.rs index a6d3cff6..cacd998e 100644 --- a/matrix_sdk/src/client.rs +++ b/matrix_sdk/src/client.rs @@ -1573,7 +1573,7 @@ impl Client { MIN_UPLOAD_REQUEST_TIMEOUT, ); - let request = assign!(create_content::Request::new(data), { + let request = assign!(create_content::Request::new(&data), { content_type: Some(content_type.essence_str()), }); diff --git a/matrix_sdk/src/event_handler/mod.rs b/matrix_sdk/src/event_handler/mod.rs index 370fa2fc..9b5b0ef2 100644 --- a/matrix_sdk/src/event_handler/mod.rs +++ b/matrix_sdk/src/event_handler/mod.rs @@ -15,7 +15,12 @@ use std::ops::Deref; use matrix_sdk_common::{ - api::r0::push::get_notifications::Notification, events::AnySyncRoomEvent, identifiers::RoomId, + api::r0::push::get_notifications::Notification, + events::{ + fully_read::FullyReadEventContent, AnySyncRoomEvent, GlobalAccountDataEvent, + RoomAccountDataEvent, + }, + identifiers::RoomId, }; use serde_json::value::RawValue as RawJsonValue; @@ -27,7 +32,6 @@ use crate::{ hangup::HangupEventContent, invite::InviteEventContent, }, custom::CustomEventContent, - fully_read::FullyReadEventContent, ignored_user_list::IgnoredUserListEventContent, presence::PresenceEvent, push_rules::PushRulesEventContent, @@ -45,9 +49,9 @@ use crate::{ tombstone::TombstoneEventContent, }, typing::TypingEventContent, - AnyBasicEvent, AnyStrippedStateEvent, AnySyncEphemeralRoomEvent, AnySyncMessageEvent, - AnySyncStateEvent, BasicEvent, StrippedStateEvent, SyncEphemeralRoomEvent, - SyncMessageEvent, SyncStateEvent, + AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnyStrippedStateEvent, + AnySyncEphemeralRoomEvent, AnySyncMessageEvent, AnySyncStateEvent, StrippedStateEvent, + SyncEphemeralRoomEvent, SyncMessageEvent, SyncStateEvent, }, room::Room, Client, @@ -73,6 +77,15 @@ impl Handler { } pub(crate) async fn handle_sync(&self, response: &SyncResponse) { + for event in response + .account_data + .events + .iter() + .filter_map(|e| e.deserialize().ok()) + { + self.handle_account_data_event(&event).await; + } + for (room_id, room_info) in &response.rooms.join { if let Some(room) = self.get_room(room_id) { for event in room_info @@ -90,7 +103,8 @@ impl Handler { .iter() .filter_map(|e| e.deserialize().ok()) { - self.handle_account_data_event(room.clone(), &event).await; + self.handle_room_account_data_event(room.clone(), &event) + .await; } for event in room_info @@ -121,7 +135,8 @@ impl Handler { .iter() .filter_map(|e| e.deserialize().ok()) { - self.handle_account_data_event(room.clone(), &event).await; + self.handle_room_account_data_event(room.clone(), &event) + .await; } for event in room_info @@ -272,13 +287,27 @@ impl Handler { } } - pub(crate) async fn handle_account_data_event(&self, room: Room, event: &AnyBasicEvent) { + pub(crate) async fn handle_room_account_data_event( + &self, + room: Room, + event: &AnyRoomAccountDataEvent, + ) { match event { - AnyBasicEvent::Presence(presence) => self.on_non_room_presence(room, &presence).await, - AnyBasicEvent::IgnoredUserList(ignored) => { - self.on_non_room_ignored_users(room, &ignored).await + AnyRoomAccountDataEvent::FullyRead(event) => { + self.on_non_room_fully_read(room, &event).await + } + _ => {} + } + } + + pub(crate) async fn handle_account_data_event(&self, event: &AnyGlobalAccountDataEvent) { + match event { + AnyGlobalAccountDataEvent::IgnoredUserList(ignored) => { + self.on_non_room_ignored_users(&ignored).await + } + AnyGlobalAccountDataEvent::PushRules(rules) => { + self.on_non_room_push_rules(&rules).await } - AnyBasicEvent::PushRules(rules) => self.on_non_room_push_rules(room, &rules).await, _ => {} } } @@ -289,9 +318,6 @@ impl Handler { event: &AnySyncEphemeralRoomEvent, ) { match event { - AnySyncEphemeralRoomEvent::FullyRead(full_read) => { - self.on_non_room_fully_read(room, full_read).await - } AnySyncEphemeralRoomEvent::Typing(typing) => { self.on_non_room_typing(room, typing).await } @@ -307,7 +333,7 @@ impl Handler { #[derive(Clone, Copy, Debug)] pub enum CustomEvent<'c> { /// A custom basic event. - Basic(&'c BasicEvent), + Basic(&'c GlobalAccountDataEvent), /// A custom basic event. EphemeralRoom(&'c SyncEphemeralRoomEvent), /// A custom room event. @@ -477,17 +503,16 @@ pub trait EventHandler: Send + Sync { /// Fires when `Client` receives a `NonRoomEvent::RoomName` event. async fn on_non_room_ignored_users( &self, - _: Room, - _: &BasicEvent, + _: &GlobalAccountDataEvent, ) { } /// Fires when `Client` receives a `NonRoomEvent::RoomCanonicalAlias` event. - async fn on_non_room_push_rules(&self, _: Room, _: &BasicEvent) {} + async fn on_non_room_push_rules(&self, _: &GlobalAccountDataEvent) {} /// Fires when `Client` receives a `NonRoomEvent::RoomAliases` event. async fn on_non_room_fully_read( &self, _: Room, - _: &SyncEphemeralRoomEvent, + _: &RoomAccountDataEvent, ) { } /// Fires when `Client` receives a `NonRoomEvent::Typing` event. @@ -689,18 +714,17 @@ mod test { } async fn on_non_room_ignored_users( &self, - _: Room, - _: &BasicEvent, + _: &GlobalAccountDataEvent, ) { self.0.lock().await.push("account ignore".to_string()) } - async fn on_non_room_push_rules(&self, _: Room, _: &BasicEvent) { + async fn on_non_room_push_rules(&self, _: &GlobalAccountDataEvent) { self.0.lock().await.push("account push rules".to_string()) } async fn on_non_room_fully_read( &self, _: Room, - _: &SyncEphemeralRoomEvent, + _: &RoomAccountDataEvent, ) { self.0.lock().await.push("account read".to_string()) } @@ -774,9 +798,9 @@ mod test { assert_eq!( v.as_slice(), [ + "account ignore", "receipt event", "account read", - "account ignore", "state rules", "state member", "state aliases", @@ -902,9 +926,9 @@ mod test { assert_eq!( v.as_slice(), [ + "account ignore", "receipt event", "account read", - "account ignore", "state rules", "state member", "state aliases", diff --git a/matrix_sdk/src/room/joined.rs b/matrix_sdk/src/room/joined.rs index 0a66409d..098e722d 100644 --- a/matrix_sdk/src/room/joined.rs +++ b/matrix_sdk/src/room/joined.rs @@ -31,6 +31,7 @@ use matrix_sdk_common::{ }, identifiers::{EventId, UserId}, instant::{Duration, Instant}, + receipt::ReceiptType, uuid::Uuid, }; @@ -225,11 +226,8 @@ impl Joined { /// /// * `event_id` - The `EventId` specifies the event to set the read receipt on. pub async fn read_receipt(&self, event_id: &EventId) -> Result<()> { - let request = create_receipt::Request::new( - self.inner.room_id(), - create_receipt::ReceiptType::Read, - event_id, - ); + let request = + create_receipt::Request::new(self.inner.room_id(), ReceiptType::Read, event_id); self.client.send(request, None).await?; Ok(()) diff --git a/matrix_sdk_appservice/tests/tests.rs b/matrix_sdk_appservice/tests/tests.rs index 19e8bc29..20de8a06 100644 --- a/matrix_sdk_appservice/tests/tests.rs +++ b/matrix_sdk_appservice/tests/tests.rs @@ -4,7 +4,7 @@ use matrix_sdk::{ api_appservice, api_appservice::Registration, async_trait, - events::{room::member::MemberEventContent, AnyEvent, AnyStateEvent, SyncStateEvent}, + events::{room::member::MemberEventContent, AnyRoomEvent, AnyStateEvent, SyncStateEvent}, room::Room, EventHandler, Raw, }; @@ -82,7 +82,7 @@ async fn test_event_handler() -> Result<()> { .await; let event = serde_json::from_value::(member_json()).unwrap(); - let event: Raw = AnyEvent::State(event).into(); + let event: Raw = AnyRoomEvent::State(event).into(); let events = vec![event]; let incoming = api_appservice::event::push_events::v1::IncomingRequest::new( @@ -100,7 +100,7 @@ async fn test_transaction() -> Result<()> { let appservice = appservice(None).await?; let event = serde_json::from_value::(member_json()).unwrap(); - let event: Raw = AnyEvent::State(event).into(); + let event: Raw = AnyRoomEvent::State(event).into(); let events = vec![event]; let incoming = api_appservice::event::push_events::v1::IncomingRequest::new( diff --git a/matrix_sdk_base/src/client.rs b/matrix_sdk_base/src/client.rs index 732909e7..bc3c382d 100644 --- a/matrix_sdk_base/src/client.rs +++ b/matrix_sdk_base/src/client.rs @@ -42,8 +42,8 @@ use matrix_sdk_common::{ }, events::{ room::member::{MemberEventContent, MembershipState}, - AnyBasicEvent, AnyStrippedStateEvent, AnySyncRoomEvent, AnySyncStateEvent, EventContent, - EventType, StateEvent, + AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnyStrippedStateEvent, + AnySyncRoomEvent, AnySyncStateEvent, EventContent, EventType, StateEvent, }, identifiers::{RoomId, UserId}, instant::Instant, @@ -657,7 +657,7 @@ impl BaseClient { async fn handle_room_account_data( &self, room_id: &RoomId, - events: &[Raw], + events: &[Raw], changes: &mut StateChanges, ) { for raw_event in events { @@ -667,7 +667,11 @@ impl BaseClient { } } - async fn handle_account_data(&self, events: &[Raw], changes: &mut StateChanges) { + async fn handle_account_data( + &self, + events: &[Raw], + changes: &mut StateChanges, + ) { let mut account_data = BTreeMap::new(); for raw_event in events { @@ -677,7 +681,7 @@ impl BaseClient { continue; }; - if let AnyBasicEvent::Direct(e) = &event { + if let AnyGlobalAccountDataEvent::Direct(e) = &event { for (user_id, rooms) in e.content.iter() { for room_id in rooms { if let Some(room) = changes.room_infos.get_mut(room_id) { @@ -1348,13 +1352,13 @@ impl BaseClient { /// Gets the push rules from `changes` if they have been updated, otherwise get them from the /// store. As a fallback, uses `Ruleset::server_default` if the user is logged in. pub async fn get_push_rules(&self, changes: &StateChanges) -> Result { - if let Some(AnyBasicEvent::PushRules(event)) = changes + if let Some(AnyGlobalAccountDataEvent::PushRules(event)) = changes .account_data .get(EventType::PushRules.as_str()) .and_then(|e| e.deserialize().ok()) { Ok(event.content.global) - } else if let Some(AnyBasicEvent::PushRules(event)) = self + } else if let Some(AnyGlobalAccountDataEvent::PushRules(event)) = self .store .get_account_data_event(EventType::PushRules) .await? diff --git a/matrix_sdk_base/src/rooms/normal.rs b/matrix_sdk_base/src/rooms/normal.rs index 2587645e..8929aee6 100644 --- a/matrix_sdk_base/src/rooms/normal.rs +++ b/matrix_sdk_base/src/rooms/normal.rs @@ -30,7 +30,7 @@ use matrix_sdk_common::{ tombstone::TombstoneEventContent, }, tag::Tags, - AnyBasicEvent, AnyStateEventContent, AnySyncStateEvent, EventType, + AnyRoomAccountDataEvent, AnyStateEventContent, AnySyncStateEvent, EventType, }, identifiers::{MxcUri, RoomAliasId, RoomId, UserId}, }; @@ -451,7 +451,7 @@ impl Room { /// Get the `Tags` for this room. pub async fn tags(&self) -> StoreResult> { - if let Some(AnyBasicEvent::Tag(event)) = self + if let Some(AnyRoomAccountDataEvent::Tag(event)) = self .store .get_room_account_data_event(self.room_id(), EventType::Tag) .await? diff --git a/matrix_sdk_base/src/store/memory_store.rs b/matrix_sdk_base/src/store/memory_store.rs index 8088d272..b9346082 100644 --- a/matrix_sdk_base/src/store/memory_store.rs +++ b/matrix_sdk_base/src/store/memory_store.rs @@ -23,7 +23,8 @@ use matrix_sdk_common::{ events::{ presence::PresenceEvent, room::member::{MemberEventContent, MembershipState}, - AnyBasicEvent, AnyStrippedStateEvent, AnySyncStateEvent, EventType, + AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnyStrippedStateEvent, + AnySyncStateEvent, EventType, }, identifiers::{RoomId, UserId}, instant::Instant, @@ -40,7 +41,7 @@ use super::{Result, RoomInfo, StateChanges, StateStore}; pub struct MemoryStore { sync_token: Arc>>, filters: Arc>, - account_data: Arc>>, + account_data: Arc>>, members: Arc>>, profiles: Arc>>, display_names: Arc>>>, @@ -49,7 +50,7 @@ pub struct MemoryStore { room_info: Arc>, #[allow(clippy::type_complexity)] room_state: Arc>>>>, - room_account_data: Arc>>>, + room_account_data: Arc>>>, stripped_room_info: Arc>, #[allow(clippy::type_complexity)] stripped_room_state: @@ -308,7 +309,7 @@ impl MemoryStore { async fn get_account_data_event( &self, event_type: EventType, - ) -> Result>> { + ) -> Result>> { Ok(self .account_data .get(event_type.as_ref()) @@ -319,7 +320,7 @@ impl MemoryStore { &self, room_id: &RoomId, event_type: EventType, - ) -> Result>> { + ) -> Result>> { Ok(self .room_account_data .get(room_id) @@ -411,7 +412,7 @@ impl StateStore for MemoryStore { async fn get_account_data_event( &self, event_type: EventType, - ) -> Result>> { + ) -> Result>> { self.get_account_data_event(event_type).await } @@ -419,7 +420,7 @@ impl StateStore for MemoryStore { &self, room_id: &RoomId, event_type: EventType, - ) -> Result>> { + ) -> Result>> { self.get_room_account_data_event(room_id, event_type).await } } diff --git a/matrix_sdk_base/src/store/mod.rs b/matrix_sdk_base/src/store/mod.rs index be7245b5..62a480b4 100644 --- a/matrix_sdk_base/src/store/mod.rs +++ b/matrix_sdk_base/src/store/mod.rs @@ -26,8 +26,8 @@ use matrix_sdk_common::{ api::r0::push::get_notifications::Notification, async_trait, events::{ - presence::PresenceEvent, room::member::MemberEventContent, AnyBasicEvent, - AnyStrippedStateEvent, AnySyncStateEvent, EventContent, EventType, + presence::PresenceEvent, room::member::MemberEventContent, AnyGlobalAccountDataEvent, + AnyRoomAccountDataEvent, AnyStrippedStateEvent, AnySyncStateEvent, EventContent, EventType, }, identifiers::{RoomId, UserId}, locks::RwLock, @@ -195,7 +195,7 @@ pub trait StateStore: AsyncTraitDeps { async fn get_account_data_event( &self, event_type: EventType, - ) -> Result>>; + ) -> Result>>; /// Get an event out of the room account data store. /// @@ -209,7 +209,7 @@ pub trait StateStore: AsyncTraitDeps { &self, room_id: &RoomId, event_type: EventType, - ) -> Result>>; + ) -> Result>>; } /// A state store wrapper for the SDK. @@ -362,7 +362,7 @@ pub struct StateChanges { /// A user session, containing an access token and information about the associated user account. pub session: Option, /// A mapping of event type string to `AnyBasicEvent`. - pub account_data: BTreeMap>, + pub account_data: BTreeMap>, /// A mapping of `UserId` to `PresenceEvent`. pub presence: BTreeMap>, @@ -374,7 +374,7 @@ pub struct StateChanges { /// A mapping of `RoomId` to a map of event type string to a state key and `AnySyncStateEvent`. pub state: BTreeMap>>>, /// A mapping of `RoomId` to a map of event type string to `AnyBasicEvent`. - pub room_account_data: BTreeMap>>, + pub room_account_data: BTreeMap>>, /// A map of `RoomId` to `RoomInfo`. pub room_infos: BTreeMap, @@ -420,7 +420,11 @@ impl StateChanges { } /// Update the `StateChanges` struct with the given `AnyBasicEvent`. - pub fn add_account_data(&mut self, event: AnyBasicEvent, raw_event: Raw) { + pub fn add_account_data( + &mut self, + event: AnyGlobalAccountDataEvent, + raw_event: Raw, + ) { self.account_data .insert(event.content().event_type().to_owned(), raw_event); } @@ -429,8 +433,8 @@ impl StateChanges { pub fn add_room_account_data( &mut self, room_id: &RoomId, - event: AnyBasicEvent, - raw_event: Raw, + event: AnyRoomAccountDataEvent, + raw_event: Raw, ) { self.room_account_data .entry(room_id.to_owned()) diff --git a/matrix_sdk_base/src/store/sled_store/mod.rs b/matrix_sdk_base/src/store/sled_store/mod.rs index 315f2a35..6f8d0290 100644 --- a/matrix_sdk_base/src/store/sled_store/mod.rs +++ b/matrix_sdk_base/src/store/sled_store/mod.rs @@ -31,7 +31,7 @@ use matrix_sdk_common::{ events::{ presence::PresenceEvent, room::member::{MemberEventContent, MembershipState}, - AnyBasicEvent, AnySyncStateEvent, EventType, + AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnySyncStateEvent, EventType, }, identifiers::{RoomId, UserId}, Raw, @@ -590,7 +590,7 @@ impl SledStore { pub async fn get_account_data_event( &self, event_type: EventType, - ) -> Result>> { + ) -> Result>> { Ok(self .account_data .get(event_type.encode())? @@ -602,7 +602,7 @@ impl SledStore { &self, room_id: &RoomId, event_type: EventType, - ) -> Result>> { + ) -> Result>> { Ok(self .room_account_data .get((room_id.as_str(), event_type.as_str()).encode())? @@ -690,7 +690,7 @@ impl StateStore for SledStore { async fn get_account_data_event( &self, event_type: EventType, - ) -> Result>> { + ) -> Result>> { self.get_account_data_event(event_type).await } @@ -698,7 +698,7 @@ impl StateStore for SledStore { &self, room_id: &RoomId, event_type: EventType, - ) -> Result>> { + ) -> Result>> { self.get_room_account_data_event(room_id, event_type).await } } diff --git a/matrix_sdk_common/Cargo.toml b/matrix_sdk_common/Cargo.toml index 2e2a1a94..5206e11d 100644 --- a/matrix_sdk_common/Cargo.toml +++ b/matrix_sdk_common/Cargo.toml @@ -22,7 +22,7 @@ async-trait = "0.1.42" [dependencies.ruma] version = "0.0.3" git = "https://github.com/ruma/ruma" -rev = "a0f7e1b771d3294187bae0b2816fbcf6ceb40b88" +rev = "3bdead1cf207e3ab9c8fcbfc454c054c726ba6f5" features = ["client-api-c", "compat", "unstable-pre-spec"] [target.'cfg(not(target_arch = "wasm32"))'.dependencies] diff --git a/matrix_sdk_common/src/deserialized_responses.rs b/matrix_sdk_common/src/deserialized_responses.rs index a3615ee6..c8ce70aa 100644 --- a/matrix_sdk_common/src/deserialized_responses.rs +++ b/matrix_sdk_common/src/deserialized_responses.rs @@ -1,6 +1,6 @@ use ruma::{ api::client::r0::sync::sync_events::{ - AccountData, Ephemeral, InvitedRoom, Presence, State, ToDevice, + Ephemeral, InvitedRoom, Presence, RoomAccountData, State, ToDevice, }, serde::Raw, DeviceIdBox, @@ -12,7 +12,8 @@ use super::{ api::r0::{ push::get_notifications::Notification, sync::sync_events::{ - DeviceLists, UnreadNotificationsCount as RumaUnreadNotificationsCount, + DeviceLists, GlobalAccountData, + UnreadNotificationsCount as RumaUnreadNotificationsCount, }, }, events::{ @@ -118,7 +119,7 @@ pub struct SyncResponse { /// Updates to the presence status of other users. pub presence: Presence, /// The global private data created by this user. - pub account_data: AccountData, + pub account_data: GlobalAccountData, /// Messages sent dirrectly between devices. pub to_device: ToDevice, /// Information on E2E device updates. @@ -165,7 +166,7 @@ pub struct JoinedRoom { /// given, or `full_state` is true). pub state: State, /// The private data that this user has attached to this room. - pub account_data: AccountData, + pub account_data: RoomAccountData, /// The ephemeral events in the room that aren't recorded in the timeline or state of the /// room. e.g. typing. pub ephemeral: Ephemeral, @@ -175,7 +176,7 @@ impl JoinedRoom { pub fn new( timeline: Timeline, state: State, - account_data: AccountData, + account_data: RoomAccountData, ephemeral: Ephemeral, unread_notifications: UnreadNotificationsCount, ) -> Self { @@ -220,11 +221,11 @@ pub struct LeftRoom { /// given, or `full_state` is true). pub state: State, /// The private data that this user has attached to this room. - pub account_data: AccountData, + pub account_data: RoomAccountData, } impl LeftRoom { - pub fn new(timeline: Timeline, state: State, account_data: AccountData) -> Self { + pub fn new(timeline: Timeline, state: State, account_data: RoomAccountData) -> Self { Self { timeline, state, diff --git a/matrix_sdk_common/src/lib.rs b/matrix_sdk_common/src/lib.rs index 081ea8b0..61db16da 100644 --- a/matrix_sdk_common/src/lib.rs +++ b/matrix_sdk_common/src/lib.rs @@ -13,7 +13,7 @@ pub use ruma::{ }, AuthScheme, EndpointError, IncomingResponse, OutgoingRequest, SendAccessToken, }, - assign, directory, encryption, events, identifiers, int, presence, push, + assign, directory, encryption, events, identifiers, int, presence, push, receipt, serde::{CanonicalJsonValue, Raw}, thirdparty, uint, Int, Outgoing, UInt, }; diff --git a/matrix_sdk_crypto/src/machine.rs b/matrix_sdk_crypto/src/machine.rs index 4bf422e3..be73530d 100644 --- a/matrix_sdk_crypto/src/machine.rs +++ b/matrix_sdk_crypto/src/machine.rs @@ -33,7 +33,7 @@ use matrix_sdk_common::{ deserialized_responses::{AlgorithmInfo, EncryptionInfo, SyncRoomEvent, VerificationState}, events::{ room::encrypted::{EncryptedEventContent, EncryptedEventScheme}, - room_key::RoomKeyEventContent, + room_key::RoomKeyToDeviceEventContent, AnyMessageEventContent, AnyToDeviceEvent, SyncMessageEvent, ToDeviceEvent, }, identifiers::{ @@ -592,7 +592,7 @@ impl OlmMachine { &self, sender_key: &str, signing_key: &str, - event: &mut ToDeviceEvent, + event: &mut ToDeviceEvent, ) -> OlmResult<(Option, Option)> { match event.content.algorithm { EventEncryptionAlgorithm::MegolmV1AesSha2 => { diff --git a/matrix_sdk_test/src/lib.rs b/matrix_sdk_test/src/lib.rs index 5fc92404..942c3c10 100644 --- a/matrix_sdk_test/src/lib.rs +++ b/matrix_sdk_test/src/lib.rs @@ -5,8 +5,8 @@ use http::Response; use matrix_sdk_common::{ api::r0::sync::sync_events::Response as SyncResponse, events::{ - presence::PresenceEvent, AnyBasicEvent, AnySyncEphemeralRoomEvent, AnySyncRoomEvent, - AnySyncStateEvent, + presence::PresenceEvent, AnyGlobalAccountDataEvent, AnySyncEphemeralRoomEvent, + AnySyncRoomEvent, AnySyncStateEvent, }, identifiers::{room_id, RoomId}, IncomingResponse, @@ -93,7 +93,7 @@ pub struct EventBuilder { /// The ephemeral room events that determine the state of a `Room`. ephemeral: Vec, /// The account data events that determine the state of a `Room`. - account_data: Vec, + account_data: Vec, /// Internal counter to enable the `prev_batch` and `next_batch` of each sync response to vary. batch_counter: i64, } @@ -123,7 +123,7 @@ impl EventBuilder { _ => panic!("unknown account event {:?}", json), }; - let event = serde_json::from_value::(val.clone()).unwrap(); + let event = serde_json::from_value::(val.clone()).unwrap(); self.account_data.push(event); self } diff --git a/matrix_sdk_test/src/test_json/sync.rs b/matrix_sdk_test/src/test_json/sync.rs index fb6dae52..862b126a 100644 --- a/matrix_sdk_test/src/test_json/sync.rs +++ b/matrix_sdk_test/src/test_json/sync.rs @@ -11,6 +11,18 @@ lazy_static! { ], "left": [] }, + "account_data": { + "events": [ + { + "content": { + "ignored_users": { + "@someone:example.org": {} + } + }, + "type": "m.ignored_user_list" + } + ] + }, "rooms": { "invite": {}, "join": { @@ -20,11 +32,10 @@ lazy_static! { "events": [ { "content": { - "ignored_users": { - "@someone:example.org": {} - } + "event_id": "$someplace:example.org" }, - "type": "m.ignored_user_list" + "room_id": "!roomid:room.com", + "type": "m.fully_read" } ] }, @@ -43,13 +54,6 @@ lazy_static! { "room_id": "!SVkFJHzfwvuaIEawgC:localhost", "type": "m.receipt" }, - { - "content": { - "event_id": "$someplace:example.org" - }, - "room_id": "!roomid:room.com", - "type": "m.fully_read" - } ] }, "state": { @@ -782,6 +786,18 @@ lazy_static! { ], "left": [] }, + "account_data": { + "events": [ + { + "content": { + "ignored_users": { + "@someone:example.org": {} + } + }, + "type": "m.ignored_user_list" + } + ] + }, "rooms": { "invite": {}, "join": {}, @@ -789,16 +805,7 @@ lazy_static! { "!SVkFJHzfwvuaIEawgC:localhost": { "summary": {}, "account_data": { - "events": [ - { - "content": { - "ignored_users": { - "@someone:example.org": {} - } - }, - "type": "m.ignored_user_list" - } - ] + "events": [] }, "ephemeral": { "events": [