crypto: Return a EncryptedEventContent when encrypting using Olm instead of a specific one.

master
Damir Jelić 2020-04-22 15:38:42 +02:00
parent b56b720c0c
commit 4369d0b854
1 changed files with 10 additions and 8 deletions

View File

@ -989,7 +989,7 @@ impl OlmMachine {
recipient_device: &Device, recipient_device: &Device,
event_type: EventType, event_type: EventType,
content: Value, content: Value,
) -> Result<OlmV1Curve25519AesSha2Content> { ) -> Result<EncryptedEventContent> {
let identity_keys = self.account.identity_keys(); let identity_keys = self.account.identity_keys();
let recipient_signing_key = recipient_device let recipient_signing_key = recipient_device
@ -1030,11 +1030,13 @@ impl OlmMachine {
content.insert(recipient_sender_key.to_owned(), ciphertext); content.insert(recipient_sender_key.to_owned(), ciphertext);
Ok(OlmV1Curve25519AesSha2Content { Ok(EncryptedEventContent::OlmV1Curve25519AesSha2(
algorithm: Algorithm::OlmV1Curve25519AesSha2, OlmV1Curve25519AesSha2Content {
sender_key: identity_keys.curve25519().to_owned(), algorithm: Algorithm::OlmV1Curve25519AesSha2,
ciphertext: content, sender_key: identity_keys.curve25519().to_owned(),
}) ciphertext: content,
},
))
} }
/// Should the client share a group session for the given room. /// Should the client share a group session for the given room.
@ -1137,12 +1139,12 @@ impl OlmMachine {
user_messages.insert( user_messages.insert(
DeviceIdOrAllDevices::DeviceId(device.device_id().clone()), DeviceIdOrAllDevices::DeviceId(device.device_id().clone()),
encrypted_content, MessageEventContent::Encrypted(encrypted_content),
); );
} }
message_vec.push(ToDeviceRequest { message_vec.push(ToDeviceRequest {
event_type: "m.room.encrypted".to_owned(), event_type: EventType::RoomEncrypted,
txn_id: Uuid::new_v4().to_string(), txn_id: Uuid::new_v4().to_string(),
messages, messages,
}); });