diff --git a/crates/matrix-sdk/src/encryption/verification/sas.rs b/crates/matrix-sdk/src/encryption/verification/sas.rs index ef4791f1e..b03a3b273 100644 --- a/crates/matrix-sdk/src/encryption/verification/sas.rs +++ b/crates/matrix-sdk/src/encryption/verification/sas.rs @@ -13,7 +13,7 @@ // limitations under the License. use matrix_sdk_base::crypto::{AcceptSettings, CancelInfo, ReadOnlyDevice, Sas as BaseSas}; -use ruma::UserId; +use ruma::{events::key::verification::cancel::CancelCode, UserId}; use crate::{error::Result, Client}; @@ -89,6 +89,16 @@ impl SasVerification { Ok(()) } + /// Cancel the interactive verification flow because the short auth strings didn't match on both sides. + pub async fn mismatch(&self) -> Result<()> { + // FIXME: Use variant once https://github.com/ruma/ruma/pull/804 is merged + if let Some(request) = self.inner.cancel_with_code(CancelCode::from("m.mismatched_sas")) { + self.client.send_verification_request(request).await?; + } + + Ok(()) + } + /// Cancel the interactive verification flow. pub async fn cancel(&self) -> Result<()> { if let Some(request) = self.inner.cancel() {