From 8291b933563d7c9599e6d07c807acd8a2b999859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Fri, 4 Dec 2020 13:35:56 +0100 Subject: [PATCH] matrix-sdk: Update ruma. --- matrix_sdk_common/Cargo.toml | 2 +- matrix_sdk_common/src/lib.rs | 4 +- matrix_sdk_crypto/src/identities/device.rs | 6 +- matrix_sdk_crypto/src/key_request.rs | 57 +++++++++++-------- .../src/olm/group_sessions/inbound.rs | 6 +- .../src/olm/group_sessions/mod.rs | 12 ++-- matrix_sdk_crypto/src/olm/mod.rs | 4 +- .../src/verification/sas/helpers.rs | 8 +-- matrix_sdk_crypto/src/verification/sas/mod.rs | 16 +++--- .../src/verification/sas/sas_state.rs | 44 +++++++------- 10 files changed, 84 insertions(+), 75 deletions(-) diff --git a/matrix_sdk_common/Cargo.toml b/matrix_sdk_common/Cargo.toml index d348a0d1..65f336d5 100644 --- a/matrix_sdk_common/Cargo.toml +++ b/matrix_sdk_common/Cargo.toml @@ -20,7 +20,7 @@ js_int = "0.1.9" [dependencies.ruma] version = "0.0.1" -git = "https://github.com/ruma/ruma" +path = "/home/poljar/werk/priv/ruma/ruma" rev = "48d1c9747561686e1c5627405780f6de01ee17b1" features = ["client-api", "unstable-pre-spec"] diff --git a/matrix_sdk_common/src/lib.rs b/matrix_sdk_common/src/lib.rs index 6e718e68..92002cfc 100644 --- a/matrix_sdk_common/src/lib.rs +++ b/matrix_sdk_common/src/lib.rs @@ -7,7 +7,9 @@ pub use ruma::{ error::{FromHttpRequestError, FromHttpResponseError, IntoHttpError, ServerError}, AuthScheme, EndpointError, OutgoingRequest, }, - directory, encryption, events, identifiers, presence, push, thirdparty, Outgoing, Raw, + directory, encryption, events, identifiers, presence, push, + serde::Raw, + thirdparty, Outgoing, }; pub use uuid; diff --git a/matrix_sdk_crypto/src/identities/device.rs b/matrix_sdk_crypto/src/identities/device.rs index 4dc44298..69e766c1 100644 --- a/matrix_sdk_crypto/src/identities/device.rs +++ b/matrix_sdk_crypto/src/identities/device.rs @@ -27,8 +27,8 @@ use matrix_sdk_common::{ api::r0::keys::SignedKey, encryption::DeviceKeys, events::{ - forwarded_room_key::ForwardedRoomKeyEventContent, room::encrypted::EncryptedEventContent, - EventType, + forwarded_room_key::ForwardedRoomKeyToDeviceEventContent, + room::encrypted::EncryptedEventContent, EventType, }, identifiers::{ DeviceId, DeviceIdBox, DeviceKeyAlgorithm, DeviceKeyId, EventEncryptionAlgorithm, UserId, @@ -158,7 +158,7 @@ impl Device { ) -> OlmResult<(Session, EncryptedEventContent)> { let export = session.export().await; - let content: ForwardedRoomKeyEventContent = if let Ok(c) = export.try_into() { + let content: ForwardedRoomKeyToDeviceEventContent = if let Ok(c) = export.try_into() { c } else { // TODO remove this panic. diff --git a/matrix_sdk_crypto/src/key_request.rs b/matrix_sdk_crypto/src/key_request.rs index 69ea629d..8ef787f4 100644 --- a/matrix_sdk_crypto/src/key_request.rs +++ b/matrix_sdk_crypto/src/key_request.rs @@ -30,8 +30,8 @@ use tracing::{error, info, trace, warn}; use matrix_sdk_common::{ api::r0::to_device::DeviceIdOrAllDevices, events::{ - forwarded_room_key::ForwardedRoomKeyEventContent, - room_key_request::{Action, RequestedKeyInfo, RoomKeyRequestEventContent}, + forwarded_room_key::ForwardedRoomKeyToDeviceEventContent, + room_key_request::{Action, RequestedKeyInfo, RoomKeyRequestToDeviceEventContent}, AnyToDeviceEvent, EventType, ToDeviceEvent, }, identifiers::{DeviceId, DeviceIdBox, EventEncryptionAlgorithm, RoomId, UserId}, @@ -67,8 +67,9 @@ pub enum KeyshareDecision { /// device that requested the key doesn't share an Olm session with us. #[derive(Debug, Clone)] struct WaitQueue { - requests_waiting_for_session: - Arc>>, + requests_waiting_for_session: Arc< + DashMap<(UserId, DeviceIdBox, String), ToDeviceEvent>, + >, requests_ids_waiting: Arc>>, } @@ -85,7 +86,7 @@ impl WaitQueue { self.requests_ids_waiting.is_empty() && self.requests_waiting_for_session.is_empty() } - fn insert(&self, device: &Device, event: &ToDeviceEvent) { + fn insert(&self, device: &Device, event: &ToDeviceEvent) { let key = ( device.user_id().to_owned(), device.device_id().into(), @@ -106,7 +107,7 @@ impl WaitQueue { device_id: &DeviceId, ) -> Vec<( (UserId, DeviceIdBox, String), - ToDeviceEvent, + ToDeviceEvent, )> { self.requests_ids_waiting .remove(&(user_id.to_owned(), device_id.into())) @@ -130,8 +131,9 @@ pub(crate) struct KeyRequestMachine { store: Store, outbound_group_sessions: Arc>, outgoing_to_device_requests: Arc>, - incoming_key_requests: - Arc>>, + incoming_key_requests: Arc< + DashMap<(UserId, DeviceIdBox, String), ToDeviceEvent>, + >, wait_queue: WaitQueue, users_for_key_claim: Arc>>, } @@ -156,7 +158,7 @@ impl Encode for RequestedKeyInfo { } } -impl Encode for ForwardedRoomKeyEventContent { +impl Encode for ForwardedRoomKeyToDeviceEventContent { fn encode(&self) -> String { format!( "{}|{}|{}|{}", @@ -168,7 +170,7 @@ impl Encode for ForwardedRoomKeyEventContent { fn wrap_key_request_content( recipient: UserId, id: Uuid, - content: &RoomKeyRequestEventContent, + content: &RoomKeyRequestToDeviceEventContent, ) -> Result { let mut messages = BTreeMap::new(); @@ -224,7 +226,10 @@ impl KeyRequestMachine { } /// Receive a room key request event. - pub fn receive_incoming_key_request(&self, event: &ToDeviceEvent) { + pub fn receive_incoming_key_request( + &self, + event: &ToDeviceEvent, + ) { let sender = event.sender.clone(); let device_id = event.content.requesting_device_id.clone(); let request_id = event.content.request_id.clone(); @@ -255,7 +260,7 @@ impl KeyRequestMachine { fn handle_key_share_without_session( &self, device: Device, - event: &ToDeviceEvent, + event: &ToDeviceEvent, ) { self.users_for_key_claim .entry(device.user_id().to_owned()) @@ -295,7 +300,7 @@ impl KeyRequestMachine { /// Handle a single incoming key request. async fn handle_key_request( &self, - event: &ToDeviceEvent, + event: &ToDeviceEvent, ) -> OlmResult> { let key_info = match &event.content.action { Action::Request => { @@ -505,7 +510,7 @@ impl KeyRequestMachine { let id = Uuid::new_v4(); - let content = RoomKeyRequestEventContent { + let content = RoomKeyRequestToDeviceEventContent { action: Action::Request, request_id: id.to_string(), requesting_device_id: (&*self.device_id).clone(), @@ -546,7 +551,7 @@ impl KeyRequestMachine { /// Get an outgoing key info that matches the forwarded room key content. async fn get_key_info( &self, - content: &ForwardedRoomKeyEventContent, + content: &ForwardedRoomKeyToDeviceEventContent, ) -> Result, CryptoStoreError> { let id: Option = self.store.get_object(&content.encode()).await?; @@ -597,7 +602,7 @@ impl KeyRequestMachine { // can delete it in one transaction. self.delete_key_info(&key_info).await?; - let content = RoomKeyRequestEventContent { + let content = RoomKeyRequestToDeviceEventContent { action: Action::CancelRequest, request_id: key_info.request_id.to_string(), requesting_device_id: (&*self.device_id).clone(), @@ -617,7 +622,7 @@ impl KeyRequestMachine { pub async fn receive_forwarded_room_key( &self, sender_key: &str, - event: &mut ToDeviceEvent, + event: &mut ToDeviceEvent, ) -> Result<(Option>, Option), CryptoStoreError> { let key_info = self.get_key_info(&event.content).await?; @@ -672,9 +677,9 @@ mod test { use matrix_sdk_common::{ api::r0::to_device::DeviceIdOrAllDevices, events::{ - forwarded_room_key::ForwardedRoomKeyEventContent, - room::encrypted::EncryptedEventContent, room_key_request::RoomKeyRequestEventContent, - AnyToDeviceEvent, ToDeviceEvent, + forwarded_room_key::ForwardedRoomKeyToDeviceEventContent, + room::encrypted::EncryptedEventContent, + room_key_request::RoomKeyRequestToDeviceEventContent, AnyToDeviceEvent, ToDeviceEvent, }, identifiers::{room_id, user_id, DeviceIdBox, RoomId, UserId}, locks::Mutex, @@ -829,7 +834,7 @@ mod test { let export = session.export_at_index(10).await.unwrap(); - let content: ForwardedRoomKeyEventContent = export.try_into().unwrap(); + let content: ForwardedRoomKeyToDeviceEventContent = export.try_into().unwrap(); let mut event = ToDeviceEvent { sender: alice_id(), @@ -886,7 +891,7 @@ mod test { let export = session.export_at_index(15).await.unwrap(); - let content: ForwardedRoomKeyEventContent = export.try_into().unwrap(); + let content: ForwardedRoomKeyToDeviceEventContent = export.try_into().unwrap(); let mut event = ToDeviceEvent { sender: alice_id(), @@ -902,7 +907,7 @@ mod test { let export = session.export_at_index(0).await.unwrap(); - let content: ForwardedRoomKeyEventContent = export.try_into().unwrap(); + let content: ForwardedRoomKeyToDeviceEventContent = export.try_into().unwrap(); let mut event = ToDeviceEvent { sender: alice_id(), @@ -1073,7 +1078,8 @@ mod test { .unwrap() .get(&DeviceIdOrAllDevices::AllDevices) .unwrap(); - let content: RoomKeyRequestEventContent = serde_json::from_str(content.get()).unwrap(); + let content: RoomKeyRequestToDeviceEventContent = + serde_json::from_str(content.get()).unwrap(); drop(request); alice_machine @@ -1241,7 +1247,8 @@ mod test { .unwrap() .get(&DeviceIdOrAllDevices::AllDevices) .unwrap(); - let content: RoomKeyRequestEventContent = serde_json::from_str(content.get()).unwrap(); + let content: RoomKeyRequestToDeviceEventContent = + serde_json::from_str(content.get()).unwrap(); drop(request); alice_machine diff --git a/matrix_sdk_crypto/src/olm/group_sessions/inbound.rs b/matrix_sdk_crypto/src/olm/group_sessions/inbound.rs index e5fdc9bf..5d6036ab 100644 --- a/matrix_sdk_crypto/src/olm/group_sessions/inbound.rs +++ b/matrix_sdk_crypto/src/olm/group_sessions/inbound.rs @@ -34,8 +34,8 @@ pub use olm_rs::{ use matrix_sdk_common::{ events::{ - forwarded_room_key::ForwardedRoomKeyEventContent, room::encrypted::EncryptedEventContent, - AnySyncRoomEvent, SyncMessageEvent, + forwarded_room_key::ForwardedRoomKeyToDeviceEventContent, + room::encrypted::EncryptedEventContent, AnySyncRoomEvent, SyncMessageEvent, }, identifiers::{DeviceKeyAlgorithm, EventEncryptionAlgorithm, RoomId}, locks::Mutex, @@ -132,7 +132,7 @@ impl InboundGroupSession { /// to create the `InboundGroupSession`. pub(crate) fn from_forwarded_key( sender_key: &str, - content: &mut ForwardedRoomKeyEventContent, + content: &mut ForwardedRoomKeyToDeviceEventContent, ) -> Result { let key = Zeroizing::from(mem::take(&mut content.session_key)); diff --git a/matrix_sdk_crypto/src/olm/group_sessions/mod.rs b/matrix_sdk_crypto/src/olm/group_sessions/mod.rs index a78bde53..04174fcb 100644 --- a/matrix_sdk_crypto/src/olm/group_sessions/mod.rs +++ b/matrix_sdk_crypto/src/olm/group_sessions/mod.rs @@ -13,7 +13,7 @@ // limitations under the License. use matrix_sdk_common::{ - events::forwarded_room_key::ForwardedRoomKeyEventContent, + events::forwarded_room_key::ForwardedRoomKeyToDeviceEventContent, identifiers::{DeviceKeyAlgorithm, EventEncryptionAlgorithm, RoomId}, }; use serde::{Deserialize, Serialize}; @@ -66,7 +66,7 @@ pub struct ExportedRoomKey { pub forwarding_curve25519_key_chain: Vec, } -impl TryInto for ExportedRoomKey { +impl TryInto for ExportedRoomKey { type Error = (); /// Convert an exported room key into a content for a forwarded room key @@ -75,7 +75,7 @@ impl TryInto for ExportedRoomKey { /// This will fail if the exported room key has multiple sender claimed keys /// or if the algorithm of the claimed sender key isn't /// `DeviceKeyAlgorithm::Ed25519`. - fn try_into(self) -> Result { + fn try_into(self) -> Result { if self.sender_claimed_keys.len() != 1 { Err(()) } else { @@ -85,7 +85,7 @@ impl TryInto for ExportedRoomKey { return Err(()); } - Ok(ForwardedRoomKeyEventContent { + Ok(ForwardedRoomKeyToDeviceEventContent { algorithm: self.algorithm, room_id: self.room_id, sender_key: self.sender_key, @@ -98,9 +98,9 @@ impl TryInto for ExportedRoomKey { } } -impl From for ExportedRoomKey { +impl From for ExportedRoomKey { /// Convert the content of a forwarded room key into a exported room key. - fn from(forwarded_key: ForwardedRoomKeyEventContent) -> Self { + fn from(forwarded_key: ForwardedRoomKeyToDeviceEventContent) -> Self { let mut sender_claimed_keys: BTreeMap = BTreeMap::new(); sender_claimed_keys.insert( DeviceKeyAlgorithm::Ed25519, diff --git a/matrix_sdk_crypto/src/olm/mod.rs b/matrix_sdk_crypto/src/olm/mod.rs index 407d360c..00d9a7aa 100644 --- a/matrix_sdk_crypto/src/olm/mod.rs +++ b/matrix_sdk_crypto/src/olm/mod.rs @@ -40,7 +40,7 @@ pub(crate) mod test { use crate::olm::{InboundGroupSession, ReadOnlyAccount, Session}; use matrix_sdk_common::{ api::r0::keys::SignedKey, - events::forwarded_room_key::ForwardedRoomKeyEventContent, + events::forwarded_room_key::ForwardedRoomKeyToDeviceEventContent, identifiers::{room_id, user_id, DeviceId, UserId}, }; use olm_rs::session::OlmMessage; @@ -237,7 +237,7 @@ pub(crate) mod test { .unwrap(); let export = inbound.export().await; - let export: ForwardedRoomKeyEventContent = export.try_into().unwrap(); + let export: ForwardedRoomKeyToDeviceEventContent = export.try_into().unwrap(); let imported = InboundGroupSession::from_export(export).unwrap(); diff --git a/matrix_sdk_crypto/src/verification/sas/helpers.rs b/matrix_sdk_crypto/src/verification/sas/helpers.rs index b58d744a..106727b8 100644 --- a/matrix_sdk_crypto/src/verification/sas/helpers.rs +++ b/matrix_sdk_crypto/src/verification/sas/helpers.rs @@ -21,7 +21,7 @@ use olm_rs::sas::OlmSas; use matrix_sdk_common::{ api::r0::to_device::DeviceIdOrAllDevices, events::{ - key::verification::{cancel::CancelCode, mac::MacEventContent}, + key::verification::{cancel::CancelCode, mac::MacToDeviceEventContent}, AnyToDeviceEventContent, EventType, ToDeviceEvent, }, identifiers::{DeviceId, DeviceKeyAlgorithm, DeviceKeyId, UserId}, @@ -159,7 +159,7 @@ pub fn receive_mac_event( sas: &OlmSas, ids: &SasIds, flow_id: &str, - event: &ToDeviceEvent, + event: &ToDeviceEvent, ) -> Result<(Vec, Vec), CancelCode> { let mut verified_devices = Vec::new(); let mut verified_identities = Vec::new(); @@ -270,7 +270,7 @@ fn extra_mac_info_send(ids: &SasIds, flow_id: &str) -> String { /// # Panics /// /// This will panic if the public key of the other side wasn't set. -pub fn get_mac_content(sas: &OlmSas, ids: &SasIds, flow_id: &str) -> MacEventContent { +pub fn get_mac_content(sas: &OlmSas, ids: &SasIds, flow_id: &str) -> MacToDeviceEventContent { let mut mac: BTreeMap = BTreeMap::new(); let key_id = DeviceKeyId::from_parts(DeviceKeyAlgorithm::Ed25519, ids.account.device_id()); @@ -291,7 +291,7 @@ pub fn get_mac_content(sas: &OlmSas, ids: &SasIds, flow_id: &str) -> MacEventCon .calculate_mac(&keys.join(","), &format!("{}KEY_IDS", &info)) .expect("Can't calculate SAS MAC"); - MacEventContent { + MacToDeviceEventContent { transaction_id: flow_id.to_owned(), keys, mac, diff --git a/matrix_sdk_crypto/src/verification/sas/mod.rs b/matrix_sdk_crypto/src/verification/sas/mod.rs index 476eadc2..d6f1322f 100644 --- a/matrix_sdk_crypto/src/verification/sas/mod.rs +++ b/matrix_sdk_crypto/src/verification/sas/mod.rs @@ -25,8 +25,8 @@ use matrix_sdk_common::{ api::r0::keys::upload_signatures::Request as SignatureUploadRequest, events::{ key::verification::{ - accept::AcceptEventContent, cancel::CancelCode, mac::MacEventContent, - start::StartEventContent, + accept::AcceptToDeviceEventContent, cancel::CancelCode, mac::MacToDeviceEventContent, + start::StartToDeviceEventContent, }, AnyToDeviceEvent, AnyToDeviceEventContent, ToDeviceEvent, }, @@ -122,7 +122,7 @@ impl Sas { other_device: ReadOnlyDevice, store: Arc>, other_identity: Option, - ) -> (Sas, StartEventContent) { + ) -> (Sas, StartToDeviceEventContent) { let (inner, content) = InnerSas::start( account.clone(), other_device.clone(), @@ -158,7 +158,7 @@ impl Sas { private_identity: PrivateCrossSigningIdentity, other_device: ReadOnlyDevice, store: Arc>, - event: &ToDeviceEvent, + event: &ToDeviceEvent, other_identity: Option, ) -> Result { let inner = InnerSas::from_start_event( @@ -554,7 +554,7 @@ impl InnerSas { account: ReadOnlyAccount, other_device: ReadOnlyDevice, other_identity: Option, - ) -> (InnerSas, StartEventContent) { + ) -> (InnerSas, StartToDeviceEventContent) { let sas = SasState::::new(account, other_device, other_identity); let content = sas.as_content(); (InnerSas::Created(sas), content) @@ -563,7 +563,7 @@ impl InnerSas { fn from_start_event( account: ReadOnlyAccount, other_device: ReadOnlyDevice, - event: &ToDeviceEvent, + event: &ToDeviceEvent, other_identity: Option, ) -> Result { match SasState::::from_start_event(account, other_device, event, other_identity) { @@ -572,7 +572,7 @@ impl InnerSas { } } - fn accept(&self) -> Option { + fn accept(&self) -> Option { if let InnerSas::Started(s) = self { Some(s.as_content()) } else { @@ -610,7 +610,7 @@ impl InnerSas { (InnerSas::Canceled(sas), Some(content)) } - fn confirm(self) -> (InnerSas, Option) { + fn confirm(self) -> (InnerSas, Option) { match self { InnerSas::KeyRecieved(s) => { let sas = s.confirm(); diff --git a/matrix_sdk_crypto/src/verification/sas/sas_state.rs b/matrix_sdk_crypto/src/verification/sas/sas_state.rs index 4065d2f7..90966008 100644 --- a/matrix_sdk_crypto/src/verification/sas/sas_state.rs +++ b/matrix_sdk_crypto/src/verification/sas/sas_state.rs @@ -25,13 +25,13 @@ use matrix_sdk_common::{ events::{ key::verification::{ accept::{ - AcceptEventContent, AcceptMethod, MSasV1Content as AcceptV1Content, + AcceptMethod, AcceptToDeviceEventContent, MSasV1Content as AcceptV1Content, MSasV1ContentInit as AcceptV1ContentInit, }, - cancel::{CancelCode, CancelEventContent}, - key::KeyEventContent, - mac::MacEventContent, - start::{MSasV1Content, MSasV1ContentInit, StartEventContent, StartMethod}, + cancel::{CancelCode, CancelToDeviceEventContent}, + key::KeyToDeviceEventContent, + mac::MacToDeviceEventContent, + start::{MSasV1Content, MSasV1ContentInit, StartMethod, StartToDeviceEventContent}, HashAlgorithm, KeyAgreementProtocol, MessageAuthenticationCode, ShortAuthenticationString, VerificationMethod, }, @@ -319,8 +319,8 @@ impl SasState { /// Get the content for the start event. /// /// The content needs to be sent to the other device. - pub fn as_content(&self) -> StartEventContent { - StartEventContent { + pub fn as_content(&self) -> StartToDeviceEventContent { + StartToDeviceEventContent { transaction_id: self.verification_flow_id.to_string(), from_device: self.device_id().into(), method: StartMethod::MSasV1( @@ -339,7 +339,7 @@ impl SasState { /// the other side. pub fn into_accepted( self, - event: &ToDeviceEvent, + event: &ToDeviceEvent, ) -> Result, SasState> { self.check_event(&event.sender, &event.content.transaction_id) .map_err(|c| self.clone().cancel(c))?; @@ -386,7 +386,7 @@ impl SasState { pub fn from_start_event( account: ReadOnlyAccount, other_device: ReadOnlyDevice, - event: &ToDeviceEvent, + event: &ToDeviceEvent, other_identity: Option, ) -> Result, SasState> { if let StartMethod::MSasV1(content) = &event.content.method { @@ -462,10 +462,10 @@ impl SasState { /// This should be sent out automatically if the SAS verification flow has /// been started because of a /// m.key.verification.request -> m.key.verification.ready flow. - pub fn as_content(&self) -> AcceptEventContent { + pub fn as_content(&self) -> AcceptToDeviceEventContent { let accepted_protocols = AcceptedProtocols::default(); - AcceptEventContent { + AcceptToDeviceEventContent { transaction_id: self.verification_flow_id.to_string(), method: AcceptMethod::MSasV1( AcceptV1ContentInit { @@ -494,7 +494,7 @@ impl SasState { /// anymore. pub fn into_key_received( self, - event: &mut ToDeviceEvent, + event: &mut ToDeviceEvent, ) -> Result, SasState> { self.check_event(&event.sender, &event.content.transaction_id) .map_err(|c| self.clone().cancel(c))?; @@ -535,7 +535,7 @@ impl SasState { /// anymore. pub fn into_key_received( self, - event: &mut ToDeviceEvent, + event: &mut ToDeviceEvent, ) -> Result, SasState> { self.check_event(&event.sender, &event.content.transaction_id) .map_err(|c| self.clone().cancel(c))?; @@ -575,8 +575,8 @@ impl SasState { /// Get the content for the key event. /// /// The content needs to be automatically sent to the other side. - pub fn as_content(&self) -> KeyEventContent { - KeyEventContent { + pub fn as_content(&self) -> KeyToDeviceEventContent { + KeyToDeviceEventContent { transaction_id: self.verification_flow_id.to_string(), key: self.inner.lock().unwrap().public_key(), } @@ -588,8 +588,8 @@ impl SasState { /// /// The content needs to be automatically sent to the other side if and only /// if we_started is false. - pub fn as_content(&self) -> KeyEventContent { - KeyEventContent { + pub fn as_content(&self) -> KeyToDeviceEventContent { + KeyToDeviceEventContent { transaction_id: self.verification_flow_id.to_string(), key: self.inner.lock().unwrap().public_key(), } @@ -632,7 +632,7 @@ impl SasState { /// the other side. pub fn into_mac_received( self, - event: &ToDeviceEvent, + event: &ToDeviceEvent, ) -> Result, SasState> { self.check_event(&event.sender, &event.content.transaction_id) .map_err(|c| self.clone().cancel(c))?; @@ -688,7 +688,7 @@ impl SasState { /// the other side. pub fn into_done( self, - event: &ToDeviceEvent, + event: &ToDeviceEvent, ) -> Result, SasState> { self.check_event(&event.sender, &event.content.transaction_id) .map_err(|c| self.clone().cancel(c))?; @@ -718,7 +718,7 @@ impl SasState { /// Get the content for the mac event. /// /// The content needs to be automatically sent to the other side. - pub fn as_content(&self) -> MacEventContent { + pub fn as_content(&self) -> MacToDeviceEventContent { get_mac_content( &self.inner.lock().unwrap(), &self.ids, @@ -780,7 +780,7 @@ impl SasState { /// /// The content needs to be automatically sent to the other side if it /// wasn't already sent. - pub fn as_content(&self) -> MacEventContent { + pub fn as_content(&self) -> MacToDeviceEventContent { get_mac_content( &self.inner.lock().unwrap(), &self.ids, @@ -829,7 +829,7 @@ impl Canceled { impl SasState { pub fn as_content(&self) -> AnyToDeviceEventContent { - AnyToDeviceEventContent::KeyVerificationCancel(CancelEventContent { + AnyToDeviceEventContent::KeyVerificationCancel(CancelToDeviceEventContent { transaction_id: self.verification_flow_id.to_string(), reason: self.state.reason.to_string(), code: self.state.cancel_code.clone(),