MatrixRTC: fix call member parsing by using the correct focus_active
format. (#1888)
`focus_select` -> `focus_selection`
This commit is contained in:
parent
82417e3940
commit
642c981f99
@ -72,6 +72,7 @@ impl CallMemberEventContent {
|
|||||||
pub fn new_empty(leave_reason: Option<LeaveReason>) -> Self {
|
pub fn new_empty(leave_reason: Option<LeaveReason>) -> Self {
|
||||||
Self::Empty(EmptyMembershipData { leave_reason })
|
Self::Empty(EmptyMembershipData { leave_reason })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// All non expired memberships in this member event.
|
/// All non expired memberships in this member event.
|
||||||
///
|
///
|
||||||
/// In most cases you want to use this method instead of the public memberships field.
|
/// In most cases you want to use this method instead of the public memberships field.
|
||||||
@ -268,7 +269,7 @@ mod tests {
|
|||||||
}),
|
}),
|
||||||
"ABCDE".to_owned(),
|
"ABCDE".to_owned(),
|
||||||
ActiveFocus::Livekit(ActiveLivekitFocus {
|
ActiveFocus::Livekit(ActiveLivekitFocus {
|
||||||
focus_select: FocusSelection::OldestMembership,
|
focus_selection: FocusSelection::OldestMembership,
|
||||||
}),
|
}),
|
||||||
vec![Focus::Livekit(LivekitFocus {
|
vec![Focus::Livekit(LivekitFocus {
|
||||||
alias: "1".to_owned(),
|
alias: "1".to_owned(),
|
||||||
@ -294,7 +295,7 @@ mod tests {
|
|||||||
],
|
],
|
||||||
"focus_active":{
|
"focus_active":{
|
||||||
"type":"livekit",
|
"type":"livekit",
|
||||||
"focus_select":"oldest_membership"
|
"focus_selection":"oldest_membership"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -348,7 +349,7 @@ mod tests {
|
|||||||
}),
|
}),
|
||||||
"THIS_DEVICE".to_owned(),
|
"THIS_DEVICE".to_owned(),
|
||||||
ActiveFocus::Livekit(ActiveLivekitFocus {
|
ActiveFocus::Livekit(ActiveLivekitFocus {
|
||||||
focus_select: FocusSelection::OldestMembership,
|
focus_selection: FocusSelection::OldestMembership,
|
||||||
}),
|
}),
|
||||||
vec![Focus::Livekit(LivekitFocus {
|
vec![Focus::Livekit(LivekitFocus {
|
||||||
alias: "room1".to_owned(),
|
alias: "room1".to_owned(),
|
||||||
@ -364,7 +365,7 @@ mod tests {
|
|||||||
"device_id": "THIS_DEVICE",
|
"device_id": "THIS_DEVICE",
|
||||||
"focus_active":{
|
"focus_active":{
|
||||||
"type": "livekit",
|
"type": "livekit",
|
||||||
"focus_select": "oldest_membership"
|
"focus_selection": "oldest_membership"
|
||||||
},
|
},
|
||||||
"foci_preferred": [
|
"foci_preferred": [
|
||||||
{
|
{
|
||||||
@ -473,7 +474,7 @@ mod tests {
|
|||||||
"device_id": "THIS_DEVICE",
|
"device_id": "THIS_DEVICE",
|
||||||
"focus_active":{
|
"focus_active":{
|
||||||
"type": "livekit",
|
"type": "livekit",
|
||||||
"focus_select": "oldest_membership"
|
"focus_selection": "oldest_membership"
|
||||||
},
|
},
|
||||||
"foci_preferred": [
|
"foci_preferred": [
|
||||||
{
|
{
|
||||||
@ -509,26 +510,32 @@ mod tests {
|
|||||||
assert_eq!(member_event.sender, sender);
|
assert_eq!(member_event.sender, sender);
|
||||||
assert_eq!(member_event.room_id, room_id);
|
assert_eq!(member_event.room_id, room_id);
|
||||||
assert_eq!(member_event.origin_server_ts, TS(js_int::UInt::new(111).unwrap()));
|
assert_eq!(member_event.origin_server_ts, TS(js_int::UInt::new(111).unwrap()));
|
||||||
|
let membership = SessionMembershipData {
|
||||||
|
application: Application::Call(CallApplicationContent {
|
||||||
|
call_id: "".to_owned(),
|
||||||
|
scope: CallScope::Room,
|
||||||
|
}),
|
||||||
|
device_id: "THIS_DEVICE".to_owned(),
|
||||||
|
foci_preferred: [Focus::Livekit(LivekitFocus {
|
||||||
|
alias: "room1".to_owned(),
|
||||||
|
service_url: "https://livekit1.com".to_owned(),
|
||||||
|
})]
|
||||||
|
.to_vec(),
|
||||||
|
focus_active: ActiveFocus::Livekit(ActiveLivekitFocus {
|
||||||
|
focus_selection: FocusSelection::OldestMembership,
|
||||||
|
}),
|
||||||
|
created_ts: None,
|
||||||
|
};
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
member_event.content,
|
member_event.content,
|
||||||
CallMemberEventContent::SessionContent(SessionMembershipData {
|
CallMemberEventContent::SessionContent(membership.clone())
|
||||||
application: Application::Call(CallApplicationContent {
|
|
||||||
call_id: "".to_owned(),
|
|
||||||
scope: CallScope::Room
|
|
||||||
}),
|
|
||||||
device_id: "THIS_DEVICE".to_owned(),
|
|
||||||
foci_preferred: [Focus::Livekit(LivekitFocus {
|
|
||||||
alias: "room1".to_owned(),
|
|
||||||
service_url: "https://livekit1.com".to_owned()
|
|
||||||
})]
|
|
||||||
.to_vec(),
|
|
||||||
focus_active: ActiveFocus::Livekit(ActiveLivekitFocus {
|
|
||||||
focus_select: FocusSelection::OldestMembership
|
|
||||||
}),
|
|
||||||
created_ts: None
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Correctly computes the active_memberships array.
|
||||||
|
assert_eq!(
|
||||||
|
member_event.content.active_memberships(None)[0],
|
||||||
|
vec![MembershipData::Session(&membership)][0]
|
||||||
|
);
|
||||||
assert_eq!(js_int::Int::new(10), member_event.unsigned.age);
|
assert_eq!(js_int::Int::new(10), member_event.unsigned.age);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
CallMemberEventContent::Empty(EmptyMembershipData { leave_reason: None }),
|
CallMemberEventContent::Empty(EmptyMembershipData { leave_reason: None }),
|
||||||
@ -568,7 +575,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn memberships_do_expire() {
|
fn legacy_memberships_do_expire() {
|
||||||
let content_legacy = create_call_member_legacy_event_content();
|
let content_legacy = create_call_member_legacy_event_content();
|
||||||
let (now, one_second_ago, two_hours_ago) = timestamps();
|
let (now, one_second_ago, two_hours_ago) = timestamps();
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ pub enum ActiveFocus {
|
|||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
pub struct ActiveLivekitFocus {
|
pub struct ActiveLivekitFocus {
|
||||||
/// The selection method used to select the LiveKit focus for the rtc session.
|
/// The selection method used to select the LiveKit focus for the rtc session.
|
||||||
pub focus_select: FocusSelection,
|
pub focus_selection: FocusSelection,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ActiveLivekitFocus {
|
impl ActiveLivekitFocus {
|
||||||
@ -67,10 +67,10 @@ impl ActiveLivekitFocus {
|
|||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// * `focus_select` - The selection method used to select the LiveKit focus for the rtc
|
/// * `focus_selection` - The selection method used to select the LiveKit focus for the rtc
|
||||||
/// session.
|
/// session.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self { focus_select: FocusSelection::OldestMembership }
|
Self { focus_selection: FocusSelection::OldestMembership }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ impl<'a> MembershipData<'a> {
|
|||||||
pub fn focus_active(&self) -> &ActiveFocus {
|
pub fn focus_active(&self) -> &ActiveFocus {
|
||||||
match self {
|
match self {
|
||||||
MembershipData::Legacy(_) => &ActiveFocus::Livekit(ActiveLivekitFocus {
|
MembershipData::Legacy(_) => &ActiveFocus::Livekit(ActiveLivekitFocus {
|
||||||
focus_select: super::focus::FocusSelection::OldestMembership,
|
focus_selection: super::focus::FocusSelection::OldestMembership,
|
||||||
}),
|
}),
|
||||||
MembershipData::Session(data) => &data.focus_active,
|
MembershipData::Session(data) => &data.focus_active,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user