mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-05 23:16:06 +03:00
Allow users to remove contact relationships that they initiated
This commit is contained in:
parent
054d697fb7
commit
0533a0bd3c
@ -269,19 +269,18 @@ impl Db for PostgresDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn remove_contact(&self, requester_id: UserId, responder_id: UserId) -> Result<()> {
|
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 {
|
let (id_a, id_b) = if responder_id < requester_id {
|
||||||
(responder_id, requester_id, false)
|
(responder_id, requester_id)
|
||||||
} else {
|
} else {
|
||||||
(requester_id, responder_id, true)
|
(requester_id, responder_id)
|
||||||
};
|
};
|
||||||
let query = "
|
let query = "
|
||||||
DELETE FROM contacts
|
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)
|
let result = sqlx::query(query)
|
||||||
.bind(id_a.0)
|
.bind(id_a.0)
|
||||||
.bind(id_b.0)
|
.bind(id_b.0)
|
||||||
.bind(a_to_b)
|
|
||||||
.execute(&self.pool)
|
.execute(&self.pool)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user