diff --git a/matrix_sdk_crypto/src/verification/sas/inner_sas.rs b/matrix_sdk_crypto/src/verification/sas/inner_sas.rs index 4ebac3fb..2dc9dfa5 100644 --- a/matrix_sdk_crypto/src/verification/sas/inner_sas.rs +++ b/matrix_sdk_crypto/src/verification/sas/inner_sas.rs @@ -46,7 +46,6 @@ pub enum InnerSas { Confirmed(SasState), MacReceived(SasState), WaitingForDone(SasState), - WaitingForDoneUnconfirmed(SasState), Done(SasState), Cancelled(SasState), } @@ -88,7 +87,6 @@ impl InnerSas { .short_auth_string .contains(&ShortAuthenticationString::Emoji), InnerSas::WaitingForDone(_) => false, - InnerSas::WaitingForDoneUnconfirmed(_) => false, InnerSas::Done(_) => false, InnerSas::Cancelled(_) => false, } @@ -154,7 +152,6 @@ impl InnerSas { InnerSas::MacReceived(s) => s.set_creation_time(time), InnerSas::Done(s) => s.set_creation_time(time), InnerSas::WaitingForDone(s) => s.set_creation_time(time), - InnerSas::WaitingForDoneUnconfirmed(s) => s.set_creation_time(time), } } @@ -181,11 +178,11 @@ impl InnerSas { (InnerSas::Confirmed(sas), Some(content)) } InnerSas::MacReceived(s) => { - if s.is_dm_verification() { + if s.started_from_request { let sas = s.confirm_and_wait_for_done(); let content = sas.as_content(); - (InnerSas::WaitingForDoneUnconfirmed(sas), Some(content)) + (InnerSas::WaitingForDone(sas), Some(content)) } else { let sas = s.confirm(); let content = sas.as_content(); @@ -273,13 +270,6 @@ impl InnerSas { }, AnyVerificationContent::Done(c) => match self { InnerSas::WaitingForDone(s) => match s.into_done(sender, c) { - Ok(s) => (InnerSas::Done(s), None), - Err(s) => { - let content = s.as_content(); - (InnerSas::Cancelled(s), Some(content)) - } - }, - InnerSas::WaitingForDoneUnconfirmed(s) => match s.into_done(sender, c) { Ok(s) => { let content = s.done_content(); (InnerSas::Done(s), Some(content)) @@ -289,7 +279,6 @@ impl InnerSas { (InnerSas::Cancelled(s), Some(content)) } }, - _ => (self, None), }, AnyVerificationContent::Request(_) @@ -320,7 +309,6 @@ impl InnerSas { InnerSas::Confirmed(s) => s.timed_out(), InnerSas::MacReceived(s) => s.timed_out(), InnerSas::WaitingForDone(s) => s.timed_out(), - InnerSas::WaitingForDoneUnconfirmed(s) => s.timed_out(), InnerSas::Done(s) => s.timed_out(), } } @@ -335,7 +323,6 @@ impl InnerSas { InnerSas::Confirmed(s) => s.verification_flow_id.clone(), InnerSas::MacReceived(s) => s.verification_flow_id.clone(), InnerSas::WaitingForDone(s) => s.verification_flow_id.clone(), - InnerSas::WaitingForDoneUnconfirmed(s) => s.verification_flow_id.clone(), InnerSas::Done(s) => s.verification_flow_id.clone(), } } diff --git a/matrix_sdk_crypto/src/verification/sas/mod.rs b/matrix_sdk_crypto/src/verification/sas/mod.rs index d7ce7dbc..4f9cc4e6 100644 --- a/matrix_sdk_crypto/src/verification/sas/mod.rs +++ b/matrix_sdk_crypto/src/verification/sas/mod.rs @@ -37,6 +37,7 @@ use matrix_sdk_common::{ identifiers::{DeviceId, EventId, RoomId, UserId}, uuid::Uuid, }; +use tracing::trace; use super::{ event_enums::{AnyVerificationContent, OwnedAcceptContent, StartContent}, @@ -305,6 +306,14 @@ impl Sas { } }); + if mac_request.is_some() { + trace!( + user_id = self.other_user_id().as_str(), + device_id = self.other_device_id().as_str(), + "Confirming SAS verification" + ) + } + if done { match self.mark_as_done().await? { VerificationResult::Cancel(c) => Ok((self.cancel_with_code(c), None)), diff --git a/matrix_sdk_crypto/src/verification/sas/sas_state.rs b/matrix_sdk_crypto/src/verification/sas/sas_state.rs index 1d34e9a7..034f6930 100644 --- a/matrix_sdk_crypto/src/verification/sas/sas_state.rs +++ b/matrix_sdk_crypto/src/verification/sas/sas_state.rs @@ -316,6 +316,7 @@ impl SasState { } /// Is this verification happening inside a DM. + #[allow(dead_code)] pub fn is_dm_verification(&self) -> bool { matches!(&*self.verification_flow_id, FlowId::InRoom(_, _)) }