From be53913a160ee8e7bb4e8d8a09c3d1c4da66c79f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Mon, 14 Jun 2021 17:28:10 +0200 Subject: [PATCH] crypto: Remove the redundant flow id copy --- .../src/verification/requests.rs | 41 +++++-------------- 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/matrix_sdk_crypto/src/verification/requests.rs b/matrix_sdk_crypto/src/verification/requests.rs index bb5bbfa7..f6d6ea64 100644 --- a/matrix_sdk_crypto/src/verification/requests.rs +++ b/matrix_sdk_crypto/src/verification/requests.rs @@ -230,7 +230,7 @@ impl VerificationRequest { r.private_cross_signing_identity.clone(), r.other_user_id.clone(), r.state.other_device_id.clone(), - r.state.flow_id.clone(), + r.flow_id.as_ref().to_owned(), data, ) .await?, @@ -508,7 +508,7 @@ impl RequestState { account, other_user_id: other_user_id.to_owned(), private_cross_signing_identity: private_identity, - state: Created { methods: SUPPORTED_METHODS.to_vec(), flow_id: flow_id.to_owned() }, + state: Created { methods: SUPPORTED_METHODS.to_vec() }, verification_cache: cache, store, flow_id: flow_id.to_owned().into(), @@ -527,7 +527,6 @@ impl RequestState { state: Ready { methods: content.methods().to_owned(), other_device_id: content.from_device().into(), - flow_id: self.state.flow_id, }, } } @@ -537,10 +536,6 @@ impl RequestState { struct Created { /// The verification methods supported by the sender. pub methods: Vec, - - /// The event id of our `m.key.verification.request` event which acts as an - /// unique id identifying this verification flow. - pub flow_id: FlowId, } #[derive(Clone, Debug)] @@ -548,10 +543,6 @@ struct Requested { /// The verification methods supported by the sender. pub methods: Vec, - /// The event id of the `m.key.verification.request` event which acts as an - /// unique id identifying this verification flow. - pub flow_id: FlowId, - /// The device id of the device that responded to the verification request. pub other_device_id: DeviceIdBox, } @@ -576,7 +567,6 @@ impl RequestState { other_user_id: sender.clone(), state: Requested { methods: content.methods().to_owned(), - flow_id: flow_id.clone(), other_device_id: content.from_device().into(), }, } @@ -588,30 +578,29 @@ impl RequestState { store: self.store, verification_cache: self.verification_cache, private_cross_signing_identity: self.private_cross_signing_identity, - flow_id: self.flow_id, + flow_id: self.flow_id.clone(), other_user_id: self.other_user_id, state: Ready { methods: SUPPORTED_METHODS.to_vec(), other_device_id: self.state.other_device_id.clone(), - flow_id: self.state.flow_id.clone(), }, }; - let content = match self.state.flow_id { + let content = match self.flow_id.as_ref() { FlowId::ToDevice(i) => { AnyToDeviceEventContent::KeyVerificationReady(ReadyToDeviceEventContent::new( self.account.device_id().to_owned(), SUPPORTED_METHODS.to_vec(), - i, + i.to_owned(), )) .into() } FlowId::InRoom(r, e) => ( - r, + r.to_owned(), AnyMessageEventContent::KeyVerificationReady(ReadyEventContent::new( self.account.device_id().to_owned(), SUPPORTED_METHODS.to_vec(), - Relation::new(e), + Relation::new(e.to_owned()), )), ) .into(), @@ -628,10 +617,6 @@ struct Ready { /// The device id of the device that responded to the verification request. pub other_device_id: DeviceIdBox, - - /// The event id of the `m.key.verification.request` event which acts as an - /// unique id identifying this verification flow. - pub flow_id: FlowId, } impl RequestState { @@ -813,7 +798,7 @@ impl RequestState { other_device: ReadOnlyDevice, other_identity: Option, ) -> (Sas, OutgoingContent) { - match self.state.flow_id { + match self.flow_id.as_ref() { FlowId::ToDevice(t) => { let (sas, content) = Sas::start( account, @@ -821,14 +806,14 @@ impl RequestState { other_device, store, other_identity, - Some(t), + Some(t.to_owned()), ); (sas, content) } FlowId::InRoom(r, e) => { let (sas, content) = Sas::start_in_room( - e, - r, + e.to_owned(), + r.to_owned(), account, private_identity, other_device, @@ -845,10 +830,6 @@ impl RequestState { struct Passive { /// The device id of the device that responded to the verification request. pub other_device_id: DeviceIdBox, - - /// The event id of the `m.key.verification.request` event which acts as an - /// unique id identifying this verification flow. - pub flow_id: FlowId, } #[derive(Clone, Debug)]