crypto: WIP handle in-room start events.
parent
7570cf5ac2
commit
5105629c08
|
@ -46,7 +46,7 @@ pub struct VerificationMachine {
|
||||||
private_identity: Arc<Mutex<PrivateCrossSigningIdentity>>,
|
private_identity: Arc<Mutex<PrivateCrossSigningIdentity>>,
|
||||||
pub(crate) store: Arc<Box<dyn CryptoStore>>,
|
pub(crate) store: Arc<Box<dyn CryptoStore>>,
|
||||||
verifications: Arc<DashMap<String, Sas>>,
|
verifications: Arc<DashMap<String, Sas>>,
|
||||||
room_verifications: Arc<DashMap<String, Sas>>,
|
room_verifications: Arc<DashMap<EventId, Sas>>,
|
||||||
requests: Arc<DashMap<EventId, VerificationRequest>>,
|
requests: Arc<DashMap<EventId, VerificationRequest>>,
|
||||||
outgoing_to_device_messages: Arc<DashMap<Uuid, OutgoingRequest>>,
|
outgoing_to_device_messages: Arc<DashMap<Uuid, OutgoingRequest>>,
|
||||||
}
|
}
|
||||||
|
@ -202,6 +202,32 @@ impl VerificationMachine {
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some((_, request)) = self.requests.remove(&e.content.relation.event_id) {
|
if let Some((_, request)) = self.requests.remove(&e.content.relation.event_id) {
|
||||||
|
if let Some(d) = self
|
||||||
|
.store
|
||||||
|
.get_device(&e.sender, &e.content.from_device)
|
||||||
|
.await?
|
||||||
|
{
|
||||||
|
match request.into_started_sas(
|
||||||
|
e,
|
||||||
|
d,
|
||||||
|
self.store.get_user_identity(&e.sender).await?,
|
||||||
|
) {
|
||||||
|
Ok(s) => {
|
||||||
|
// TODO we need to queue up the accept event
|
||||||
|
// here.
|
||||||
|
let accept_event = s.accept();
|
||||||
|
self.room_verifications
|
||||||
|
.insert(e.content.relation.event_id.clone(), s);
|
||||||
|
}
|
||||||
|
Err(c) => {
|
||||||
|
warn!(
|
||||||
|
"Can't start key verification with {} {}, canceling: {:?}",
|
||||||
|
e.sender, e.content.from_device, c
|
||||||
|
);
|
||||||
|
// self.queue_up_content(&e.sender, &e.content.from_device, c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
|
|
|
@ -23,7 +23,7 @@ use matrix_sdk_common::{
|
||||||
ready::ReadyEventContent, start::StartEventContent, Relation, VerificationMethod,
|
ready::ReadyEventContent, start::StartEventContent, Relation, VerificationMethod,
|
||||||
},
|
},
|
||||||
room::message::KeyVerificationRequestEventContent,
|
room::message::KeyVerificationRequestEventContent,
|
||||||
MessageEvent,
|
MessageEvent, SyncMessageEvent,
|
||||||
},
|
},
|
||||||
identifiers::{DeviceId, DeviceIdBox, EventId, RoomId, UserId},
|
identifiers::{DeviceId, DeviceIdBox, EventId, RoomId, UserId},
|
||||||
};
|
};
|
||||||
|
@ -87,7 +87,7 @@ impl VerificationRequest {
|
||||||
|
|
||||||
pub(crate) fn into_started_sas(
|
pub(crate) fn into_started_sas(
|
||||||
&self,
|
&self,
|
||||||
event: &MessageEvent<StartEventContent>,
|
event: &SyncMessageEvent<StartEventContent>,
|
||||||
device: ReadOnlyDevice,
|
device: ReadOnlyDevice,
|
||||||
user_identity: Option<UserIdentities>,
|
user_identity: Option<UserIdentities>,
|
||||||
) -> Result<Sas, OutgoingContent> {
|
) -> Result<Sas, OutgoingContent> {
|
||||||
|
@ -128,7 +128,7 @@ impl InnerRequest {
|
||||||
|
|
||||||
fn into_started_sas(
|
fn into_started_sas(
|
||||||
&mut self,
|
&mut self,
|
||||||
event: &MessageEvent<StartEventContent>,
|
event: &SyncMessageEvent<StartEventContent>,
|
||||||
store: Arc<Box<dyn CryptoStore>>,
|
store: Arc<Box<dyn CryptoStore>>,
|
||||||
account: ReadOnlyAccount,
|
account: ReadOnlyAccount,
|
||||||
private_identity: PrivateCrossSigningIdentity,
|
private_identity: PrivateCrossSigningIdentity,
|
||||||
|
@ -299,7 +299,7 @@ struct Ready {
|
||||||
impl RequestState<Ready> {
|
impl RequestState<Ready> {
|
||||||
fn into_started_sas(
|
fn into_started_sas(
|
||||||
&self,
|
&self,
|
||||||
event: &MessageEvent<StartEventContent>,
|
event: &SyncMessageEvent<StartEventContent>,
|
||||||
store: Arc<Box<dyn CryptoStore>>,
|
store: Arc<Box<dyn CryptoStore>>,
|
||||||
account: ReadOnlyAccount,
|
account: ReadOnlyAccount,
|
||||||
private_identity: PrivateCrossSigningIdentity,
|
private_identity: PrivateCrossSigningIdentity,
|
||||||
|
@ -344,6 +344,3 @@ struct Passive {
|
||||||
/// unique id identifying this verification flow.
|
/// unique id identifying this verification flow.
|
||||||
pub flow_id: EventId,
|
pub flow_id: EventId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
struct Started {}
|
|
||||||
|
|
Loading…
Reference in New Issue