Add upper-bound to readreceipts_since() and callsites.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-07-26 04:44:09 +00:00
parent 33a9fce828
commit c6836e51b2
7 changed files with 19 additions and 15 deletions

View File

@@ -66,6 +66,7 @@ impl Data {
&'a self,
room_id: &'a RoomId,
since: u64,
to: Option<u64>,
) -> impl Stream<Item = ReceiptItem<'_>> + Send + 'a {
type Key<'a> = (&'a RoomId, u64, &'a UserId);
type KeyVal<'a> = (Key<'a>, CanonicalJsonObject);
@@ -76,7 +77,9 @@ impl Data {
self.readreceiptid_readreceipt
.stream_from(&first_possible_edu)
.ignore_err()
.ready_take_while(move |((r, ..), _): &KeyVal<'_>| *r == room_id)
.ready_take_while(move |((r, c, ..), _): &KeyVal<'_>| {
*r == room_id && to.is_none_or(|to| *c <= to)
})
.map(move |((_, count, user_id), mut json): KeyVal<'_>| {
json.remove("room_id");

View File

@@ -126,8 +126,9 @@ impl Service {
&'a self,
room_id: &'a RoomId,
since: u64,
to: Option<u64>,
) -> impl Stream<Item = ReceiptItem<'_>> + Send + 'a {
self.db.readreceipts_since(room_id, since)
self.db.readreceipts_since(room_id, since, to)
}
/// Sets a private read marker at PDU `count`.