MSC3575: make known rooms global per connection rather than per list

This commit is contained in:
Lambda 2025-08-10 19:00:34 +00:00
parent a72ff4f6e6
commit b4f6c88e57
2 changed files with 9 additions and 33 deletions

View file

@ -39,16 +39,15 @@ impl TodoRoom {
&mut self,
required_state: Vec<(StateEventType, String)>,
timeline_limit: UInt,
known_rooms: Option<&BTreeMap<OwnedRoomId, u64>>,
known_rooms: &BTreeMap<OwnedRoomId, u64>,
room_id: &RoomId,
) {
self.required_state_request.extend(required_state);
self.timeline_limit =
self.timeline_limit.max(u64::from(timeline_limit).min(100));
// 0 means unknown because it got out of date
self.roomsince = self.roomsince.min(
known_rooms.and_then(|k| k.get(room_id)).copied().unwrap_or(0),
);
self.roomsince =
self.roomsince.min(known_rooms.get(room_id).copied().unwrap_or(0));
}
}
impl Default for TodoRoom {
@ -362,7 +361,7 @@ pub(crate) async fn sync_events_v4_route(
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),
&known_rooms,
room_id,
);
}
@ -375,16 +374,8 @@ pub(crate) async fn sync_events_v4_route(
.unwrap_or(UInt::MAX),
},
);
services().users.update_sync_known_rooms(
connection_key.clone(),
list_id,
list_room_ids,
globalsince,
);
}
let mut known_subscription_rooms = BTreeSet::new();
for (room_id, room) in &body.room_subscriptions {
if !services().rooms.metadata.exists(room_id)? {
continue;
@ -392,20 +383,14 @@ pub(crate) async fn sync_events_v4_route(
todo_rooms.entry(room_id.clone()).or_default().update(
room.required_state.clone(),
room.timeline_limit.unwrap_or(uint!(10)),
known_rooms.get("subscriptions"),
&known_rooms,
room_id,
);
known_subscription_rooms.insert(room_id.clone());
}
for r in body.unsubscribe_rooms {
known_subscription_rooms.remove(&r);
}
services().users.update_sync_known_rooms(
connection_key.clone(),
"subscriptions".to_owned(),
known_subscription_rooms,
todo_rooms.keys().cloned().collect(),
globalsince,
);