Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "a3663c04511f79f99376924d739f84d839600de6", features = [
ruma = { git = "https://github.com/ruma/ruma", rev = "7bae3d0c0b8edf008899ac2b04cf9722182eef68", features = [
"client-api-c",
"compat-upload-signatures",
"compat-arbitrary-length-ids",
Expand All @@ -77,7 +77,7 @@ ruma = { git = "https://github.com/ruma/ruma", rev = "a3663c04511f79f99376924d73
"unstable-msc4278",
"unstable-msc4286",
] }
ruma-common = { git = "https://github.com/ruma/ruma", rev = "a3663c04511f79f99376924d739f84d839600de6" }
ruma-common = { git = "https://github.com/ruma/ruma", rev = "7bae3d0c0b8edf008899ac2b04cf9722182eef68" }
sentry = "0.36.0"
sentry-tracing = "0.36.0"
serde = { version = "1.0.217", features = ["rc"] }
Expand Down
4 changes: 2 additions & 2 deletions bindings/matrix-sdk-ffi/src/notification_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl TryFrom<SdkPushCondition> for PushCondition {
Self::RoomMemberCount { prefix: is.prefix.into(), count: is.count.into() }
}
SdkPushCondition::SenderNotificationPermission { key } => {
Self::SenderNotificationPermission { key }
Self::SenderNotificationPermission { key: key.to_string() }
}
SdkPushCondition::EventPropertyIs { key, value } => {
Self::EventPropertyIs { key, value: value.into() }
Expand All @@ -197,7 +197,7 @@ impl From<PushCondition> for SdkPushCondition {
},
},
PushCondition::SenderNotificationPermission { key } => {
Self::SenderNotificationPermission { key }
Self::SenderNotificationPermission { key: key.into() }
}
PushCondition::EventPropertyIs { key, value } => {
Self::EventPropertyIs { key, value: value.into() }
Expand Down
2 changes: 1 addition & 1 deletion crates/matrix-sdk-base/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ impl BaseClient {
) -> Result<Ruleset> {
if let Some(event) = global_account_data_processor
.push_rules()
.and_then(|ev| ev.deserialize_as::<PushRulesEvent>().ok())
.and_then(|ev| ev.deserialize_as_unchecked::<PushRulesEvent>().ok())
{
Ok(event.content.global)
} else if let Some(event) = self
Expand Down
4 changes: 2 additions & 2 deletions crates/matrix-sdk-base/src/deserialized_responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ impl RawAnySyncOrStrippedState {
C::Redacted: RedactedStateEventContent,
{
match self {
Self::Sync(raw) => RawSyncOrStrippedState::Sync(raw.cast()),
Self::Stripped(raw) => RawSyncOrStrippedState::Stripped(raw.cast()),
Self::Sync(raw) => RawSyncOrStrippedState::Sync(raw.cast_unchecked()),
Self::Stripped(raw) => RawSyncOrStrippedState::Stripped(raw.cast_unchecked()),
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions crates/matrix-sdk-base/src/latest_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ mod tests {
AnySyncMessageLikeEvent, AnySyncStateEvent, AnySyncTimelineEvent, EmptyStateKey,
Mentions, MessageLikeUnsigned, OriginalSyncMessageLikeEvent, OriginalSyncStateEvent,
RedactedSyncMessageLikeEvent, RedactedUnsigned, StateUnsigned, SyncMessageLikeEvent,
UnsignedRoomRedactionEvent,
},
owned_event_id, owned_mxc_uri, owned_user_id, MilliSecondsSinceUnixEpoch, UInt,
VoipVersionId,
Expand Down Expand Up @@ -501,7 +500,7 @@ mod tests {
#[test]
fn test_redacted_messages_are_suitable() {
// Ruma does not allow constructing UnsignedRoomRedactionEvent instances.
let room_redaction_event: UnsignedRoomRedactionEvent = serde_json::from_value(json!({
let room_redaction_event = serde_json::from_value(json!({
"content": {},
"event_id": "$redaction",
"sender": "@x:y.za",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn apply_changes(
if let Some(event) =
context.state_changes.account_data.get(&GlobalAccountDataEventType::IgnoredUserList)
{
match event.deserialize_as::<IgnoredUserListEvent>() {
match event.deserialize_as_unchecked::<IgnoredUserListEvent>() {
Ok(event) => {
let user_ids: Vec<String> =
event.content.ignored_users.keys().map(|id| id.to_string()).collect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub async fn sync_timeline_event(

Ok(Some(
match olm
.try_decrypt_room_event(event.cast_ref(), room_id, e2ee.decryption_settings)
.try_decrypt_room_event(event.cast_ref_unchecked(), room_id, e2ee.decryption_settings)
.await?
{
RoomEventDecryptionResult::Decrypted(decrypted) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async fn decrypt_sync_room_event(
let event = match e2ee
.olm_machine
.expect("An `OlmMachine` is expected")
.try_decrypt_room_event(event.cast_ref(), room_id, e2ee.decryption_settings)
.try_decrypt_room_event(event.cast_ref_unchecked(), room_id, e2ee.decryption_settings)
.await?
{
RoomEventDecryptionResult::Decrypted(decrypted) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub mod sync {
super::collect(raw_events.iter().filter_map(|raw_event| {
// Only state events have a `state_key` field.
match raw_event.get_field::<&str>("state_key") {
Ok(Some(_)) => Some(raw_event.cast_ref()),
Ok(Some(_)) => Some(raw_event.cast_ref_unchecked()),
_ => None,
}
}))
Expand Down
8 changes: 5 additions & 3 deletions crates/matrix-sdk-base/src/response_processors/timeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ pub async fn build<'notification, 'e2ee>(
let redaction_rules = room_info.room_version_rules_or_default().redaction;

if let Some(redacts) = redaction_event.redacts(&redaction_rules) {
room_info
.handle_redaction(redaction_event, timeline_event.raw().cast_ref());
room_info.handle_redaction(
redaction_event,
timeline_event.raw().cast_ref_unchecked(),
);

context.state_changes.add_redaction(
room_id,
redacts,
timeline_event.raw().clone().cast(),
timeline_event.raw().clone().cast_unchecked(),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/matrix-sdk-base/src/room/display_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ mod tests {
"state_key": user_id,
});

Raw::new(&ev_json).unwrap().cast()
Raw::new(&ev_json).unwrap().cast_unchecked()
}

fn make_canonical_alias_event() -> MinimalStateEvent<RoomCanonicalAliasEventContent> {
Expand Down
6 changes: 3 additions & 3 deletions crates/matrix-sdk-base/src/room/room_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ pub fn apply_redaction(
}

let raw = Raw::new(&event_json).expect("CanonicalJsonObject must be serializable");
Some(raw.cast())
Some(raw.cast_unchecked())
}

/// Indicates that a notable update of `RoomInfo` has been applied, and why.
Expand Down Expand Up @@ -1412,11 +1412,11 @@ mod tests {
// Add events to the store.
let mut changes = StateChanges::default();

let raw_tag_event = Raw::new(&*TAG).unwrap().cast();
let raw_tag_event = Raw::new(&*TAG).unwrap().cast_unchecked();
let tag_event = raw_tag_event.deserialize().unwrap();
changes.add_room_account_data(&room_info.room_id, tag_event, raw_tag_event);

let raw_pinned_events_event = Raw::new(&*PINNED_EVENTS).unwrap().cast();
let raw_pinned_events_event = Raw::new(&*PINNED_EVENTS).unwrap().cast_unchecked();
let pinned_events_event = raw_pinned_events_event.deserialize().unwrap();
changes.add_state_event(&room_info.room_id, pinned_events_event, raw_pinned_events_event);

Expand Down
8 changes: 4 additions & 4 deletions crates/matrix-sdk-base/src/room/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ mod tests {
"type": "m.tag",
}))
.unwrap()
.cast();
.cast_unchecked();

// When the new tag is handled and applied.
let mut context = processors::Context::default();
Expand Down Expand Up @@ -164,7 +164,7 @@ mod tests {
"type": "m.tag"
}))
.unwrap()
.cast();
.cast_unchecked();

processors::account_data::for_room(&mut context, room_id, &[tag_raw], &client.state_store)
.await;
Expand Down Expand Up @@ -230,7 +230,7 @@ mod tests {
"type": "m.tag"
}))
.unwrap()
.cast();
.cast_unchecked();

// When the new tag is handled and applied.
let mut context = processors::Context::default();
Expand Down Expand Up @@ -262,7 +262,7 @@ mod tests {
"type": "m.tag"
}))
.unwrap()
.cast();
.cast_unchecked();

processors::account_data::for_room(&mut context, room_id, &[tag_raw], &client.state_store)
.await;
Expand Down
14 changes: 7 additions & 7 deletions crates/matrix-sdk-base/src/sliding_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ mod tests {
"state_key": user_id,
}))
.expect("Failed to make raw event")
.cast();
.cast_unchecked();
room.invite_state = Some(vec![event]);

let response = response_with_room(room_id, room);
Expand Down Expand Up @@ -1327,7 +1327,7 @@ mod tests {
// When the sliding sync response contains a timeline
let events = &[knock_event];
let mut room = room_with_timeline(events);
room.required_state.push(Raw::new(&power_levels).unwrap().cast());
room.required_state.push(Raw::new(&power_levels).unwrap().cast_unchecked());
let response = response_with_room(room_id, room);
client
.process_sliding_sync(&response, &RequestedRequiredStates::default())
Expand Down Expand Up @@ -1375,7 +1375,7 @@ mod tests {
// When the sliding sync response contains a timeline
let events = &[knock_event];
let mut room = room_with_timeline(events);
room.required_state.push(Raw::new(&power_levels).unwrap().cast());
room.required_state.push(Raw::new(&power_levels).unwrap().cast_unchecked());
let response = response_with_room(room_id, room);
client
.process_sliding_sync(&response, &RequestedRequiredStates::default())
Expand Down Expand Up @@ -2708,7 +2708,7 @@ mod tests {
"state_key": invitee,
}))
.expect("Failed to make raw event")
.cast();
.cast_unchecked();

room.invite_state = Some(vec![evt]);

Expand Down Expand Up @@ -2736,7 +2736,7 @@ mod tests {
"state_key": knocker,
}))
.expect("Failed to make raw event")
.cast();
.cast_unchecked();

room.invite_state = Some(vec![evt]);
}
Expand Down Expand Up @@ -2771,7 +2771,7 @@ mod tests {
"content": content,
}))
.expect("Failed to create account data event")
.cast()
.cast_unchecked()
}

fn make_state_event<C: StateEventContent, E>(
Expand All @@ -2796,6 +2796,6 @@ mod tests {
"unsigned": unsigned,
}))
.expect("Failed to create state event")
.cast()
.cast_unchecked()
}
}
9 changes: 5 additions & 4 deletions crates/matrix-sdk-base/src/store/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ impl StateStoreIntegrationTests for DynStateStore {
changes.add_room(stripped_room);

let stripped_member_json: &JsonValue = &test_json::MEMBER_STRIPPED;
let stripped_member_event = Raw::new(&stripped_member_json.clone()).unwrap().cast();
let stripped_member_event =
Raw::new(&stripped_member_json.clone()).unwrap().cast_unchecked();
changes.add_stripped_member(stripped_room_id, user_id, stripped_member_event);

self.save_changes(&changes).await?;
Expand Down Expand Up @@ -1969,7 +1970,7 @@ fn custom_stripped_membership_event(user_id: &UserId) -> Raw<StrippedRoomMemberE
"state_key": user_id,
});

Raw::new(&ev_json).unwrap().cast()
Raw::new(&ev_json).unwrap().cast_unchecked()
}

fn membership_event() -> Raw<SyncRoomMemberEvent> {
Expand All @@ -1986,7 +1987,7 @@ fn custom_membership_event(user_id: &UserId, event_id: &EventId) -> Raw<SyncRoom
"state_key": user_id,
});

Raw::new(&ev_json).unwrap().cast()
Raw::new(&ev_json).unwrap().cast_unchecked()
}

fn custom_presence_event(user_id: &UserId) -> Raw<PresenceEvent> {
Expand All @@ -1997,5 +1998,5 @@ fn custom_presence_event(user_id: &UserId) -> Raw<PresenceEvent> {
"sender": user_id,
});

Raw::new(&ev_json).unwrap().cast()
Raw::new(&ev_json).unwrap().cast_unchecked()
}
Loading
Loading