diff --git a/Cargo.lock b/Cargo.lock index 618a58d8c..b380518ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4658,7 +4658,7 @@ dependencies = [ [[package]] name = "ruma" version = "0.12.6" -source = "git+https://github.com/ruma/ruma?rev=a2fe858133ba932b4bda730dc7472c9c985739a0#a2fe858133ba932b4bda730dc7472c9c985739a0" +source = "git+https://github.com/ruma/ruma?rev=d879f7df16ba9928a73649f8149dabeee939691e#d879f7df16ba9928a73649f8149dabeee939691e" dependencies = [ "assign", "js_int", @@ -4675,7 +4675,7 @@ dependencies = [ [[package]] name = "ruma-client-api" version = "0.20.4" -source = "git+https://github.com/ruma/ruma?rev=a2fe858133ba932b4bda730dc7472c9c985739a0#a2fe858133ba932b4bda730dc7472c9c985739a0" +source = "git+https://github.com/ruma/ruma?rev=d879f7df16ba9928a73649f8149dabeee939691e#d879f7df16ba9928a73649f8149dabeee939691e" dependencies = [ "as_variant", "assign", @@ -4698,7 +4698,7 @@ dependencies = [ [[package]] name = "ruma-common" version = "0.15.4" -source = "git+https://github.com/ruma/ruma?rev=a2fe858133ba932b4bda730dc7472c9c985739a0#a2fe858133ba932b4bda730dc7472c9c985739a0" +source = "git+https://github.com/ruma/ruma?rev=d879f7df16ba9928a73649f8149dabeee939691e#d879f7df16ba9928a73649f8149dabeee939691e" dependencies = [ "as_variant", "base64", @@ -4731,7 +4731,7 @@ dependencies = [ [[package]] name = "ruma-events" version = "0.30.5" -source = "git+https://github.com/ruma/ruma?rev=a2fe858133ba932b4bda730dc7472c9c985739a0#a2fe858133ba932b4bda730dc7472c9c985739a0" +source = "git+https://github.com/ruma/ruma?rev=d879f7df16ba9928a73649f8149dabeee939691e#d879f7df16ba9928a73649f8149dabeee939691e" dependencies = [ "as_variant", "indexmap", @@ -4757,7 +4757,7 @@ dependencies = [ [[package]] name = "ruma-federation-api" version = "0.11.2" -source = "git+https://github.com/ruma/ruma?rev=a2fe858133ba932b4bda730dc7472c9c985739a0#a2fe858133ba932b4bda730dc7472c9c985739a0" +source = "git+https://github.com/ruma/ruma?rev=d879f7df16ba9928a73649f8149dabeee939691e#d879f7df16ba9928a73649f8149dabeee939691e" dependencies = [ "headers", "http", @@ -4777,7 +4777,7 @@ dependencies = [ [[package]] name = "ruma-html" version = "0.4.1" -source = "git+https://github.com/ruma/ruma?rev=a2fe858133ba932b4bda730dc7472c9c985739a0#a2fe858133ba932b4bda730dc7472c9c985739a0" +source = "git+https://github.com/ruma/ruma?rev=d879f7df16ba9928a73649f8149dabeee939691e#d879f7df16ba9928a73649f8149dabeee939691e" dependencies = [ "as_variant", "html5ever", @@ -4788,7 +4788,7 @@ dependencies = [ [[package]] name = "ruma-identifiers-validation" version = "0.10.1" -source = "git+https://github.com/ruma/ruma?rev=a2fe858133ba932b4bda730dc7472c9c985739a0#a2fe858133ba932b4bda730dc7472c9c985739a0" +source = "git+https://github.com/ruma/ruma?rev=d879f7df16ba9928a73649f8149dabeee939691e#d879f7df16ba9928a73649f8149dabeee939691e" dependencies = [ "js_int", "thiserror 2.0.11", @@ -4797,7 +4797,7 @@ dependencies = [ [[package]] name = "ruma-macros" version = "0.15.2" -source = "git+https://github.com/ruma/ruma?rev=a2fe858133ba932b4bda730dc7472c9c985739a0#a2fe858133ba932b4bda730dc7472c9c985739a0" +source = "git+https://github.com/ruma/ruma?rev=d879f7df16ba9928a73649f8149dabeee939691e#d879f7df16ba9928a73649f8149dabeee939691e" dependencies = [ "cfg-if", "proc-macro-crate", diff --git a/Cargo.toml b/Cargo.toml index 35c4cddc8..ea6e27d05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,7 @@ proptest = { version = "1.6.0", default-features = false, features = ["std"] } rand = "0.8.5" reqwest = { version = "0.12.12", default-features = false } rmp-serde = "1.3.0" -ruma = { git = "https://github.com/ruma/ruma", rev = "a2fe858133ba932b4bda730dc7472c9c985739a0", features = [ +ruma = { git = "https://github.com/ruma/ruma", rev = "d879f7df16ba9928a73649f8149dabeee939691e", features = [ "client-api-c", "compat-upload-signatures", "compat-arbitrary-length-ids", @@ -79,7 +79,7 @@ ruma = { git = "https://github.com/ruma/ruma", rev = "a2fe858133ba932b4bda730dc7 "unstable-msc4286", "unstable-msc4306" ] } -ruma-common = { git = "https://github.com/ruma/ruma", rev = "a2fe858133ba932b4bda730dc7472c9c985739a0" } +ruma-common = { git = "https://github.com/ruma/ruma", rev = "d879f7df16ba9928a73649f8149dabeee939691e" } sentry = "0.36.0" sentry-tracing = "0.36.0" serde = { version = "1.0.217", features = ["rc"] } diff --git a/crates/matrix-sdk-base/src/deserialized_responses.rs b/crates/matrix-sdk-base/src/deserialized_responses.rs index 2c7002b3c..eda956b50 100644 --- a/crates/matrix-sdk-base/src/deserialized_responses.rs +++ b/crates/matrix-sdk-base/src/deserialized_responses.rs @@ -21,9 +21,8 @@ use once_cell::sync::Lazy; use regex::Regex; use ruma::{ EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedUserId, UInt, UserId, - api::client::sync::sync_events::StrippedState, events::{ - AnySyncStateEvent, AnySyncTimelineEvent, EventContentFromType, + AnyStrippedStateEvent, AnySyncStateEvent, AnySyncTimelineEvent, EventContentFromType, PossiblyRedactedStateEventContent, RedactContent, RedactedStateEventContent, StateEventContent, StaticStateEventContent, StrippedStateEvent, SyncStateEvent, room::{ @@ -262,7 +261,7 @@ pub enum RawAnySyncOrStrippedTimelineEvent { /// An event from a room in joined or left state. Sync(Raw), /// An event from a room in invited state. - Stripped(Raw), + Stripped(Raw), } impl From> for RawAnySyncOrStrippedTimelineEvent { @@ -271,8 +270,8 @@ impl From> for RawAnySyncOrStrippedTimelineEvent { } } -impl From> for RawAnySyncOrStrippedTimelineEvent { - fn from(event: Raw) -> Self { +impl From> for RawAnySyncOrStrippedTimelineEvent { + fn from(event: Raw) -> Self { Self::Stripped(event) } } @@ -284,7 +283,7 @@ pub enum RawAnySyncOrStrippedState { /// An event from a room in joined or left state. Sync(Raw), /// An event from a room in invited state. - Stripped(Raw), + Stripped(Raw), } impl RawAnySyncOrStrippedState { @@ -324,7 +323,7 @@ pub enum AnySyncOrStrippedState { /// /// The value is `Box`ed because it is quite large. Let's keep the size of /// `Self` as small as possible. - Stripped(Box), + Stripped(Box), } impl AnySyncOrStrippedState { @@ -339,7 +338,7 @@ impl AnySyncOrStrippedState { /// If this is an `AnyStrippedStateEvent`, return a reference to the inner /// event. - pub fn as_stripped(&self) -> Option<&StrippedState> { + pub fn as_stripped(&self) -> Option<&AnyStrippedStateEvent> { match self { Self::Sync(_) => None, Self::Stripped(ev) => Some(ev), diff --git a/crates/matrix-sdk-base/src/response_processors/room/msc4186/mod.rs b/crates/matrix-sdk-base/src/response_processors/room/msc4186/mod.rs index e339919bb..2150e3f18 100644 --- a/crates/matrix-sdk-base/src/response_processors/room/msc4186/mod.rs +++ b/crates/matrix-sdk-base/src/response_processors/room/msc4186/mod.rs @@ -23,7 +23,6 @@ use matrix_sdk_common::deserialized_responses::TimelineEvent; use ruma::{ JsOption, OwnedRoomId, RoomId, UserId, api::client::sync::sync_events::{ - StrippedState, v3::{InviteState, InvitedRoom, KnockState, KnockedRoom}, v5 as http, }, @@ -226,7 +225,7 @@ pub async fn update_any_room( fn membership( context: &mut Context, state_events: &[AnySyncStateEvent], - invite_state_events: &Option<(Vec>, Vec)>, + invite_state_events: &Option<(Vec>, Vec)>, store: &BaseStateStore, user_id: &UserId, room_id: &RoomId, diff --git a/crates/matrix-sdk-base/src/response_processors/state_events.rs b/crates/matrix-sdk-base/src/response_processors/state_events.rs index aceb4f5b8..70fcf0067 100644 --- a/crates/matrix-sdk-base/src/response_processors/state_events.rs +++ b/crates/matrix-sdk-base/src/response_processors/state_events.rs @@ -206,10 +206,8 @@ pub mod sync { pub mod stripped { use std::{collections::BTreeMap, iter}; - use ruma::{ - api::client::sync::sync_events::StrippedState, events::AnyStrippedStateEvent, push::Action, - }; - use tracing::{instrument, warn}; + use ruma::{events::AnyStrippedStateEvent, push::Action}; + use tracing::instrument; use super::{ super::{notification, timeline}, @@ -217,20 +215,11 @@ pub mod stripped { }; use crate::{Result, Room, RoomInfo}; - /// Collect [`Raw`] to [`AnyStrippedStateEvent`]. + /// Collect [`Raw`] to [`AnyStrippedStateEvent`]. pub fn collect( - raw_events: &[Raw], - ) -> (Vec>, Vec) { - raw_events - .iter() - .filter_map(|raw_event| match raw_event.deserialize_as() { - Ok(event) => Some((raw_event.clone(), event)), - Err(e) => { - warn!("Couldn't deserialize stripped state event: {e}"); - None - } - }) - .unzip() + raw_events: &[Raw], + ) -> (Vec>, Vec) { + super::collect(raw_events) } /// Dispatch the stripped state events. @@ -252,7 +241,7 @@ pub mod stripped { #[instrument(skip_all, fields(room_id = ?room_info.room_id))] pub(crate) async fn dispatch_invite_or_knock( context: &mut Context, - (raw_events, events): (&[Raw], &[AnyStrippedStateEvent]), + (raw_events, events): (&[Raw], &[AnyStrippedStateEvent]), room: &Room, room_info: &mut RoomInfo, mut notification: notification::Notification<'_>, diff --git a/crates/matrix-sdk-base/src/store/integration_tests.rs b/crates/matrix-sdk-base/src/store/integration_tests.rs index bb4ba2558..6249ef23d 100644 --- a/crates/matrix-sdk-base/src/store/integration_tests.rs +++ b/crates/matrix-sdk-base/src/store/integration_tests.rs @@ -10,16 +10,13 @@ use ruma::{ EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedUserId, RoomId, TransactionId, UserId, api::{ FeatureFlag, MatrixVersion, - client::{ - discovery::discover_homeserver::{HomeserverInfo, RtcFocusInfo}, - sync::sync_events::StrippedState, - }, + client::discovery::discover_homeserver::{HomeserverInfo, RtcFocusInfo}, }, event_id, events::{ AnyGlobalAccountDataEvent, AnyMessageLikeEventContent, AnyRoomAccountDataEvent, - AnySyncStateEvent, GlobalAccountDataEventType, RoomAccountDataEventType, StateEventType, - SyncStateEvent, + AnyStrippedStateEvent, AnySyncStateEvent, GlobalAccountDataEventType, + RoomAccountDataEventType, StateEventType, SyncStateEvent, presence::PresenceEvent, receipt::{ReceiptThread, ReceiptType}, room::{ @@ -193,8 +190,8 @@ impl StateStoreIntegrationTests for DynStateStore { let stripped_name_json: &JsonValue = &test_json::NAME_STRIPPED; let stripped_name_raw = - serde_json::from_value::>(stripped_name_json.clone())?; - let stripped_name_event = stripped_name_raw.deserialize_as()?; + serde_json::from_value::>(stripped_name_json.clone())?; + let stripped_name_event = stripped_name_raw.deserialize()?; stripped_room.handle_stripped_state_event(&stripped_name_event); changes.stripped_state.insert( stripped_room_id.to_owned(), diff --git a/crates/matrix-sdk-base/src/store/memory_store.rs b/crates/matrix-sdk-base/src/store/memory_store.rs index a974ac065..fdf3676b9 100644 --- a/crates/matrix-sdk-base/src/store/memory_store.rs +++ b/crates/matrix-sdk-base/src/store/memory_store.rs @@ -23,11 +23,10 @@ use matrix_sdk_common::{ROOM_VERSION_FALLBACK, ROOM_VERSION_RULES_FALLBACK}; use ruma::{ CanonicalJsonObject, EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedMxcUri, OwnedRoomId, OwnedTransactionId, OwnedUserId, RoomId, TransactionId, UserId, - api::client::sync::sync_events::StrippedState, canonical_json::{RedactedBecause, redact}, events::{ - AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnySyncStateEvent, - GlobalAccountDataEventType, RoomAccountDataEventType, StateEventType, + AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnyStrippedStateEvent, + AnySyncStateEvent, GlobalAccountDataEventType, RoomAccountDataEventType, StateEventType, presence::PresenceEvent, receipt::{Receipt, ReceiptThread, ReceiptType}, room::member::{MembershipState, StrippedRoomMemberEvent, SyncRoomMemberEvent}, @@ -69,7 +68,7 @@ struct MemoryStoreInner { room_account_data: HashMap>>, stripped_room_state: - HashMap>>>, + HashMap>>>, stripped_members: HashMap>, presence: HashMap>, room_user_receipts: HashMap< diff --git a/crates/matrix-sdk-base/src/store/mod.rs b/crates/matrix-sdk-base/src/store/mod.rs index 9dc1524b7..73c234a68 100644 --- a/crates/matrix-sdk-base/src/store/mod.rs +++ b/crates/matrix-sdk-base/src/store/mod.rs @@ -47,12 +47,11 @@ pub use matrix_sdk_store_encryption::Error as StoreEncryptionError; use observable_map::ObservableMap; use ruma::{ EventId, OwnedEventId, OwnedRoomId, OwnedUserId, RoomId, UserId, - api::client::sync::sync_events::StrippedState, events::{ - AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnySyncStateEvent, EmptyStateKey, - GlobalAccountDataEventType, RedactContent, RedactedStateEventContent, - RoomAccountDataEventType, StateEventType, StaticEventContent, StaticStateEventContent, - StrippedStateEvent, SyncStateEvent, + AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnyStrippedStateEvent, + AnySyncStateEvent, EmptyStateKey, GlobalAccountDataEventType, RedactContent, + RedactedStateEventContent, RoomAccountDataEventType, StateEventType, StaticEventContent, + StaticStateEventContent, StrippedStateEvent, SyncStateEvent, presence::PresenceEvent, receipt::ReceiptEventContent, room::{ @@ -517,8 +516,10 @@ pub struct StateChanges { /// A mapping of `RoomId` to a map of event type to a map of state key to /// `StrippedState`. - pub stripped_state: - BTreeMap>>>, + pub stripped_state: BTreeMap< + OwnedRoomId, + BTreeMap>>, + >, /// A map from room id to a map of a display name and a set of user ids that /// share that display name in the given room. diff --git a/testing/matrix-sdk-integration-testing/src/tests/sliding_sync/notification_client.rs b/testing/matrix-sdk-integration-testing/src/tests/sliding_sync/notification_client.rs index 7013b5258..42b8e5fcd 100644 --- a/testing/matrix-sdk-integration-testing/src/tests/sliding_sync/notification_client.rs +++ b/testing/matrix-sdk-integration-testing/src/tests/sliding_sync/notification_client.rs @@ -70,7 +70,7 @@ async fn test_notification() -> Result<()> { }; if let Some(event_id) = invited_room.invite_state.events.iter().find_map(|event| { - let Ok(AnyStrippedStateEvent::RoomMember(room_member_ev)) = event.deserialize_as() else { + let Ok(AnyStrippedStateEvent::RoomMember(room_member_ev)) = event.deserialize() else { return None; }; diff --git a/testing/matrix-sdk-test/src/lib.rs b/testing/matrix-sdk-test/src/lib.rs index 163f25a9c..78ad1ee32 100644 --- a/testing/matrix-sdk-test/src/lib.rs +++ b/testing/matrix-sdk-test/src/lib.rs @@ -68,7 +68,7 @@ macro_rules! stripped_state_event { ($( $tt:tt )*) => { ::ruma::serde::Raw::new(&::serde_json::json!( $($tt)* )) .unwrap() - .cast_unchecked::<::ruma::api::client::sync::sync_events::StrippedState>() + .cast_unchecked::<::ruma::events::AnyStrippedStateEvent>() } } diff --git a/testing/matrix-sdk-test/src/sync_builder/invited_room.rs b/testing/matrix-sdk-test/src/sync_builder/invited_room.rs index cddfba80f..842a86be3 100644 --- a/testing/matrix-sdk-test/src/sync_builder/invited_room.rs +++ b/testing/matrix-sdk-test/src/sync_builder/invited_room.rs @@ -1,7 +1,6 @@ use ruma::{ - OwnedRoomId, RoomId, - api::client::sync::sync_events::{StrippedState, v3::InvitedRoom}, - serde::Raw, + OwnedRoomId, RoomId, api::client::sync::sync_events::v3::InvitedRoom, + events::AnyStrippedStateEvent, serde::Raw, }; use crate::DEFAULT_TEST_ROOM_ID; @@ -26,7 +25,7 @@ impl InvitedRoomBuilder { } /// Add an event to the state. - pub fn add_state_event(mut self, event: impl Into>) -> Self { + pub fn add_state_event(mut self, event: impl Into>) -> Self { self.inner.invite_state.events.push(event.into()); self } @@ -34,7 +33,7 @@ impl InvitedRoomBuilder { /// Add events to the state in bulk. pub fn add_state_bulk(mut self, events: I) -> Self where - I: IntoIterator>, + I: IntoIterator>, { self.inner.invite_state.events.extend(events); self diff --git a/testing/matrix-sdk-test/src/sync_builder/knocked_room.rs b/testing/matrix-sdk-test/src/sync_builder/knocked_room.rs index 9c548041a..065636ab4 100644 --- a/testing/matrix-sdk-test/src/sync_builder/knocked_room.rs +++ b/testing/matrix-sdk-test/src/sync_builder/knocked_room.rs @@ -1,7 +1,6 @@ use ruma::{ - OwnedRoomId, RoomId, - api::client::sync::sync_events::{StrippedState, v3::KnockedRoom}, - serde::Raw, + OwnedRoomId, RoomId, api::client::sync::sync_events::v3::KnockedRoom, + events::AnyStrippedStateEvent, serde::Raw, }; use super::StrippedStateTestEvent; @@ -35,7 +34,7 @@ impl KnockedRoomBuilder { /// Add events to the state in bulk. pub fn add_state_bulk(mut self, events: I) -> Self where - I: IntoIterator>, + I: IntoIterator>, { self.inner.knock_state.events.extend(events); self 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 9b2b36910..3d864804a 100644 --- a/testing/matrix-sdk-test/src/sync_builder/test_event.rs +++ b/testing/matrix-sdk-test/src/sync_builder/test_event.rs @@ -1,8 +1,7 @@ use ruma::{ - api::client::sync::sync_events::StrippedState, events::{ - AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnySyncStateEvent, - presence::PresenceEvent, + AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnyStrippedStateEvent, + AnySyncStateEvent, presence::PresenceEvent, }, serde::Raw, }; @@ -90,7 +89,7 @@ impl From for JsonValue { } } -impl From for Raw { +impl From for Raw { fn from(val: StrippedStateTestEvent) -> Self { from_json_value(val.into()).unwrap() }