cyrpto: Go into passive mode if someone else replies to a request

master
Damir Jelić 2021-06-14 17:32:30 +02:00
parent be53913a16
commit 80fac4bfa4
1 changed files with 17 additions and 1 deletions

View File

@ -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<Created> {
}
}
fn into_passive(self, content: &ReadyContent) -> RequestState<Passive> {
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<Ready> {
// TODO check the flow id, and that the methods match what we suggested.
RequestState {