Skip to content

Commit 960c90c

Browse files
committed
Add method to mismatch SAS verifications
The method sets the proper CancelCode for the case when SAS doesn't match on both devices.
1 parent c79e62d commit 960c90c

File tree

1 file changed

+11
-1
lines changed
  • crates/matrix-sdk/src/encryption/verification

1 file changed

+11
-1
lines changed

crates/matrix-sdk/src/encryption/verification/sas.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
use matrix_sdk_base::crypto::{AcceptSettings, CancelInfo, ReadOnlyDevice, Sas as BaseSas};
16-
use ruma::UserId;
16+
use ruma::{events::key::verification::cancel::CancelCode, UserId};
1717

1818
use crate::{error::Result, Client};
1919

@@ -89,6 +89,16 @@ impl SasVerification {
8989
Ok(())
9090
}
9191

92+
/// Cancel the interactive verification flow because the short auth strings didn't match on both sides.
93+
pub async fn mismatch(&self) -> Result<()> {
94+
// FIXME: Use variant once https://github.com/ruma/ruma/pull/804 is merged
95+
if let Some(request) = self.inner.cancel_with_code(CancelCode::from("m.mismatched_sas")) {
96+
self.client.send_verification_request(request).await?;
97+
}
98+
99+
Ok(())
100+
}
101+
92102
/// Cancel the interactive verification flow.
93103
pub async fn cancel(&self) -> Result<()> {
94104
if let Some(request) = self.inner.cancel() {

0 commit comments

Comments
 (0)