From b7986a5153b2450c4e292400d1fd64fbbcd2b8ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Mon, 14 Jun 2021 17:50:35 +0200 Subject: [PATCH] crypto: Add a couple more accessors for the verification request --- .../src/verification/requests.rs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/matrix_sdk_crypto/src/verification/requests.rs b/matrix_sdk_crypto/src/verification/requests.rs index 48caf4d0..71ec2463 100644 --- a/matrix_sdk_crypto/src/verification/requests.rs +++ b/matrix_sdk_crypto/src/verification/requests.rs @@ -177,11 +177,32 @@ impl VerificationRequest { &self.other_user_id } + /// Has the verification request been answered by another device. + pub fn is_passive(&self) -> bool { + matches!(&*self.inner.lock().unwrap(), InnerRequest::Passive(_)) + } + /// Is the verification request ready to start a verification flow. pub fn is_ready(&self) -> bool { matches!(&*self.inner.lock().unwrap(), InnerRequest::Ready(_)) } + /// Get the supported verification methods of the other side. + /// + /// Will be present only if the other side requested the verification or if + /// we're in the ready state. + pub fn their_supported_methods(&self) -> Vec { + match &*self.inner.lock().unwrap() { + InnerRequest::Requested(r) => Some(r.state.their_methods.clone()), + InnerRequest::Ready(r) => Some(r.state.their_methods.clone()), + InnerRequest::Created(_) + | InnerRequest::Passive(_) + | InnerRequest::Done(_) + | InnerRequest::Cancelled(_) => None, + } + .unwrap_or_default() + } + /// Get the unique ID of this verification request pub fn flow_id(&self) -> &FlowId { &self.flow_id