fix: improve code when skipping /state_ids

next
Timo Kösters 2021-07-20 22:06:42 +02:00
parent 08a3326431
commit 80533bfab2
No known key found for this signature in database
GPG Key ID: 24DA7517711A2BA4
1 changed files with 30 additions and 35 deletions

View File

@ -1027,20 +1027,8 @@ pub fn handle_incoming_pdu<'a>(
.map_err(|_| "Failed talking to db".to_owned())? .map_err(|_| "Failed talking to db".to_owned())?
.map(|shortstatehash| db.rooms.state_full_ids(shortstatehash).ok()) .map(|shortstatehash| db.rooms.state_full_ids(shortstatehash).ok())
.flatten(); .flatten();
if let Some(mut state) = state { if let Some(state) = state {
if db let mut state = fetch_and_handle_events(
.rooms
.get_pdu(prev_event)
.ok()
.flatten()
.ok_or_else(|| "Could not find prev event, but we know the state.".to_owned())?
.state_key
.is_some()
{
state.insert(prev_event.clone());
}
state_at_incoming_event = Some(
fetch_and_handle_events(
db, db,
origin, origin,
&state.into_iter().collect::<Vec<_>>(), &state.into_iter().collect::<Vec<_>>(),
@ -1061,8 +1049,15 @@ pub fn handle_incoming_pdu<'a>(
pdu, pdu,
) )
}) })
.collect(), .collect::<HashMap<_, _>>();
);
let prev_pdu = db.rooms.get_pdu(prev_event).ok().flatten().ok_or_else(|| {
"Could not find prev event, but we know the state.".to_owned()
})?;
if let Some(state_key) = &prev_pdu.state_key {
state.insert((prev_pdu.kind.clone(), state_key.clone()), prev_pdu);
}
} }
// TODO: set incoming_auth_events? // TODO: set incoming_auth_events?
} }