bump ruma to 24154195a00390a33542603b968e94022487587c

This commit is contained in:
Kévin Commaille 2021-05-07 13:22:32 +02:00
parent 8dbbacfbe6
commit b8017b1fb0
No known key found for this signature in database
GPG key ID: 296D60AE1E61661C
6 changed files with 44 additions and 24 deletions

View file

@ -21,7 +21,7 @@ async-trait = "0.1.42"
[dependencies.ruma]
version = "0.0.3"
git = "https://github.com/ruma/ruma"
rev = "1e005f576e4640ee5ce6e357bcf33293819502d1"
rev = "24154195a00390a33542603b968e94022487587c"
features = ["client-api-c", "compat", "unstable-pre-spec"]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]

View file

@ -32,7 +32,8 @@ use matrix_sdk_common::{
assign,
deserialized_responses::{AlgorithmInfo, EncryptionInfo, SyncRoomEvent, VerificationState},
events::{
room::encrypted::EncryptedEventContent, room_key::RoomKeyEventContent,
room::encrypted::{EncryptedEventContent, EncryptedEventScheme},
room_key::RoomKeyEventContent,
AnyMessageEventContent, AnyToDeviceEvent, SyncMessageEvent, ToDeviceEvent,
},
identifiers::{
@ -939,8 +940,8 @@ impl OlmMachine {
event: &SyncMessageEvent<EncryptedEventContent>,
room_id: &RoomId,
) -> MegolmResult<(Option<OutgoingRequest>, OutgoingRequest)> {
let content = match &event.content {
EncryptedEventContent::MegolmV1AesSha2(c) => c,
let content = match &event.content.scheme {
EncryptedEventScheme::MegolmV1AesSha2(c) => c,
_ => return Err(EventError::UnsupportedAlgorithm.into()),
};
@ -1000,8 +1001,8 @@ impl OlmMachine {
event: &SyncMessageEvent<EncryptedEventContent>,
room_id: &RoomId,
) -> MegolmResult<SyncRoomEvent> {
let content = match &event.content {
EncryptedEventContent::MegolmV1AesSha2(c) => c,
let content = match &event.content.scheme {
EncryptedEventScheme::MegolmV1AesSha2(c) => c,
_ => return Err(EventError::UnsupportedAlgorithm.into()),
};

View file

@ -35,7 +35,10 @@ use matrix_sdk_common::{
upload_keys, upload_signatures::Request as SignatureUploadRequest, OneTimeKey, SignedKey,
},
encryption::DeviceKeys,
events::{room::encrypted::EncryptedEventContent, AnyToDeviceEvent},
events::{
room::encrypted::{EncryptedEventContent, EncryptedEventScheme},
AnyToDeviceEvent,
},
identifiers::{
DeviceId, DeviceIdBox, DeviceKeyAlgorithm, DeviceKeyId, EventEncryptionAlgorithm, RoomId,
UserId,
@ -124,7 +127,8 @@ impl Account {
) -> OlmResult<OlmDecryptionInfo> {
debug!("Decrypting to-device event");
let content = if let EncryptedEventContent::OlmV1Curve25519AesSha2(c) = &event.content {
let content = if let EncryptedEventScheme::OlmV1Curve25519AesSha2(c) = &event.content.scheme
{
c
} else {
warn!("Error, unsupported encryption algorithm");
@ -1046,7 +1050,7 @@ impl ReadOnlyAccount {
.encrypt(&device, EventType::Dummy, json!({}))
.await
.unwrap();
let content = if let EncryptedEventContent::OlmV1Curve25519AesSha2(c) = message {
let content = if let EncryptedEventScheme::OlmV1Curve25519AesSha2(c) = message.scheme {
c
} else {
panic!("Invalid encrypted event algorithm");

View file

@ -35,7 +35,10 @@ pub use olm_rs::{
use matrix_sdk_common::{
events::{
forwarded_room_key::ForwardedRoomKeyToDeviceEventContent,
room::{encrypted::EncryptedEventContent, history_visibility::HistoryVisibility},
room::{
encrypted::{EncryptedEventContent, EncryptedEventScheme},
history_visibility::HistoryVisibility,
},
AnySyncRoomEvent, SyncMessageEvent,
},
identifiers::{DeviceKeyAlgorithm, EventEncryptionAlgorithm, RoomId},
@ -305,8 +308,8 @@ impl InboundGroupSession {
&self,
event: &SyncMessageEvent<EncryptedEventContent>,
) -> MegolmResult<(Raw<AnySyncRoomEvent>, u32)> {
let content = match &event.content {
EncryptedEventContent::MegolmV1AesSha2(c) => c,
let content = match &event.content.scheme {
EncryptedEventScheme::MegolmV1AesSha2(c) => c,
_ => return Err(EventError::UnsupportedAlgorithm.into()),
};
@ -340,7 +343,7 @@ impl InboundGroupSession {
.flatten()
{
if !decrypted_content.contains_key("m.relates_to") {
if let Some(relation) = &content.relates_to {
if let Some(relation) = &event.content.relates_to {
decrypted_content.insert(
"m.relates_to".to_owned(),
serde_json::to_value(relation).unwrap_or_default(),

View file

@ -16,8 +16,7 @@ use dashmap::DashMap;
use matrix_sdk_common::{
api::r0::to_device::DeviceIdOrAllDevices,
events::room::{
encrypted::{MegolmV1AesSha2Content, MegolmV1AesSha2ContentInit},
history_visibility::HistoryVisibility,
encrypted::MegolmV1AesSha2ContentInit, history_visibility::HistoryVisibility,
message::Relation,
},
uuid::Uuid,
@ -36,7 +35,10 @@ use tracing::{debug, error, trace};
use matrix_sdk_common::{
events::{
room::{encrypted::EncryptedEventContent, encryption::EncryptionEventContent},
room::{
encrypted::{EncryptedEventContent, EncryptedEventScheme},
encryption::EncryptionEventContent,
},
AnyMessageEventContent, EventContent,
},
identifiers::{DeviceId, DeviceIdBox, EventEncryptionAlgorithm, RoomId, UserId},
@ -306,7 +308,7 @@ impl OutboundGroupSession {
let ciphertext = self.encrypt_helper(plaintext).await;
let mut encrypted_content: MegolmV1AesSha2Content = MegolmV1AesSha2ContentInit {
let encrypted_content = MegolmV1AesSha2ContentInit {
ciphertext,
sender_key: self.account_identity_keys.curve25519().to_owned(),
session_id: self.session_id().to_owned(),
@ -314,9 +316,10 @@ impl OutboundGroupSession {
}
.into();
encrypted_content.relates_to = relates_to;
EncryptedEventContent::MegolmV1AesSha2(encrypted_content)
EncryptedEventContent::new(
EncryptedEventScheme::MegolmV1AesSha2(encrypted_content),
relates_to,
)
}
/// Check if the session has expired and if it should be rotated.

View file

@ -16,7 +16,10 @@ use std::{collections::BTreeMap, fmt, sync::Arc};
use matrix_sdk_common::{
events::{
room::encrypted::{CiphertextInfo, EncryptedEventContent, OlmV1Curve25519AesSha2Content},
room::encrypted::{
CiphertextInfo, EncryptedEventContent, EncryptedEventScheme,
OlmV1Curve25519AesSha2Content,
},
EventType,
},
identifiers::{DeviceId, DeviceKeyAlgorithm, UserId},
@ -118,6 +121,11 @@ impl Session {
.get_key(DeviceKeyAlgorithm::Ed25519)
.ok_or(EventError::MissingSigningKey)?;
let relates_to = content
.get("m.relates_to")
.cloned()
.and_then(|v| serde_json::from_value(v).ok());
let payload = json!({
"sender": self.user_id.as_str(),
"sender_device": self.device_id.as_ref(),
@ -141,11 +149,12 @@ impl Session {
let mut content = BTreeMap::new();
content.insert((&*self.sender_key).to_owned(), ciphertext);
Ok(EncryptedEventContent::OlmV1Curve25519AesSha2(
OlmV1Curve25519AesSha2Content::new(
Ok(EncryptedEventContent::new(
EncryptedEventScheme::OlmV1Curve25519AesSha2(OlmV1Curve25519AesSha2Content::new(
content,
self.our_identity_keys.curve25519().to_string(),
),
)),
relates_to,
))
}