fix: improve code when skipping /state_ids
parent
08a3326431
commit
80533bfab2
|
@ -1027,42 +1027,37 @@ 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
|
db,
|
||||||
.get_pdu(prev_event)
|
origin,
|
||||||
.ok()
|
&state.into_iter().collect::<Vec<_>>(),
|
||||||
.flatten()
|
&room_id,
|
||||||
.ok_or_else(|| "Could not find prev event, but we know the state.".to_owned())?
|
pub_key_map,
|
||||||
.state_key
|
)
|
||||||
.is_some()
|
.await
|
||||||
{
|
.map_err(|_| "Failed to fetch state events locally".to_owned())?
|
||||||
state.insert(prev_event.clone());
|
.into_iter()
|
||||||
}
|
.map(|pdu| {
|
||||||
state_at_incoming_event = Some(
|
(
|
||||||
fetch_and_handle_events(
|
|
||||||
db,
|
|
||||||
origin,
|
|
||||||
&state.into_iter().collect::<Vec<_>>(),
|
|
||||||
&room_id,
|
|
||||||
pub_key_map,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map_err(|_| "Failed to fetch state events locally".to_owned())?
|
|
||||||
.into_iter()
|
|
||||||
.map(|pdu| {
|
|
||||||
(
|
(
|
||||||
(
|
pdu.kind.clone(),
|
||||||
pdu.kind.clone(),
|
pdu.state_key
|
||||||
pdu.state_key
|
.clone()
|
||||||
.clone()
|
.expect("events from state_full_ids are state events"),
|
||||||
.expect("events from state_full_ids are state events"),
|
),
|
||||||
),
|
pdu,
|
||||||
pdu,
|
)
|
||||||
)
|
})
|
||||||
})
|
.collect::<HashMap<_, _>>();
|
||||||
.collect(),
|
|
||||||
);
|
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?
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue