crypto: Add a method to check if the scanning has been confirmed

master
Damir Jelić 2021-06-28 09:53:56 +02:00
parent 80a30bcdd6
commit 100a936f1b
2 changed files with 10 additions and 2 deletions

View File

@ -101,10 +101,15 @@ impl QrVerification {
/// ///
/// When the verification object is in this state it's required that the /// When the verification object is in this state it's required that the
/// user confirms that the other side has scanned the QR code. /// user confirms that the other side has scanned the QR code.
pub fn is_scanned(&self) -> bool { pub fn has_been_scanned(&self) -> bool {
matches!(&*self.state.lock().unwrap(), InnerState::Scanned(_)) matches!(&*self.state.lock().unwrap(), InnerState::Scanned(_))
} }
/// Has the scanning of the QR code been confirmed by us.
pub fn has_been_confirmed(&self) -> bool {
matches!(&*self.state.lock().unwrap(), InnerState::Confirmed(_))
}
/// Get our own user id. /// Get our own user id.
pub fn user_id(&self) -> &UserId { pub fn user_id(&self) -> &UserId {
self.identities.user_id() self.identities.user_id()

View File

@ -551,7 +551,10 @@ impl InnerRequest {
}) })
} }
async fn generate_qr_code(&self, we_started: bool) -> Result<Option<QrVerification>, CryptoStoreError> { async fn generate_qr_code(
&self,
we_started: bool,
) -> Result<Option<QrVerification>, CryptoStoreError> {
match self { match self {
InnerRequest::Created(_) => Ok(None), InnerRequest::Created(_) => Ok(None),
InnerRequest::Requested(_) => Ok(None), InnerRequest::Requested(_) => Ok(None),