From 6c322dc835df802ee86e1855b54e51e7a50f7323 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 18 Oct 2022 19:15:14 +0200 Subject: [PATCH] Clear out incoming call when removing last connection for a user Co-Authored-By: Nathan Sobo --- crates/collab/src/integration_tests.rs | 5 +++-- crates/collab/src/rpc/store.rs | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/collab/src/integration_tests.rs b/crates/collab/src/integration_tests.rs index 7586348081..9bf4afc5db 100644 --- a/crates/collab/src/integration_tests.rs +++ b/crates/collab/src/integration_tests.rs @@ -418,7 +418,7 @@ async fn test_calls_on_multiple_connections( let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await; let client_a = server.create_client(cx_a, "user_a").await; let client_b1 = server.create_client(cx_b1, "user_b").await; - let _client_b2 = server.create_client(cx_b2, "user_b").await; + let client_b2 = server.create_client(cx_b2, "user_b").await; server .make_contacts(&mut [(&client_a, cx_a), (&client_b1, cx_b1)]) .await; @@ -548,8 +548,9 @@ async fn test_calls_on_multiple_connections( assert!(incoming_call_b2.next().await.unwrap().is_some()); // User B disconnects all clients, causing user A to no longer see a pending call for them. - println!("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + server.forbid_connections(); server.disconnect_client(client_b1.peer_id().unwrap()); + server.disconnect_client(client_b2.peer_id().unwrap()); deterministic.advance_clock(rpc::RECEIVE_TIMEOUT); active_call_a.read_with(cx_a, |call, _| assert!(call.room().is_none())); } diff --git a/crates/collab/src/rpc/store.rs b/crates/collab/src/rpc/store.rs index ee7d3e2587..f487735188 100644 --- a/crates/collab/src/rpc/store.rs +++ b/crates/collab/src/rpc/store.rs @@ -221,6 +221,9 @@ impl Store { result.guest_projects = left_room.left_projects; result.room_id = Some(room_id); result.canceled_call_connection_ids = left_room.canceled_call_connection_ids; + } else if connected_user.connection_ids.len() == 1 { + self.decline_call(room_id, connection_id)?; + result.room_id = Some(room_id); } }