diff --git a/matrix_sdk_crypto/src/verification/sas/inner_sas.rs b/matrix_sdk_crypto/src/verification/sas/inner_sas.rs index 67b5302e..7ca37d5a 100644 --- a/matrix_sdk_crypto/src/verification/sas/inner_sas.rs +++ b/matrix_sdk_crypto/src/verification/sas/inner_sas.rs @@ -312,6 +312,18 @@ impl InnerSas { matches!(self, InnerSas::Cancelled(_)) } + pub fn have_we_confirmed(&self) -> bool { + matches!(self, InnerSas::Confirmed(_) | InnerSas::WaitingForDone(_) | InnerSas::Done(_)) + } + + pub fn cancel_code(&self) -> Option { + if let InnerSas::Cancelled(c) = self { + Some(c.state.cancel_code.clone()) + } else { + None + } + } + pub fn timed_out(&self) -> bool { match self { InnerSas::Created(s) => s.timed_out(), diff --git a/matrix_sdk_crypto/src/verification/sas/mod.rs b/matrix_sdk_crypto/src/verification/sas/mod.rs index fb9a5be6..3339c8e4 100644 --- a/matrix_sdk_crypto/src/verification/sas/mod.rs +++ b/matrix_sdk_crypto/src/verification/sas/mod.rs @@ -104,6 +104,16 @@ impl Sas { self.identities_being_verified.is_self_verification() } + /// Have we confirmed that the short auth string matches. + pub fn have_we_confirmed(&self) -> bool { + self.inner.lock().unwrap().have_we_confirmed() + } + + /// Get the cancel code of this SAS verification if it has been cancelled + pub fn cancel_code(&self) -> Option { + self.inner.lock().unwrap().cancel_code() + } + #[cfg(test)] #[allow(dead_code)] pub(crate) fn set_creation_time(&self, time: Instant) {