mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-12-29 05:53:48 +03:00
fix: also fetch prev events that are outliers already
This commit is contained in:
parent
ecd1e45a44
commit
f9a2edc0dd
2 changed files with 26 additions and 11 deletions
|
@ -844,6 +844,19 @@ impl Rooms {
|
||||||
.transpose()
|
.transpose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the json of a pdu.
|
||||||
|
pub fn get_outlier_pdu_json(
|
||||||
|
&self,
|
||||||
|
event_id: &EventId,
|
||||||
|
) -> Result<Option<CanonicalJsonObject>> {
|
||||||
|
self.eventid_outlierpdu
|
||||||
|
.get(event_id.as_bytes())?
|
||||||
|
.map(|pdu| {
|
||||||
|
serde_json::from_slice(&pdu).map_err(|_| Error::bad_database("Invalid PDU in db."))
|
||||||
|
})
|
||||||
|
.transpose()
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the json of a pdu.
|
/// Returns the json of a pdu.
|
||||||
pub fn get_non_outlier_pdu_json(
|
pub fn get_non_outlier_pdu_json(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
@ -887,10 +887,10 @@ pub async fn handle_incoming_pdu<'a>(
|
||||||
let mut todo_outlier_stack = incoming_pdu.prev_events.clone();
|
let mut todo_outlier_stack = incoming_pdu.prev_events.clone();
|
||||||
let mut todo_timeline_stack = Vec::new();
|
let mut todo_timeline_stack = Vec::new();
|
||||||
while let Some(prev_event_id) = todo_outlier_stack.pop() {
|
while let Some(prev_event_id) = todo_outlier_stack.pop() {
|
||||||
if let Some((pdu, Some(json))) = fetch_and_handle_outliers(
|
if let Some((pdu, json_opt)) = fetch_and_handle_outliers(
|
||||||
db,
|
db,
|
||||||
origin,
|
origin,
|
||||||
&[prev_event_id],
|
&[prev_event_id.clone()],
|
||||||
&create_event,
|
&create_event,
|
||||||
&room_id,
|
&room_id,
|
||||||
pub_key_map,
|
pub_key_map,
|
||||||
|
@ -898,15 +898,17 @@ pub async fn handle_incoming_pdu<'a>(
|
||||||
.await
|
.await
|
||||||
.pop()
|
.pop()
|
||||||
{
|
{
|
||||||
if incoming_pdu.origin_server_ts
|
if let Some(json) = json_opt.or_else(|| db.rooms.get_outlier_pdu_json(&prev_event_id).ok().flatten()) {
|
||||||
> db.rooms
|
if incoming_pdu.origin_server_ts
|
||||||
.first_pdu_in_room(&room_id)
|
> db.rooms
|
||||||
.map_err(|_| "Error loading first room event.".to_owned())?
|
.first_pdu_in_room(&room_id)
|
||||||
.expect("Room exists")
|
.map_err(|_| "Error loading first room event.".to_owned())?
|
||||||
.origin_server_ts
|
.expect("Room exists")
|
||||||
{
|
.origin_server_ts
|
||||||
todo_outlier_stack.extend(pdu.prev_events.iter().cloned());
|
{
|
||||||
todo_timeline_stack.push((pdu, json));
|
todo_outlier_stack.extend(pdu.prev_events.iter().cloned());
|
||||||
|
todo_timeline_stack.push((pdu, json));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue