crypto: Remove the redundant flow id copy

master
Damir Jelić 2021-06-14 17:28:10 +02:00
parent df1fe0ebc4
commit be53913a16
1 changed files with 11 additions and 30 deletions

View File

@ -230,7 +230,7 @@ impl VerificationRequest {
r.private_cross_signing_identity.clone(), r.private_cross_signing_identity.clone(),
r.other_user_id.clone(), r.other_user_id.clone(),
r.state.other_device_id.clone(), r.state.other_device_id.clone(),
r.state.flow_id.clone(), r.flow_id.as_ref().to_owned(),
data, data,
) )
.await?, .await?,
@ -508,7 +508,7 @@ impl RequestState<Created> {
account, account,
other_user_id: other_user_id.to_owned(), other_user_id: other_user_id.to_owned(),
private_cross_signing_identity: private_identity, 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, verification_cache: cache,
store, store,
flow_id: flow_id.to_owned().into(), flow_id: flow_id.to_owned().into(),
@ -527,7 +527,6 @@ impl RequestState<Created> {
state: Ready { state: Ready {
methods: content.methods().to_owned(), methods: content.methods().to_owned(),
other_device_id: content.from_device().into(), other_device_id: content.from_device().into(),
flow_id: self.state.flow_id,
}, },
} }
} }
@ -537,10 +536,6 @@ impl RequestState<Created> {
struct Created { struct Created {
/// The verification methods supported by the sender. /// The verification methods supported by the sender.
pub methods: Vec<VerificationMethod>, pub methods: Vec<VerificationMethod>,
/// 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)] #[derive(Clone, Debug)]
@ -548,10 +543,6 @@ struct Requested {
/// The verification methods supported by the sender. /// The verification methods supported by the sender.
pub methods: Vec<VerificationMethod>, pub methods: Vec<VerificationMethod>,
/// 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. /// The device id of the device that responded to the verification request.
pub other_device_id: DeviceIdBox, pub other_device_id: DeviceIdBox,
} }
@ -576,7 +567,6 @@ impl RequestState<Requested> {
other_user_id: sender.clone(), other_user_id: sender.clone(),
state: Requested { state: Requested {
methods: content.methods().to_owned(), methods: content.methods().to_owned(),
flow_id: flow_id.clone(),
other_device_id: content.from_device().into(), other_device_id: content.from_device().into(),
}, },
} }
@ -588,30 +578,29 @@ impl RequestState<Requested> {
store: self.store, store: self.store,
verification_cache: self.verification_cache, verification_cache: self.verification_cache,
private_cross_signing_identity: self.private_cross_signing_identity, 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, other_user_id: self.other_user_id,
state: Ready { state: Ready {
methods: SUPPORTED_METHODS.to_vec(), methods: SUPPORTED_METHODS.to_vec(),
other_device_id: self.state.other_device_id.clone(), 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) => { FlowId::ToDevice(i) => {
AnyToDeviceEventContent::KeyVerificationReady(ReadyToDeviceEventContent::new( AnyToDeviceEventContent::KeyVerificationReady(ReadyToDeviceEventContent::new(
self.account.device_id().to_owned(), self.account.device_id().to_owned(),
SUPPORTED_METHODS.to_vec(), SUPPORTED_METHODS.to_vec(),
i, i.to_owned(),
)) ))
.into() .into()
} }
FlowId::InRoom(r, e) => ( FlowId::InRoom(r, e) => (
r, r.to_owned(),
AnyMessageEventContent::KeyVerificationReady(ReadyEventContent::new( AnyMessageEventContent::KeyVerificationReady(ReadyEventContent::new(
self.account.device_id().to_owned(), self.account.device_id().to_owned(),
SUPPORTED_METHODS.to_vec(), SUPPORTED_METHODS.to_vec(),
Relation::new(e), Relation::new(e.to_owned()),
)), )),
) )
.into(), .into(),
@ -628,10 +617,6 @@ struct Ready {
/// The device id of the device that responded to the verification request. /// The device id of the device that responded to the verification request.
pub other_device_id: DeviceIdBox, 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<Ready> { impl RequestState<Ready> {
@ -813,7 +798,7 @@ impl RequestState<Ready> {
other_device: ReadOnlyDevice, other_device: ReadOnlyDevice,
other_identity: Option<UserIdentities>, other_identity: Option<UserIdentities>,
) -> (Sas, OutgoingContent) { ) -> (Sas, OutgoingContent) {
match self.state.flow_id { match self.flow_id.as_ref() {
FlowId::ToDevice(t) => { FlowId::ToDevice(t) => {
let (sas, content) = Sas::start( let (sas, content) = Sas::start(
account, account,
@ -821,14 +806,14 @@ impl RequestState<Ready> {
other_device, other_device,
store, store,
other_identity, other_identity,
Some(t), Some(t.to_owned()),
); );
(sas, content) (sas, content)
} }
FlowId::InRoom(r, e) => { FlowId::InRoom(r, e) => {
let (sas, content) = Sas::start_in_room( let (sas, content) = Sas::start_in_room(
e, e.to_owned(),
r, r.to_owned(),
account, account,
private_identity, private_identity,
other_device, other_device,
@ -845,10 +830,6 @@ impl RequestState<Ready> {
struct Passive { struct Passive {
/// The device id of the device that responded to the verification request. /// The device id of the device that responded to the verification request.
pub other_device_id: DeviceIdBox, 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)] #[derive(Clone, Debug)]