crypto: Remove some duplicate code
parent
cbcf673d21
commit
cf98681f19
|
@ -25,6 +25,7 @@ use matrix_sdk_common::{
|
||||||
events::{
|
events::{
|
||||||
key::verification::{
|
key::verification::{
|
||||||
cancel::{CancelCode, CancelEventContent, CancelToDeviceEventContent},
|
cancel::{CancelCode, CancelEventContent, CancelToDeviceEventContent},
|
||||||
|
done::{DoneEventContent, DoneToDeviceEventContent},
|
||||||
Relation,
|
Relation,
|
||||||
},
|
},
|
||||||
AnyMessageEventContent, AnyToDeviceEventContent,
|
AnyMessageEventContent, AnyToDeviceEventContent,
|
||||||
|
@ -54,6 +55,24 @@ pub struct Done {
|
||||||
verified_master_keys: Arc<[UserIdentities]>,
|
verified_master_keys: Arc<[UserIdentities]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Done {
|
||||||
|
pub fn as_content(&self, flow_id: &FlowId) -> OutgoingContent {
|
||||||
|
match flow_id {
|
||||||
|
FlowId::ToDevice(t) => AnyToDeviceEventContent::KeyVerificationDone(
|
||||||
|
DoneToDeviceEventContent::new(t.to_owned()),
|
||||||
|
)
|
||||||
|
.into(),
|
||||||
|
FlowId::InRoom(r, e) => (
|
||||||
|
r.to_owned(),
|
||||||
|
AnyMessageEventContent::KeyVerificationDone(DoneEventContent::new(Relation::new(
|
||||||
|
e.to_owned(),
|
||||||
|
))),
|
||||||
|
)
|
||||||
|
.into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Cancelled {
|
pub struct Cancelled {
|
||||||
cancel_code: CancelCode,
|
cancel_code: CancelCode,
|
||||||
|
|
|
@ -1064,19 +1064,7 @@ impl SasState<Done> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn done_content(&self) -> OutgoingContent {
|
pub fn done_content(&self) -> OutgoingContent {
|
||||||
match self.verification_flow_id.as_ref() {
|
self.state.as_content(self.verification_flow_id.as_ref())
|
||||||
FlowId::ToDevice(t) => AnyToDeviceEventContent::KeyVerificationDone(
|
|
||||||
DoneToDeviceEventContent::new(t.to_owned()),
|
|
||||||
)
|
|
||||||
.into(),
|
|
||||||
FlowId::InRoom(r, e) => (
|
|
||||||
r.clone(),
|
|
||||||
AnyMessageEventContent::KeyVerificationDone(DoneEventContent::new(Relation::new(
|
|
||||||
e.clone(),
|
|
||||||
))),
|
|
||||||
)
|
|
||||||
.into(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the list of verified devices.
|
/// Get the list of verified devices.
|
||||||
|
|
Loading…
Reference in New Issue