Skip to content

Commit b877d15

Browse files
committed
Do not send Done message after receiving a Done
Done messages are supposed to indicate that the verification was successful and _can be_ finalized. The correct time to send Done events is after the user has confirmed the verification (after checking the emoji or similar) and after receiving and checking a mac from the other party (whatever happens later). Waiting for the other side to send Done before sending it ourselves does not make sense.
1 parent 1c72472 commit b877d15

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

crates/matrix-sdk-crypto/src/verification/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ use matrix_sdk_common::locks::Mutex;
3131
#[cfg(feature = "qrcode")]
3232
pub use qrcode::{QrVerification, ScanError};
3333
pub use requests::VerificationRequest;
34+
#[cfg(feature = "qrcode")]
35+
use ruma::events::key::verification::done::{
36+
KeyVerificationDoneEventContent, ToDeviceKeyVerificationDoneEventContent,
37+
};
3438
use ruma::{
3539
api::client::r0::keys::upload_signatures::Request as SignatureUploadRequest,
3640
events::{
@@ -39,7 +43,6 @@ use ruma::{
3943
CancelCode, KeyVerificationCancelEventContent,
4044
ToDeviceKeyVerificationCancelEventContent,
4145
},
42-
done::{KeyVerificationDoneEventContent, ToDeviceKeyVerificationDoneEventContent},
4346
Relation,
4447
},
4548
AnyMessageEventContent, AnyToDeviceEventContent,
@@ -243,6 +246,7 @@ pub struct Done {
243246
}
244247

245248
impl Done {
249+
#[cfg(feature = "qrcode")]
246250
pub fn as_content(&self, flow_id: &FlowId) -> OutgoingContent {
247251
match flow_id {
248252
FlowId::ToDevice(t) => AnyToDeviceEventContent::KeyVerificationDone(

crates/matrix-sdk-crypto/src/verification/sas/inner_sas.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,7 @@ impl InnerSas {
335335
},
336336
AnyVerificationContent::Done(c) => match self {
337337
InnerSas::WaitingForDone(s) => match s.into_done(sender, c) {
338-
Ok(s) => {
339-
let content = s.done_content();
340-
(InnerSas::Done(s), Some(content))
341-
}
338+
Ok(s) => (InnerSas::Done(s), None),
342339
Err(s) => {
343340
let content = s.as_content();
344341
(InnerSas::Cancelled(s), Some(content))

crates/matrix-sdk-crypto/src/verification/sas/sas_state.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,10 +1177,6 @@ impl SasState<Done> {
11771177
get_mac_content(&self.inner.lock().unwrap(), &self.ids, &self.verification_flow_id)
11781178
}
11791179

1180-
pub fn done_content(&self) -> OutgoingContent {
1181-
self.state.as_content(self.verification_flow_id.as_ref())
1182-
}
1183-
11841180
/// Get the list of verified devices.
11851181
pub fn verified_devices(&self) -> Arc<[ReadOnlyDevice]> {
11861182
self.state.verified_devices.clone()

0 commit comments

Comments
 (0)