mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 08:11:24 +01:00
SSS: implement num_live
This commit is contained in:
parent
8e3e1b1f8d
commit
7b4acd214c
1 changed files with 24 additions and 3 deletions
|
|
@ -571,7 +571,9 @@ pub(crate) async fn sync_events_v5_route(
|
||||||
|
|
||||||
let mut rooms = BTreeMap::new();
|
let mut rooms = BTreeMap::new();
|
||||||
for (room_id, todo_room) in todo_rooms {
|
for (room_id, todo_room) in todo_rooms {
|
||||||
if let Some(room) = process_room(&sender_user, &room_id, &todo_room)? {
|
if let Some(room) =
|
||||||
|
process_room(&sender_user, &room_id, &todo_room, globalsince)?
|
||||||
|
{
|
||||||
rooms.insert(room_id.clone(), room);
|
rooms.insert(room_id.clone(), room);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -902,6 +904,7 @@ fn process_room(
|
||||||
sender_user: &UserId,
|
sender_user: &UserId,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
todo_room: &TodoRoom,
|
todo_room: &TodoRoom,
|
||||||
|
globalsince: u64,
|
||||||
) -> Result<Option<sync_events::v5::response::Room>> {
|
) -> Result<Option<sync_events::v5::response::Room>> {
|
||||||
let roomsincecount = PduCount::Normal(todo_room.roomsince);
|
let roomsincecount = PduCount::Normal(todo_room.roomsince);
|
||||||
|
|
||||||
|
|
@ -940,6 +943,25 @@ fn process_room(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let num_live = Some(
|
||||||
|
timeline_pdus
|
||||||
|
.iter()
|
||||||
|
.filter(|(pdu_count, _)| match pdu_count {
|
||||||
|
// TODO check logic
|
||||||
|
PduCount::Backfilled(_) => false,
|
||||||
|
PduCount::Normal(pdu_count) => {
|
||||||
|
if globalsince == 0 {
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
*pdu_count > globalsince
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.count()
|
||||||
|
.try_into()
|
||||||
|
.unwrap_or(UInt::MAX),
|
||||||
|
);
|
||||||
|
|
||||||
let room_events: Vec<_> =
|
let room_events: Vec<_> =
|
||||||
timeline_pdus.iter().map(|(_, pdu)| pdu.to_sync_room_event()).collect();
|
timeline_pdus.iter().map(|(_, pdu)| pdu.to_sync_room_event()).collect();
|
||||||
|
|
||||||
|
|
@ -1115,8 +1137,7 @@ fn process_room(
|
||||||
.map(UInt::new_saturating)
|
.map(UInt::new_saturating)
|
||||||
.unwrap_or(uint!(0)),
|
.unwrap_or(uint!(0)),
|
||||||
),
|
),
|
||||||
// Count events in timeline greater than global sync counter
|
num_live,
|
||||||
num_live: None,
|
|
||||||
bump_stamp,
|
bump_stamp,
|
||||||
heroes,
|
heroes,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue