From 80fac4bfa41b09fb4996d3c4b514f8b127fad5ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Mon, 14 Jun 2021 17:32:30 +0200 Subject: [PATCH] cyrpto: Go into passive mode if someone else replies to a request --- matrix_sdk_crypto/src/verification/requests.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/matrix_sdk_crypto/src/verification/requests.rs b/matrix_sdk_crypto/src/verification/requests.rs index f6d6ea64..ea704f67 100644 --- a/matrix_sdk_crypto/src/verification/requests.rs +++ b/matrix_sdk_crypto/src/verification/requests.rs @@ -305,7 +305,11 @@ impl VerificationRequest { let mut inner = self.inner.lock().unwrap(); if let InnerRequest::Created(s) = &*inner { - *inner = InnerRequest::Ready(s.clone().into_ready(sender, content)); + if sender == self.own_user_id() && content.from_device() == self.account.device_id() { + *inner = InnerRequest::Passive(s.clone().into_passive(content)) + } else { + *inner = InnerRequest::Ready(s.clone().into_ready(sender, content)); + } } } @@ -515,6 +519,18 @@ impl RequestState { } } + fn into_passive(self, content: &ReadyContent) -> RequestState { + RequestState { + account: self.account, + flow_id: self.flow_id, + verification_cache: self.verification_cache, + private_cross_signing_identity: self.private_cross_signing_identity, + store: self.store, + other_user_id: self.other_user_id, + state: Passive { other_device_id: content.from_device().to_owned() }, + } + } + fn into_ready(self, _sender: &UserId, content: &ReadyContent) -> RequestState { // TODO check the flow id, and that the methods match what we suggested. RequestState {