MSC3575: avoid double-processing rooms in case of overlapping ranges

This commit is contained in:
Lambda 2025-08-10 19:32:12 +00:00
parent ede39370a4
commit a72ff4f6e6

View file

@ -331,7 +331,7 @@ pub(crate) async fn sync_events_v4_route(
continue;
}
let mut new_known_rooms = BTreeSet::new();
let mut list_room_ids = BTreeSet::new();
let mut ops = Vec::new();
for (mut from, mut to) in list.ranges {
@ -348,15 +348,7 @@ pub(crate) async fn sync_events_v4_route(
..=to.try_into().unwrap_or(usize::MAX)]
.to_vec();
new_known_rooms.extend(room_ids.iter().cloned());
for room_id in &room_ids {
todo_rooms.entry(room_id.clone()).or_default().update(
list.room_details.required_state.clone(),
list.room_details.timeline_limit.unwrap_or(uint!(10)),
known_rooms.get(&list_id),
room_id,
);
}
list_room_ids.extend(room_ids.iter().cloned());
ops.push(sync_events::v4::SyncOp {
op: SlidingOp::Sync,
range: Some((from, to)),
@ -366,6 +358,15 @@ pub(crate) async fn sync_events_v4_route(
});
}
for room_id in &list_room_ids {
todo_rooms.entry(room_id.clone()).or_default().update(
list.room_details.required_state.clone(),
list.room_details.timeline_limit.unwrap_or(uint!(10)),
known_rooms.get(&list_id),
room_id,
);
}
lists.insert(
list_id.clone(),
sync_events::v4::SyncList {
@ -378,7 +379,7 @@ pub(crate) async fn sync_events_v4_route(
services().users.update_sync_known_rooms(
connection_key.clone(),
list_id,
new_known_rooms,
list_room_ids,
globalsince,
);
}