mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-13 04:06:54 +00:00
fix: Only consider accepted PDUs in extremity consistency check
This commit is contained in:
2 files changed
+26
-10
No files matched your search
@@ -1020,19 +1020,23 @@ async fn consistency_check_extremity_tracker(services: &Services) -> Result {
|
||||
.count()
|
||||
.await;
|
||||
|
||||
if extremity_count > 20
|
||||
{
|
||||
if extremity_count > 20 {
|
||||
warn!(%extremity_count, "Room {room_id} has an abnormal number of forward extremities, attempting to re-calculate to a sane value. This might take a while.");
|
||||
services
|
||||
.rooms
|
||||
.state
|
||||
.get_forward_extremities(&room_id)
|
||||
.ready_for_each(|event_id| services.rooms.state.remove_forward_extremity(&room_id, &event_id))
|
||||
.ready_for_each(|event_id| {
|
||||
services
|
||||
.rooms
|
||||
.state
|
||||
.remove_forward_extremity(&room_id, &event_id);
|
||||
})
|
||||
.await;
|
||||
} else if extremity_count == 0 {
|
||||
warn!(
|
||||
"Room {room_id} is missing extremity information, recalculating. This may take a \
|
||||
long time if this room is old."
|
||||
"Room {room_id} is missing extremity information, recalculating. This may take \
|
||||
a long time if this room is old."
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1044,6 +1048,14 @@ async fn consistency_check_extremity_tracker(services: &Services) -> Result {
|
||||
.for_each(|(_, pdu)| {
|
||||
let room_id = &room_id;
|
||||
async move {
|
||||
if !services
|
||||
.rooms
|
||||
.pdu_metadata
|
||||
.is_event_accepted(pdu.event_id())
|
||||
.await
|
||||
{
|
||||
return;
|
||||
}
|
||||
services
|
||||
.rooms
|
||||
.timeline
|
||||
|
||||
@@ -432,6 +432,15 @@ impl Service {
|
||||
) where
|
||||
I: Iterator<Item = &'a EventId> + Send + 'a,
|
||||
{
|
||||
self.clear_forward_extremities(room_id).await;
|
||||
|
||||
for event_id in event_ids {
|
||||
let key = (room_id, event_id);
|
||||
self.db.roomid_pduleaves.put_raw(key, event_id);
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn clear_forward_extremities(&self, room_id: &RoomId) {
|
||||
let prefix = (room_id, Interfix);
|
||||
self.db
|
||||
.roomid_pduleaves
|
||||
@@ -439,11 +448,6 @@ impl Service {
|
||||
.ignore_err()
|
||||
.ready_for_each(|key| self.db.roomid_pduleaves.remove(key))
|
||||
.await;
|
||||
|
||||
for event_id in event_ids {
|
||||
let key = (room_id, event_id);
|
||||
self.db.roomid_pduleaves.put_raw(key, event_id);
|
||||
}
|
||||
}
|
||||
|
||||
/// Appends a forward extremity to the extremity tracker.
|
||||
|
||||
Reference in new issue
Block a user