Merge branch 'master' into sas-verification

master
Damir Jelić 2020-07-25 10:31:20 +02:00
commit 094b2f90d6
5 changed files with 32 additions and 48 deletions

View File

@ -966,18 +966,14 @@ impl Client {
/// # use futures::executor::block_on;
/// # use matrix_sdk::identifiers::RoomId;
/// # use std::convert::TryFrom;
/// use matrix_sdk::events::room::message::{FormattedBody, MessageEventContent, TextMessageEventContent};
/// use matrix_sdk::events::room::message::{MessageEventContent, TextMessageEventContent};
/// # block_on(async {
/// # let homeserver = Url::parse("http://localhost:8080").unwrap();
/// # let mut client = Client::new(homeserver).unwrap();
/// # let room_id = RoomId::try_from("!test:localhost").unwrap();
/// use matrix_sdk_common::uuid::Uuid;
///
/// let content = MessageEventContent::Text(TextMessageEventContent {
/// body: "Hello world".to_owned(),
/// formatted: None,
/// relates_to: None,
/// });
/// let content = MessageEventContent::Text(TextMessageEventContent::plain("Hello world"));
/// let txn_id = Uuid::new_v4();
/// client.room_send(&room_id, content, Some(txn_id)).await.unwrap();
/// # })

View File

@ -469,13 +469,11 @@ impl BaseClient {
// a store path was provided.
if self.state_store.read().await.is_none() {
#[cfg(not(target_arch = "wasm32"))]
{
if let Some(path) = &*self.store_path {
let store = JsonStore::open(path)?;
*self.state_store.write().await = Some(Box::new(store));
}
}
}
self.sync_with_state_store(&session).await?;
@ -719,7 +717,6 @@ impl BaseClient {
#[allow(unused_mut)]
Ok(mut e) => {
#[cfg(feature = "encryption")]
{
if let AnySyncRoomEvent::Message(AnySyncMessageEvent::RoomEncrypted(
ref mut encrypted_event,
)) = e
@ -727,8 +724,7 @@ impl BaseClient {
let mut olm = self.olm.lock().await;
if let Some(o) = &mut *olm {
if let Ok(decrypted) =
o.decrypt_room_event(&encrypted_event, room_id).await
if let Ok(decrypted) = o.decrypt_room_event(&encrypted_event, room_id).await
{
if let Ok(d) = decrypted.deserialize() {
e = d
@ -737,7 +733,6 @@ impl BaseClient {
}
}
}
}
let room_lock = self.get_or_create_joined_room(&room_id).await?;
let mut room = room_lock.write().await;
@ -1199,10 +1194,9 @@ impl BaseClient {
// send the `prev_content` field as part of the unsigned field.
if let AnyStrippedStateEvent::RoomMember(_) = &mut e {
if let Some(raw_content) = stripped_deserialize_prev_content(event) {
let prev_content = match raw_content.prev_content {
Some(json) => json.deserialize().ok(),
None => None,
};
let prev_content = raw_content
.prev_content
.and_then(|json| json.deserialize().ok());
self.emit_stripped_state_event(
&room_id,
&e,

View File

@ -17,7 +17,7 @@ js_int = "0.1.8"
[dependencies.ruma]
git = "https://github.com/ruma/ruma"
features = ["client-api"]
rev = "9190bff1d03fb188aa1d24502129f9dd19a824e6"
rev = "ea2992a4120d34495d6f07f141350d8f2a3429d3"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
uuid = { version = "0.8.1", features = ["v4"] }

View File

@ -302,18 +302,14 @@ impl OlmMachine {
for (user_id, user_devices) in &response.one_time_keys {
for (device_id, key_map) in user_devices {
let device: Device = match self.store.get_device(&user_id, device_id).await {
Ok(d) => {
if let Some(d) = d {
d
} else {
Ok(Some(d)) => d,
Ok(None) => {
warn!(
"Tried to create an Olm session for {} {}, but \
the device is unknown",
"Tried to create an Olm session for {} {}, but the device is unknown",
user_id, device_id
);
continue;
}
}
Err(e) => {
warn!(
"Tried to create an Olm session for {} {}, but \
@ -1683,7 +1679,7 @@ mod test {
let plaintext = "It is a secret to everybody";
let content = MessageEventContent::Text(TextMessageEventContent::new_plain(plaintext));
let content = MessageEventContent::Text(TextMessageEventContent::plain(plaintext));
let encrypted_content = alice.encrypt(&room_id, content.clone()).await.unwrap();

View File

@ -37,10 +37,7 @@ pub use olm_rs::{
use matrix_sdk_common::{
events::{
room::{
encrypted::{EncryptedEventContent, MegolmV1AesSha2Content},
message::MessageEventContent,
},
room::{encrypted::EncryptedEventContent, message::MessageEventContent},
Algorithm, AnySyncRoomEvent, EventJson, EventType, SyncMessageEvent,
},
identifiers::{DeviceId, RoomId},
@ -332,14 +329,15 @@ impl OutboundGroupSession {
let ciphertext = self.encrypt_helper(plaintext).await;
EncryptedEventContent::MegolmV1AesSha2(MegolmV1AesSha2Content::new(
EncryptedEventContent::MegolmV1AesSha2(
matrix_sdk_common::events::room::encrypted::MegolmV1AesSha2ContentInit {
ciphertext,
sender_key: self.account_identity_keys.curve25519().to_owned(),
session_id: self.session_id().to_owned(),
device_id: (&*self.device_id).to_owned(),
},
))
}
.into(),
)
}
/// Check if the session has expired and if it should be rotated.