From 0823506d05b63efe7ef3a3c6611f066f24ec5bc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20K=C3=B6sters?= Date: Mon, 16 Aug 2021 23:24:52 +0200 Subject: [PATCH] fix: don't load endless prev events and fix room join bug --- src/database/rooms.rs | 7 ++++++- src/server_server.rs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/database/rooms.rs b/src/database/rooms.rs index d648b7d..75251aa 100644 --- a/src/database/rooms.rs +++ b/src/database/rooms.rs @@ -1571,6 +1571,8 @@ impl Rooms { let shortstatekey = self.get_or_create_shortstatekey(&new_pdu.kind, &state_key, globals)?; + let new = self.compress_state_event(shortstatekey, &new_pdu.event_id, globals)?; + let replaces = states_parents .last() .map(|info| { @@ -1580,11 +1582,14 @@ impl Rooms { }) .unwrap_or_default(); + if Some(&new) == replaces { + return Ok(previous_shortstatehash.expect("must exist")); + } + // TODO: statehash with deterministic inputs let shortstatehash = globals.next_count()?; let mut statediffnew = HashSet::new(); - let new = self.compress_state_event(shortstatekey, &new_pdu.event_id, globals)?; statediffnew.insert(new); let mut statediffremoved = HashSet::new(); diff --git a/src/server_server.rs b/src/server_server.rs index a4bfda5..7a28e5d 100644 --- a/src/server_server.rs +++ b/src/server_server.rs @@ -907,7 +907,7 @@ pub async fn handle_incoming_pdu<'a>( if let Some(json) = json_opt.or_else(|| db.rooms.get_outlier_pdu_json(&prev_event_id).ok().flatten()) { - if incoming_pdu.origin_server_ts + if pdu.origin_server_ts > db.rooms .first_pdu_in_room(&room_id) .map_err(|_| "Error loading first room event.".to_owned())?