From d6d1e20f07b2162af33c7be144651bc464255b61 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 1 Nov 2022 18:48:08 +0100 Subject: [PATCH] Ensure declining call doesn't accidentally leave a room --- crates/collab/src/integration_tests.rs | 2 +- crates/collab/src/rpc/store.rs | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/collab/src/integration_tests.rs b/crates/collab/src/integration_tests.rs index 1e2a3e7a548950e9ee40db52953a405286c879ff..9818e295f179a0f6f6422ad03785fa9cafb71dcf 100644 --- a/crates/collab/src/integration_tests.rs +++ b/crates/collab/src/integration_tests.rs @@ -6612,7 +6612,7 @@ impl TestClient { .update(cx, |call, cx| call.share_project(project.clone(), cx)) .await { - log::error!("{}: error sharing project {:?}", username, error); + log::error!("{}: error sharing project, {:?}", username, error); } let buffers = client.buffers.entry(project.clone()).or_default(); diff --git a/crates/collab/src/rpc/store.rs b/crates/collab/src/rpc/store.rs index a7abce7094b1c8fdfb062d98e21c9f859b58cdfa..c9358ddc2a356e3f1c3e624f1851d955287c840c 100644 --- a/crates/collab/src/rpc/store.rs +++ b/crates/collab/src/rpc/store.rs @@ -674,8 +674,13 @@ impl Store { .connected_users .get_mut(&recipient_user_id) .ok_or_else(|| anyhow!("no such connection"))?; - if let Some(active_call) = recipient.active_call.take() { + if let Some(active_call) = recipient.active_call { anyhow::ensure!(active_call.room_id == room_id, "no such room"); + anyhow::ensure!( + active_call.connection_id.is_none(), + "cannot decline a call after joining room" + ); + recipient.active_call.take(); let recipient_connection_ids = self .connection_ids_for_user(recipient_user_id) .collect::>(); @@ -1196,7 +1201,9 @@ impl Store { assert!( self.connections .contains_key(&ConnectionId(participant.peer_id)), - "room contains participant that has disconnected" + "room {} contains participant {:?} that has disconnected", + room_id, + participant ); for participant_project in &participant.projects {