Skip to content

Commit

Permalink
fixup! Broadcast valid secrets we receive over m.secret.send
Browse files Browse the repository at this point in the history
  • Loading branch information
poljar committed Jul 19, 2023
1 parent e70f8d9 commit eedf737
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions crates/matrix-sdk-crypto/src/gossiping/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,8 +1045,6 @@ mod tests {
serde::Raw,
user_id, DeviceId, RoomId, UserId,
};
#[cfg(feature = "automatic-room-key-forwarding")]
use serde::{de::DeserializeOwned, Serialize};
use serde_json::json;
use tokio::sync::Mutex;

Expand All @@ -1055,16 +1053,14 @@ mod tests {
use crate::{
gossiping::KeyForwardDecision,
olm::OutboundGroupSession,
store::Changes,
types::{
events::{
forwarded_room_key::ForwardedRoomKeyContent, olm_v1::AnyDecryptedOlmEvent,
olm_v1::DecryptedOlmV1Event, room::encrypted::EncryptedToDeviceEvent, EventType,
ToDeviceEvent,
olm_v1::DecryptedOlmV1Event,
},
EventEncryptionAlgorithm,
},
EncryptionSettings, OutgoingRequest, OutgoingRequests,
EncryptionSettings, OutgoingRequests,
};
use crate::{
identities::{LocalTrust, ReadOnlyDevice},
Expand All @@ -1074,6 +1070,8 @@ mod tests {
types::events::room::encrypted::{EncryptedEvent, RoomEncryptedEventContent},
verification::VerificationMachine,
};
#[cfg(any(feature = "automatic-room-key-forwarding", feature = "backups_v1"))]
use crate::{store::Changes, types::events::room::encrypted::EncryptedToDeviceEvent};

fn alice_id() -> &'static UserId {
user_id!("@alice:example.org")
Expand Down Expand Up @@ -1227,10 +1225,10 @@ mod tests {
(alice_machine, alice_account, group_session, bob_machine)
}

#[cfg(feature = "automatic-room-key-forwarding")]
#[cfg(any(feature = "automatic-room-key-forwarding", feature = "backups_v1"))]
fn extract_content<'a>(
recipient: &UserId,
request: &'a OutgoingRequest,
request: &'a crate::OutgoingRequest,
) -> &'a Raw<ruma::events::AnyToDeviceEventContent> {
request
.request()
Expand Down Expand Up @@ -1260,21 +1258,24 @@ mod tests {
}
}

#[cfg(feature = "automatic-room-key-forwarding")]
#[cfg(any(feature = "automatic-room-key-forwarding", feature = "backups_v1"))]
fn request_to_event<C>(
recipient: &UserId,
sender: &UserId,
request: &OutgoingRequest,
) -> ToDeviceEvent<C>
request: &crate::OutgoingRequest,
) -> crate::types::events::ToDeviceEvent<C>
where
C: EventType + DeserializeOwned + Serialize + std::fmt::Debug,
C: crate::types::events::EventType
+ serde::de::DeserializeOwned
+ serde::ser::Serialize
+ std::fmt::Debug,
{
let content = extract_content(recipient, request);
let content: C = content.deserialize_as().unwrap_or_else(|_| {
panic!("We can always deserialize the to-device event content {content:?}")
});

ToDeviceEvent::new(sender.to_owned(), content)
crate::types::events::ToDeviceEvent::new(sender.to_owned(), content)
}

#[async_test]
Expand Down

0 comments on commit eedf737

Please sign in to comment.