Browse Source

fix: e2ee verification

locks
Timo Kösters 5 years ago
parent
commit
1bba271916
No known key found for this signature in database
GPG Key ID: 24DA7517711A2BA4
  1. 4
      src/client_server/sync.rs
  2. 3
      src/client_server/to_device.rs
  3. 2
      src/database/abstraction/sled.rs
  4. 2
      src/database/rooms.rs
  5. 9
      src/database/users.rs

4
src/client_server/sync.rs

@ -89,7 +89,9 @@ pub async fn sync_events_route(
let we_have_to_wait = rx.borrow().is_none(); let we_have_to_wait = rx.borrow().is_none();
if we_have_to_wait { if we_have_to_wait {
let _ = rx.changed().await; if let Err(e) = rx.changed().await {
error!("Error waiting for sync: {}", e);
}
} }
let result = match rx let result = match rx

3
src/client_server/to_device.rs

@ -19,7 +19,9 @@ pub async fn send_event_to_device_route(
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let sender_device = body.sender_device.as_deref(); let sender_device = body.sender_device.as_deref();
// TODO: uncomment when https://github.com/vector-im/element-android/issues/3589 is solved
// Check if this is a new transaction id // Check if this is a new transaction id
/*
if db if db
.transaction_ids .transaction_ids
.existing_txnid(sender_user, sender_device, &body.txn_id)? .existing_txnid(sender_user, sender_device, &body.txn_id)?
@ -27,6 +29,7 @@ pub async fn send_event_to_device_route(
{ {
return Ok(send_event_to_device::Response.into()); return Ok(send_event_to_device::Response.into());
} }
*/
for (target_user_id, map) in &body.messages { for (target_user_id, map) in &body.messages {
for (target_device_id_maybe, event) in map { for (target_device_id_maybe, event) in map {

2
src/database/abstraction/sled.rs

@ -64,7 +64,7 @@ impl Tree for SledEngineTree {
backwards: bool, backwards: bool,
) -> Box<dyn Iterator<Item = (Vec<u8>, Vec<u8>)> + Send> { ) -> Box<dyn Iterator<Item = (Vec<u8>, Vec<u8>)> + Send> {
let iter = if backwards { let iter = if backwards {
self.0.range(..from) self.0.range(..=from)
} else { } else {
self.0.range(from..) self.0.range(from..)
}; };

2
src/database/rooms.rs

@ -1497,7 +1497,7 @@ impl Rooms {
prefix.push(0xff); prefix.push(0xff);
let mut current = prefix.clone(); let mut current = prefix.clone();
current.extend_from_slice(&until.to_be_bytes()); current.extend_from_slice(&(until.saturating_sub(1)).to_be_bytes()); // -1 because we don't want event at `until`
let current: &[u8] = &current; let current: &[u8] = &current;

9
src/database/users.rs

@ -726,10 +726,9 @@ impl Users {
json.insert("sender".to_owned(), sender.to_string().into()); json.insert("sender".to_owned(), sender.to_string().into());
json.insert("content".to_owned(), content); json.insert("content".to_owned(), content);
self.todeviceid_events.insert( let value = serde_json::to_vec(&json).expect("Map::to_vec always works");
&key,
&serde_json::to_vec(&json).expect("Map::to_vec always works"), self.todeviceid_events.insert(&key, &value)?;
)?;
Ok(()) Ok(())
} }
@ -774,7 +773,7 @@ impl Users {
for (key, _) in self for (key, _) in self
.todeviceid_events .todeviceid_events
.iter_from(&last, true) .iter_from(&last, true) // this includes last
.take_while(move |(k, _)| k.starts_with(&prefix)) .take_while(move |(k, _)| k.starts_with(&prefix))
.map(|(key, _)| { .map(|(key, _)| {
Ok::<_, Error>(( Ok::<_, Error>((

Loading…
Cancel
Save