Skip to content

Commit a3a239f

Browse files
zecakehHywan
authored andcommitted
Upgrade Ruma: revert StrippedState
Handle the previous breaking change that was reverted: `StrippedState` was removed and `AnyStrippedStateEvent` is used again. Signed-off-by: Kévin Commaille <[email protected]>
1 parent ca8b64e commit a3a239f

File tree

13 files changed

+53
-72
lines changed

13 files changed

+53
-72
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ proptest = { version = "1.6.0", default-features = false, features = ["std"] }
5959
rand = "0.8.5"
6060
reqwest = { version = "0.12.12", default-features = false }
6161
rmp-serde = "1.3.0"
62-
ruma = { git = "https://github.com/ruma/ruma", rev = "a2fe858133ba932b4bda730dc7472c9c985739a0", features = [
62+
ruma = { git = "https://github.com/ruma/ruma", rev = "d879f7df16ba9928a73649f8149dabeee939691e", features = [
6363
"client-api-c",
6464
"compat-upload-signatures",
6565
"compat-arbitrary-length-ids",
@@ -79,7 +79,7 @@ ruma = { git = "https://github.com/ruma/ruma", rev = "a2fe858133ba932b4bda730dc7
7979
"unstable-msc4286",
8080
"unstable-msc4306"
8181
] }
82-
ruma-common = { git = "https://github.com/ruma/ruma", rev = "a2fe858133ba932b4bda730dc7472c9c985739a0" }
82+
ruma-common = { git = "https://github.com/ruma/ruma", rev = "d879f7df16ba9928a73649f8149dabeee939691e" }
8383
sentry = "0.36.0"
8484
sentry-tracing = "0.36.0"
8585
serde = { version = "1.0.217", features = ["rc"] }

crates/matrix-sdk-base/src/deserialized_responses.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ use once_cell::sync::Lazy;
2121
use regex::Regex;
2222
use ruma::{
2323
EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedUserId, UInt, UserId,
24-
api::client::sync::sync_events::StrippedState,
2524
events::{
26-
AnySyncStateEvent, AnySyncTimelineEvent, EventContentFromType,
25+
AnyStrippedStateEvent, AnySyncStateEvent, AnySyncTimelineEvent, EventContentFromType,
2726
PossiblyRedactedStateEventContent, RedactContent, RedactedStateEventContent,
2827
StateEventContent, StaticStateEventContent, StrippedStateEvent, SyncStateEvent,
2928
room::{
@@ -262,7 +261,7 @@ pub enum RawAnySyncOrStrippedTimelineEvent {
262261
/// An event from a room in joined or left state.
263262
Sync(Raw<AnySyncTimelineEvent>),
264263
/// An event from a room in invited state.
265-
Stripped(Raw<StrippedState>),
264+
Stripped(Raw<AnyStrippedStateEvent>),
266265
}
267266

268267
impl From<Raw<AnySyncTimelineEvent>> for RawAnySyncOrStrippedTimelineEvent {
@@ -271,8 +270,8 @@ impl From<Raw<AnySyncTimelineEvent>> for RawAnySyncOrStrippedTimelineEvent {
271270
}
272271
}
273272

274-
impl From<Raw<StrippedState>> for RawAnySyncOrStrippedTimelineEvent {
275-
fn from(event: Raw<StrippedState>) -> Self {
273+
impl From<Raw<AnyStrippedStateEvent>> for RawAnySyncOrStrippedTimelineEvent {
274+
fn from(event: Raw<AnyStrippedStateEvent>) -> Self {
276275
Self::Stripped(event)
277276
}
278277
}
@@ -284,7 +283,7 @@ pub enum RawAnySyncOrStrippedState {
284283
/// An event from a room in joined or left state.
285284
Sync(Raw<AnySyncStateEvent>),
286285
/// An event from a room in invited state.
287-
Stripped(Raw<StrippedState>),
286+
Stripped(Raw<AnyStrippedStateEvent>),
288287
}
289288

290289
impl RawAnySyncOrStrippedState {
@@ -324,7 +323,7 @@ pub enum AnySyncOrStrippedState {
324323
///
325324
/// The value is `Box`ed because it is quite large. Let's keep the size of
326325
/// `Self` as small as possible.
327-
Stripped(Box<StrippedState>),
326+
Stripped(Box<AnyStrippedStateEvent>),
328327
}
329328

330329
impl AnySyncOrStrippedState {
@@ -339,7 +338,7 @@ impl AnySyncOrStrippedState {
339338

340339
/// If this is an `AnyStrippedStateEvent`, return a reference to the inner
341340
/// event.
342-
pub fn as_stripped(&self) -> Option<&StrippedState> {
341+
pub fn as_stripped(&self) -> Option<&AnyStrippedStateEvent> {
343342
match self {
344343
Self::Sync(_) => None,
345344
Self::Stripped(ev) => Some(ev),

crates/matrix-sdk-base/src/response_processors/room/msc4186/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use matrix_sdk_common::deserialized_responses::TimelineEvent;
2323
use ruma::{
2424
JsOption, OwnedRoomId, RoomId, UserId,
2525
api::client::sync::sync_events::{
26-
StrippedState,
2726
v3::{InviteState, InvitedRoom, KnockState, KnockedRoom},
2827
v5 as http,
2928
},
@@ -226,7 +225,7 @@ pub async fn update_any_room(
226225
fn membership(
227226
context: &mut Context,
228227
state_events: &[AnySyncStateEvent],
229-
invite_state_events: &Option<(Vec<Raw<StrippedState>>, Vec<AnyStrippedStateEvent>)>,
228+
invite_state_events: &Option<(Vec<Raw<AnyStrippedStateEvent>>, Vec<AnyStrippedStateEvent>)>,
230229
store: &BaseStateStore,
231230
user_id: &UserId,
232231
room_id: &RoomId,

crates/matrix-sdk-base/src/response_processors/state_events.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -206,31 +206,20 @@ pub mod sync {
206206
pub mod stripped {
207207
use std::{collections::BTreeMap, iter};
208208

209-
use ruma::{
210-
api::client::sync::sync_events::StrippedState, events::AnyStrippedStateEvent, push::Action,
211-
};
212-
use tracing::{instrument, warn};
209+
use ruma::{events::AnyStrippedStateEvent, push::Action};
210+
use tracing::instrument;
213211

214212
use super::{
215213
super::{notification, timeline},
216214
Context, Raw,
217215
};
218216
use crate::{Result, Room, RoomInfo};
219217

220-
/// Collect [`Raw<StrippedState>`] to [`AnyStrippedStateEvent`].
218+
/// Collect [`Raw<AnyStrippedStateEvent>`] to [`AnyStrippedStateEvent`].
221219
pub fn collect(
222-
raw_events: &[Raw<StrippedState>],
223-
) -> (Vec<Raw<StrippedState>>, Vec<AnyStrippedStateEvent>) {
224-
raw_events
225-
.iter()
226-
.filter_map(|raw_event| match raw_event.deserialize_as() {
227-
Ok(event) => Some((raw_event.clone(), event)),
228-
Err(e) => {
229-
warn!("Couldn't deserialize stripped state event: {e}");
230-
None
231-
}
232-
})
233-
.unzip()
220+
raw_events: &[Raw<AnyStrippedStateEvent>],
221+
) -> (Vec<Raw<AnyStrippedStateEvent>>, Vec<AnyStrippedStateEvent>) {
222+
super::collect(raw_events)
234223
}
235224

236225
/// Dispatch the stripped state events.
@@ -252,7 +241,7 @@ pub mod stripped {
252241
#[instrument(skip_all, fields(room_id = ?room_info.room_id))]
253242
pub(crate) async fn dispatch_invite_or_knock(
254243
context: &mut Context,
255-
(raw_events, events): (&[Raw<StrippedState>], &[AnyStrippedStateEvent]),
244+
(raw_events, events): (&[Raw<AnyStrippedStateEvent>], &[AnyStrippedStateEvent]),
256245
room: &Room,
257246
room_info: &mut RoomInfo,
258247
mut notification: notification::Notification<'_>,

crates/matrix-sdk-base/src/store/integration_tests.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@ use ruma::{
1010
EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedUserId, RoomId, TransactionId, UserId,
1111
api::{
1212
FeatureFlag, MatrixVersion,
13-
client::{
14-
discovery::discover_homeserver::{HomeserverInfo, RtcFocusInfo},
15-
sync::sync_events::StrippedState,
16-
},
13+
client::discovery::discover_homeserver::{HomeserverInfo, RtcFocusInfo},
1714
},
1815
event_id,
1916
events::{
2017
AnyGlobalAccountDataEvent, AnyMessageLikeEventContent, AnyRoomAccountDataEvent,
21-
AnySyncStateEvent, GlobalAccountDataEventType, RoomAccountDataEventType, StateEventType,
22-
SyncStateEvent,
18+
AnyStrippedStateEvent, AnySyncStateEvent, GlobalAccountDataEventType,
19+
RoomAccountDataEventType, StateEventType, SyncStateEvent,
2320
presence::PresenceEvent,
2421
receipt::{ReceiptThread, ReceiptType},
2522
room::{
@@ -193,8 +190,8 @@ impl StateStoreIntegrationTests for DynStateStore {
193190

194191
let stripped_name_json: &JsonValue = &test_json::NAME_STRIPPED;
195192
let stripped_name_raw =
196-
serde_json::from_value::<Raw<StrippedState>>(stripped_name_json.clone())?;
197-
let stripped_name_event = stripped_name_raw.deserialize_as()?;
193+
serde_json::from_value::<Raw<AnyStrippedStateEvent>>(stripped_name_json.clone())?;
194+
let stripped_name_event = stripped_name_raw.deserialize()?;
198195
stripped_room.handle_stripped_state_event(&stripped_name_event);
199196
changes.stripped_state.insert(
200197
stripped_room_id.to_owned(),

crates/matrix-sdk-base/src/store/memory_store.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ use matrix_sdk_common::{ROOM_VERSION_FALLBACK, ROOM_VERSION_RULES_FALLBACK};
2323
use ruma::{
2424
CanonicalJsonObject, EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedMxcUri,
2525
OwnedRoomId, OwnedTransactionId, OwnedUserId, RoomId, TransactionId, UserId,
26-
api::client::sync::sync_events::StrippedState,
2726
canonical_json::{RedactedBecause, redact},
2827
events::{
29-
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnySyncStateEvent,
30-
GlobalAccountDataEventType, RoomAccountDataEventType, StateEventType,
28+
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnyStrippedStateEvent,
29+
AnySyncStateEvent, GlobalAccountDataEventType, RoomAccountDataEventType, StateEventType,
3130
presence::PresenceEvent,
3231
receipt::{Receipt, ReceiptThread, ReceiptType},
3332
room::member::{MembershipState, StrippedRoomMemberEvent, SyncRoomMemberEvent},
@@ -69,7 +68,7 @@ struct MemoryStoreInner {
6968
room_account_data:
7069
HashMap<OwnedRoomId, HashMap<RoomAccountDataEventType, Raw<AnyRoomAccountDataEvent>>>,
7170
stripped_room_state:
72-
HashMap<OwnedRoomId, HashMap<StateEventType, HashMap<String, Raw<StrippedState>>>>,
71+
HashMap<OwnedRoomId, HashMap<StateEventType, HashMap<String, Raw<AnyStrippedStateEvent>>>>,
7372
stripped_members: HashMap<OwnedRoomId, HashMap<OwnedUserId, MembershipState>>,
7473
presence: HashMap<OwnedUserId, Raw<PresenceEvent>>,
7574
room_user_receipts: HashMap<

crates/matrix-sdk-base/src/store/mod.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,11 @@ pub use matrix_sdk_store_encryption::Error as StoreEncryptionError;
4747
use observable_map::ObservableMap;
4848
use ruma::{
4949
EventId, OwnedEventId, OwnedRoomId, OwnedUserId, RoomId, UserId,
50-
api::client::sync::sync_events::StrippedState,
5150
events::{
52-
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnySyncStateEvent, EmptyStateKey,
53-
GlobalAccountDataEventType, RedactContent, RedactedStateEventContent,
54-
RoomAccountDataEventType, StateEventType, StaticEventContent, StaticStateEventContent,
55-
StrippedStateEvent, SyncStateEvent,
51+
AnyGlobalAccountDataEvent, AnyRoomAccountDataEvent, AnyStrippedStateEvent,
52+
AnySyncStateEvent, EmptyStateKey, GlobalAccountDataEventType, RedactContent,
53+
RedactedStateEventContent, RoomAccountDataEventType, StateEventType, StaticEventContent,
54+
StaticStateEventContent, StrippedStateEvent, SyncStateEvent,
5655
presence::PresenceEvent,
5756
receipt::ReceiptEventContent,
5857
room::{
@@ -517,8 +516,10 @@ pub struct StateChanges {
517516

518517
/// A mapping of `RoomId` to a map of event type to a map of state key to
519518
/// `StrippedState`.
520-
pub stripped_state:
521-
BTreeMap<OwnedRoomId, BTreeMap<StateEventType, BTreeMap<String, Raw<StrippedState>>>>,
519+
pub stripped_state: BTreeMap<
520+
OwnedRoomId,
521+
BTreeMap<StateEventType, BTreeMap<String, Raw<AnyStrippedStateEvent>>>,
522+
>,
522523

523524
/// A map from room id to a map of a display name and a set of user ids that
524525
/// share that display name in the given room.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async fn test_notification() -> Result<()> {
7070
};
7171

7272
if let Some(event_id) = invited_room.invite_state.events.iter().find_map(|event| {
73-
let Ok(AnyStrippedStateEvent::RoomMember(room_member_ev)) = event.deserialize_as() else {
73+
let Ok(AnyStrippedStateEvent::RoomMember(room_member_ev)) = event.deserialize() else {
7474
return None;
7575
};
7676

testing/matrix-sdk-test/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ macro_rules! stripped_state_event {
6868
($( $tt:tt )*) => {
6969
::ruma::serde::Raw::new(&::serde_json::json!( $($tt)* ))
7070
.unwrap()
71-
.cast_unchecked::<::ruma::api::client::sync::sync_events::StrippedState>()
71+
.cast_unchecked::<::ruma::events::AnyStrippedStateEvent>()
7272
}
7373
}
7474

0 commit comments

Comments
 (0)