From 74aeec360d03d23a3ec878fb517336495a99ea88 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 26 Jan 2023 16:44:55 +0100 Subject: [PATCH] Cancel pending call when participant leaves room after a reconnection Previously, if a user temporarily disconnected while there was a pending call, we would fail to cancel such pending call when the caller left the room. This was due to the caller reconnecting and having a different connection id than the one originally used to initiate the call. --- crates/collab/src/db.rs | 8 ++------ .../collab/src/tests/randomized_integration_tests.rs | 10 ++++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/crates/collab/src/db.rs b/crates/collab/src/db.rs index 63ea7fdd9e..3358652feb 100644 --- a/crates/collab/src/db.rs +++ b/crates/collab/src/db.rs @@ -1586,12 +1586,8 @@ impl Database { .filter( Condition::all() .add( - room_participant::Column::CallingConnectionId - .eq(connection.id as i32), - ) - .add( - room_participant::Column::CallingConnectionServerId - .eq(connection.owner_id as i32), + room_participant::Column::CallingUserId + .eq(leaving_participant.user_id), ) .add(room_participant::Column::AnsweringConnectionId.is_null()), ) diff --git a/crates/collab/src/tests/randomized_integration_tests.rs b/crates/collab/src/tests/randomized_integration_tests.rs index e0170f6648..4783957dbb 100644 --- a/crates/collab/src/tests/randomized_integration_tests.rs +++ b/crates/collab/src/tests/randomized_integration_tests.rs @@ -166,12 +166,10 @@ async fn test_random_collaboration( let contacts = server.app_state.db.get_contacts(*user_id).await.unwrap(); let pool = server.connection_pool.lock(); for contact in contacts { - if let db::Contact::Accepted { user_id, .. } = contact { - if pool.is_user_online(user_id) { - assert_ne!( - user_id, removed_user_id, - "removed client is still a contact of another peer" - ); + if let db::Contact::Accepted { user_id, busy, .. } = contact { + if user_id == removed_user_id { + assert!(!pool.is_user_online(user_id)); + assert!(!busy); } } }