1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2024-11-04 17:08:52 +01:00

fix: improve code when skipping /state_ids

This commit is contained in:
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

View file

@ -1027,20 +1027,8 @@ pub fn handle_incoming_pdu<'a>(
.map_err(|_| "Failed talking to db".to_owned())?
.map(|shortstatehash| db.rooms.state_full_ids(shortstatehash).ok())
.flatten();
if let Some(mut state) = state {
if db
.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(
if let Some(state) = state {
let mut state = fetch_and_handle_events(
db,
origin,
&state.into_iter().collect::<Vec<_>>(),
@ -1061,8 +1049,15 @@ pub fn handle_incoming_pdu<'a>(
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?
}