mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-13 04:06:54 +00:00
fix: Do not make late-arriving events forward extremities
This commit is contained in:
1 parent
7b3e3a26bb
commit
3efb66c76c
4 files changed
+27
-3
No files matched your search
@@ -0,0 +1 @@
|
||||
Events arriving after one of their children has already been backfilled are no longer used as forward extremities. Contributed by @eleboucher.
|
||||
@@ -154,9 +154,9 @@ impl super::Service {
|
||||
.stream()
|
||||
.fold(0_u8, |i, event_id| async move {
|
||||
if self.services.timeline.pdu_exists(event_id).await {
|
||||
i.expected_add(1)
|
||||
} else {
|
||||
i
|
||||
} else {
|
||||
i.expected_add(1)
|
||||
}
|
||||
})
|
||||
.await;
|
||||
|
||||
@@ -194,7 +194,24 @@ impl super::Service {
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.await;
|
||||
forward_extremities.push(incoming_pdu.event_id().to_owned());
|
||||
|
||||
// An event with a child is not a leaf, but a room with no extremities cannot be
|
||||
// written to, so it is added anyway when nothing else remains.
|
||||
let has_child = self
|
||||
.services
|
||||
.pdu_metadata
|
||||
.is_event_referenced(&incoming_pdu.room_id_or_hash(), incoming_pdu.event_id())
|
||||
.await;
|
||||
if !has_child || forward_extremities.is_empty() {
|
||||
if has_child {
|
||||
warn!(
|
||||
"Adding {} as an extremity despite its child, the room has no other leaves",
|
||||
incoming_pdu.event_id()
|
||||
);
|
||||
}
|
||||
forward_extremities.push(incoming_pdu.event_id().to_owned());
|
||||
}
|
||||
|
||||
debug!(
|
||||
"Retained {} extremities checked against {} prev_events",
|
||||
forward_extremities.len(),
|
||||
|
||||
@@ -213,6 +213,12 @@ impl super::Service {
|
||||
|
||||
drop(insert_lock);
|
||||
|
||||
// Backfilled events skip append_pdu, so this is the only place their
|
||||
// prev_events can be marked as referenced. See issue #2115.
|
||||
self.services
|
||||
.pdu_metadata
|
||||
.mark_as_referenced(&room_id, pdu.prev_events().map(AsRef::as_ref));
|
||||
|
||||
if pdu.kind == TimelineEventType::RoomMessage {
|
||||
let content: ExtractBody = pdu.get_content()?;
|
||||
if let Some(body) = content.body {
|
||||
|
||||
Reference in new issue
Block a user