@@ -72,6 +72,7 @@ impl CallMemberEventContent {
72
72
pub fn new_empty ( leave_reason : Option < LeaveReason > ) -> Self {
73
73
Self :: Empty ( EmptyMembershipData { leave_reason } )
74
74
}
75
+
75
76
/// All non expired memberships in this member event.
76
77
///
77
78
/// In most cases you want to use this method instead of the public memberships field.
@@ -268,7 +269,7 @@ mod tests {
268
269
} ) ,
269
270
"ABCDE" . to_owned ( ) ,
270
271
ActiveFocus :: Livekit ( ActiveLivekitFocus {
271
- focus_select : FocusSelection :: OldestMembership ,
272
+ focus_selection : FocusSelection :: OldestMembership ,
272
273
} ) ,
273
274
vec ! [ Focus :: Livekit ( LivekitFocus {
274
275
alias: "1" . to_owned( ) ,
@@ -294,7 +295,7 @@ mod tests {
294
295
] ,
295
296
"focus_active" : {
296
297
"type" : "livekit" ,
297
- "focus_select " : "oldest_membership"
298
+ "focus_selection " : "oldest_membership"
298
299
}
299
300
} ) ;
300
301
assert_eq ! (
@@ -348,7 +349,7 @@ mod tests {
348
349
} ) ,
349
350
"THIS_DEVICE" . to_owned ( ) ,
350
351
ActiveFocus :: Livekit ( ActiveLivekitFocus {
351
- focus_select : FocusSelection :: OldestMembership ,
352
+ focus_selection : FocusSelection :: OldestMembership ,
352
353
} ) ,
353
354
vec ! [ Focus :: Livekit ( LivekitFocus {
354
355
alias: "room1" . to_owned( ) ,
@@ -364,7 +365,7 @@ mod tests {
364
365
"device_id" : "THIS_DEVICE" ,
365
366
"focus_active" : {
366
367
"type" : "livekit" ,
367
- "focus_select " : "oldest_membership"
368
+ "focus_selection " : "oldest_membership"
368
369
} ,
369
370
"foci_preferred" : [
370
371
{
@@ -473,7 +474,7 @@ mod tests {
473
474
"device_id" : "THIS_DEVICE" ,
474
475
"focus_active" : {
475
476
"type" : "livekit" ,
476
- "focus_select " : "oldest_membership"
477
+ "focus_selection " : "oldest_membership"
477
478
} ,
478
479
"foci_preferred" : [
479
480
{
@@ -509,26 +510,32 @@ mod tests {
509
510
assert_eq ! ( member_event. sender, sender) ;
510
511
assert_eq ! ( member_event. room_id, room_id) ;
511
512
assert_eq ! ( member_event. origin_server_ts, TS ( js_int:: UInt :: new( 111 ) . unwrap( ) ) ) ;
513
+ let membership = SessionMembershipData {
514
+ application : Application :: Call ( CallApplicationContent {
515
+ call_id : "" . to_owned ( ) ,
516
+ scope : CallScope :: Room ,
517
+ } ) ,
518
+ device_id : "THIS_DEVICE" . to_owned ( ) ,
519
+ foci_preferred : [ Focus :: Livekit ( LivekitFocus {
520
+ alias : "room1" . to_owned ( ) ,
521
+ service_url : "https://livekit1.com" . to_owned ( ) ,
522
+ } ) ]
523
+ . to_vec ( ) ,
524
+ focus_active : ActiveFocus :: Livekit ( ActiveLivekitFocus {
525
+ focus_selection : FocusSelection :: OldestMembership ,
526
+ } ) ,
527
+ created_ts : None ,
528
+ } ;
512
529
assert_eq ! (
513
530
member_event. content,
514
- CallMemberEventContent :: SessionContent ( SessionMembershipData {
515
- application: Application :: Call ( CallApplicationContent {
516
- call_id: "" . to_owned( ) ,
517
- scope: CallScope :: Room
518
- } ) ,
519
- device_id: "THIS_DEVICE" . to_owned( ) ,
520
- foci_preferred: [ Focus :: Livekit ( LivekitFocus {
521
- alias: "room1" . to_owned( ) ,
522
- service_url: "https://livekit1.com" . to_owned( )
523
- } ) ]
524
- . to_vec( ) ,
525
- focus_active: ActiveFocus :: Livekit ( ActiveLivekitFocus {
526
- focus_select: FocusSelection :: OldestMembership
527
- } ) ,
528
- created_ts: None
529
- } )
531
+ CallMemberEventContent :: SessionContent ( membership. clone( ) )
530
532
) ;
531
533
534
+ // Correctly computes the active_memberships array.
535
+ assert_eq ! (
536
+ member_event. content. active_memberships( None ) [ 0 ] ,
537
+ vec![ MembershipData :: Session ( & membership) ] [ 0 ]
538
+ ) ;
532
539
assert_eq ! ( js_int:: Int :: new( 10 ) , member_event. unsigned. age) ;
533
540
assert_eq ! (
534
541
CallMemberEventContent :: Empty ( EmptyMembershipData { leave_reason: None } ) ,
@@ -568,7 +575,7 @@ mod tests {
568
575
}
569
576
570
577
#[ test]
571
- fn memberships_do_expire ( ) {
578
+ fn legacy_memberships_do_expire ( ) {
572
579
let content_legacy = create_call_member_legacy_event_content ( ) ;
573
580
let ( now, one_second_ago, two_hours_ago) = timestamps ( ) ;
574
581
0 commit comments