fix: don't load endless prev events and fix room join bug

This commit is contained in:
Timo Kösters 2021-08-16 23:24:52 +02:00
parent 2c3bee34a0
commit 0823506d05
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4
2 changed files with 7 additions and 2 deletions

View file

@ -1571,6 +1571,8 @@ impl Rooms {
let shortstatekey = let shortstatekey =
self.get_or_create_shortstatekey(&new_pdu.kind, &state_key, globals)?; 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 let replaces = states_parents
.last() .last()
.map(|info| { .map(|info| {
@ -1580,11 +1582,14 @@ impl Rooms {
}) })
.unwrap_or_default(); .unwrap_or_default();
if Some(&new) == replaces {
return Ok(previous_shortstatehash.expect("must exist"));
}
// TODO: statehash with deterministic inputs // TODO: statehash with deterministic inputs
let shortstatehash = globals.next_count()?; let shortstatehash = globals.next_count()?;
let mut statediffnew = HashSet::new(); let mut statediffnew = HashSet::new();
let new = self.compress_state_event(shortstatekey, &new_pdu.event_id, globals)?;
statediffnew.insert(new); statediffnew.insert(new);
let mut statediffremoved = HashSet::new(); let mut statediffremoved = HashSet::new();

View file

@ -907,7 +907,7 @@ pub async fn handle_incoming_pdu<'a>(
if let Some(json) = if let Some(json) =
json_opt.or_else(|| db.rooms.get_outlier_pdu_json(&prev_event_id).ok().flatten()) 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 > db.rooms
.first_pdu_in_room(&room_id) .first_pdu_in_room(&room_id)
.map_err(|_| "Error loading first room event.".to_owned())? .map_err(|_| "Error loading first room event.".to_owned())?