Skip to content

Commit

Permalink
MatrixRTC: bump ruma to be compatible with MSC4143.
Browse files Browse the repository at this point in the history
Adapt types for the new ruma version.
  • Loading branch information
toger5 authored and bnjbvr committed Jun 17, 2024
1 parent b34a2cd commit cb7814b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 28 deletions.
18 changes: 9 additions & 9 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 @@ -44,7 +44,7 @@ once_cell = "1.16.0"
pin-project-lite = "0.2.9"
rand = "0.8.5"
reqwest = { version = "0.12.4", default-features = false }
ruma = { git = "https://github.com/ruma/ruma", rev = "75e8829bec0b7bc5332860e1fb2df658d5c71d66", features = [
ruma = { git = "https://github.com/ruma/ruma", rev = "c21817436979acbe66d43064498920a6d289b562", features = [
"client-api-c",
"compat-upload-signatures",
"compat-user-id",
Expand All @@ -55,7 +55,7 @@ ruma = { git = "https://github.com/ruma/ruma", rev = "75e8829bec0b7bc5332860e1fb
"unstable-msc3266",
"unstable-msc4075"
] }
ruma-common = { git = "https://github.com/ruma/ruma", rev = "75e8829bec0b7bc5332860e1fb2df658d5c71d66" }
ruma-common = { git = "https://github.com/ruma/ruma", rev = "c21817436979acbe66d43064498920a6d289b562" }
serde = "1.0.151"
serde_html_form = "0.2.0"
serde_json = "1.0.91"
Expand Down
2 changes: 1 addition & 1 deletion bindings/matrix-sdk-ffi/src/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl Room {

/// Returns a Vec of userId's that participate in the room call.
///
/// matrix_rtc memberships with application "m.call" and scope "m.room" are
/// MatrixRTC memberships with application "m.call" and scope "m.room" are
/// considered. A user can occur twice if they join with two devices.
/// convert to a set depending if the different users are required or the
/// amount of sessions.
Expand Down
23 changes: 12 additions & 11 deletions crates/matrix-sdk-base/src/rooms/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use ruma::events::AnySyncTimelineEvent;
use ruma::{
api::client::sync::sync_events::v3::RoomSummary as RumaSummary,
events::{
call::member::Membership,
call::member::MembershipData,
ignored_user_list::IgnoredUserListEventContent,
receipt::{Receipt, ReceiptThread, ReceiptType},
room::{
Expand Down Expand Up @@ -462,7 +462,7 @@ impl Room {

/// Returns a Vec of userId's that participate in the room call.
///
/// matrix_rtc memberships with application "m.call" and scope "m.room" are
/// MatrixRTC memberships with application "m.call" and scope "m.room" are
/// considered. A user can occur twice if they join with two devices.
/// convert to a set depending if the different users are required or the
/// amount of sessions.
Expand Down Expand Up @@ -1289,7 +1289,7 @@ impl RoomInfo {
/// associated UserId's in this room.
///
/// The vector is ordered by oldest membership to newest.
fn active_matrix_rtc_memberships(&self) -> Vec<(OwnedUserId, &Membership)> {
fn active_matrix_rtc_memberships(&self) -> Vec<(OwnedUserId, MembershipData<'_>)> {
let mut v = self
.base_info
.rtc_member
Expand All @@ -1304,7 +1304,7 @@ impl RoomInfo {
})
.flatten()
.collect::<Vec<_>>();
v.sort_by_key(|(_, m)| m.created_ts);
v.sort_by_key(|(_, m)| m.created_ts());
v
}

Expand All @@ -1313,7 +1313,7 @@ impl RoomInfo {
/// returns Memberships with application "m.call" and scope "m.room".
///
/// The vector is ordered by oldest membership user to newest.
fn active_room_call_memberships(&self) -> Vec<(OwnedUserId, &Membership)> {
fn active_room_call_memberships(&self) -> Vec<(OwnedUserId, MembershipData<'_>)> {
self.active_matrix_rtc_memberships()
.into_iter()
.filter(|(_user_id, m)| m.is_room_call())
Expand Down Expand Up @@ -1485,8 +1485,9 @@ mod tests {
api::client::sync::sync_events::v3::RoomSummary as RumaSummary,
events::{
call::member::{
Application, CallApplicationContent, CallMemberEventContent, Focus, LivekitFocus,
Membership, MembershipInit, OriginalSyncCallMemberEvent,
Application, CallApplicationContent, CallMemberEventContent, Focus,
LegacyMembershipData, LegacyMembershipDataInit, LivekitFocus,
OriginalSyncCallMemberEvent,
},
room::{
canonical_alias::RoomCanonicalAliasEventContent,
Expand Down Expand Up @@ -2341,11 +2342,11 @@ mod tests {
}

fn call_member_state_event(
memberships: Vec<Membership>,
memberships: Vec<LegacyMembershipData>,
ev_id: &str,
user_id: &UserId,
) -> AnySyncStateEvent {
let content = CallMemberEventContent::new(memberships);
let content = CallMemberEventContent::new_legacy(memberships);

AnySyncStateEvent::CallMember(SyncStateEvent::Original(OriginalSyncCallMemberEvent {
content,
Expand All @@ -2363,7 +2364,7 @@ mod tests {
device_id: &str,
membership_id: &str,
minutes_ago: u32,
) -> Membership {
) -> LegacyMembershipData {
let application = Application::Call(CallApplicationContent::new(
"my_call_id_1".to_owned(),
ruma::events::call::member::CallScope::Room,
Expand All @@ -2374,7 +2375,7 @@ mod tests {
))];

assign!(
Membership::from(MembershipInit {
LegacyMembershipData::from(LegacyMembershipDataInit {
application,
device_id: device_id.to_owned(),
expires: Duration::from_millis(3_600_000),
Expand Down
8 changes: 3 additions & 5 deletions crates/matrix-sdk-base/src/sliding_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ fn process_room_properties(room_data: &v4::SlidingSyncRoom, room_info: &mut Room
if let Some(heroes) = &room_data.heroes {
// Filter out all the heroes which don't have a user id or name.
room_info.update_heroes(
heroes.iter().filter_map(|hero| hero.user_id.as_ref()).cloned().collect(),
heroes.iter().map(|hero| &hero.user_id).cloned().collect(),
heroes.iter().filter_map(|hero| hero.name.as_ref()).cloned().collect(),
);
}
Expand Down Expand Up @@ -1351,12 +1351,10 @@ mod tests {
// in `heroes`)
let mut room = v4::SlidingSyncRoom::new();
room.heroes = Some(vec![
assign!(v4::SlidingSyncRoomHero::default(), {
user_id: Some(gordon),
assign!(v4::SlidingSyncRoomHero::new(gordon), {
name: Some("Gordon".to_owned()),
}),
assign!(v4::SlidingSyncRoomHero::default(), {
user_id: Some(alice),
assign!(v4::SlidingSyncRoomHero::new(alice), {
name: Some("Alice".to_owned()),
}),
]);
Expand Down

0 comments on commit cb7814b

Please sign in to comment.