From 0533a0bd3c2ebb8c13a64f473eb89b0621514363 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 9 May 2022 16:26:44 -0700 Subject: [PATCH] Allow users to remove contact relationships that they initiated --- crates/collab/src/db.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/collab/src/db.rs b/crates/collab/src/db.rs index e5b3b31571..57619941a0 100644 --- a/crates/collab/src/db.rs +++ b/crates/collab/src/db.rs @@ -269,19 +269,18 @@ impl Db for PostgresDb { } async fn remove_contact(&self, requester_id: UserId, responder_id: UserId) -> Result<()> { - let (id_a, id_b, a_to_b) = if responder_id < requester_id { - (responder_id, requester_id, false) + let (id_a, id_b) = if responder_id < requester_id { + (responder_id, requester_id) } else { - (requester_id, responder_id, true) + (requester_id, responder_id) }; let query = " DELETE FROM contacts - WHERE user_id_a = $1 AND user_id_b = $2 AND a_to_b = $3; + WHERE user_id_a = $1 AND user_id_b = $2; "; let result = sqlx::query(query) .bind(id_a.0) .bind(id_b.0) - .bind(a_to_b) .execute(&self.pool) .await?;