From 7764f01b59117175c148af9193386238c4b5e32b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Wed, 15 Sep 2021 20:28:16 +0200 Subject: [PATCH] fix(crypto): Only send cancellations if there were multiple request recipients --- .../src/verification/requests.rs | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/crates/matrix-sdk-crypto/src/verification/requests.rs b/crates/matrix-sdk-crypto/src/verification/requests.rs index cdf9f5f9..0e0b28a2 100644 --- a/crates/matrix-sdk-crypto/src/verification/requests.rs +++ b/crates/matrix-sdk-crypto/src/verification/requests.rs @@ -532,12 +532,20 @@ impl VerificationRequest { .filter(|d| if let Some(device) = filter_device { &**d != device } else { true }) .collect(); - Some(ToDeviceRequest::new_for_recipients( - self.other_user(), - recipients, - c, - Uuid::new_v4(), - )) + // We don't need to notify anyone if no recipients were present + // but we did have a filter device, since this means that only a + // single device received the `m.key.verification.request` and that + // device accepted the request. + if recipients.is_empty() && filter_device.is_some() { + None + } else { + Some(ToDeviceRequest::new_for_recipients( + self.other_user(), + recipients, + c, + Uuid::new_v4(), + )) + } } else { None }