crypto: Copy the relates to field to the unencrypted content when encrypting
parent
d9e5a17ab0
commit
5babd71341
|
@ -13,7 +13,14 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use dashmap::{DashMap, DashSet};
|
use dashmap::{DashMap, DashSet};
|
||||||
use matrix_sdk_common::{api::r0::to_device::DeviceIdOrAllDevices, uuid::Uuid};
|
use matrix_sdk_common::{
|
||||||
|
api::r0::to_device::DeviceIdOrAllDevices,
|
||||||
|
events::room::{
|
||||||
|
encrypted::{MegolmV1AesSha2Content, MegolmV1AesSha2ContentInit},
|
||||||
|
message::Relation,
|
||||||
|
},
|
||||||
|
uuid::Uuid,
|
||||||
|
};
|
||||||
use std::{
|
use std::{
|
||||||
cmp::min,
|
cmp::min,
|
||||||
fmt,
|
fmt,
|
||||||
|
@ -240,19 +247,31 @@ impl OutboundGroupSession {
|
||||||
"type": content.event_type(),
|
"type": content.event_type(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let relates_to: Option<Relation> = json_content
|
||||||
|
.get("content")
|
||||||
|
.map(|c| {
|
||||||
|
c.get("m.relates_to")
|
||||||
|
.cloned()
|
||||||
|
.map(|r| serde_json::from_value(r).ok())
|
||||||
|
})
|
||||||
|
.flatten()
|
||||||
|
.flatten();
|
||||||
|
|
||||||
let plaintext = json_content.to_string();
|
let plaintext = json_content.to_string();
|
||||||
|
|
||||||
let ciphertext = self.encrypt_helper(plaintext).await;
|
let ciphertext = self.encrypt_helper(plaintext).await;
|
||||||
|
|
||||||
EncryptedEventContent::MegolmV1AesSha2(
|
let mut encrypted_content: MegolmV1AesSha2Content = MegolmV1AesSha2ContentInit {
|
||||||
matrix_sdk_common::events::room::encrypted::MegolmV1AesSha2ContentInit {
|
ciphertext,
|
||||||
ciphertext,
|
sender_key: self.account_identity_keys.curve25519().to_owned(),
|
||||||
sender_key: self.account_identity_keys.curve25519().to_owned(),
|
session_id: self.session_id().to_owned(),
|
||||||
session_id: self.session_id().to_owned(),
|
device_id: (&*self.device_id).to_owned(),
|
||||||
device_id: (&*self.device_id).to_owned(),
|
}
|
||||||
}
|
.into();
|
||||||
.into(),
|
|
||||||
)
|
encrypted_content.relates_to = relates_to;
|
||||||
|
|
||||||
|
EncryptedEventContent::MegolmV1AesSha2(encrypted_content)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if the session has expired and if it should be rotated.
|
/// Check if the session has expired and if it should be rotated.
|
||||||
|
|
Loading…
Reference in New Issue