crypto: Remove some duplicate code
parent
cbcf673d21
commit
cf98681f19
|
@ -25,6 +25,7 @@ use matrix_sdk_common::{
|
|||
events::{
|
||||
key::verification::{
|
||||
cancel::{CancelCode, CancelEventContent, CancelToDeviceEventContent},
|
||||
done::{DoneEventContent, DoneToDeviceEventContent},
|
||||
Relation,
|
||||
},
|
||||
AnyMessageEventContent, AnyToDeviceEventContent,
|
||||
|
@ -54,6 +55,24 @@ pub struct Done {
|
|||
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)]
|
||||
pub struct Cancelled {
|
||||
cancel_code: CancelCode,
|
||||
|
|
|
@ -1064,19 +1064,7 @@ impl SasState<Done> {
|
|||
}
|
||||
|
||||
pub fn done_content(&self) -> OutgoingContent {
|
||||
match 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(),
|
||||
}
|
||||
self.state.as_content(self.verification_flow_id.as_ref())
|
||||
}
|
||||
|
||||
/// Get the list of verified devices.
|
||||
|
|
Loading…
Reference in New Issue