Add count value to the to_device iter item.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-10-27 06:53:31 +00:00
parent 8959d9e2c1
commit 6a4aff424f
3 changed files with 5 additions and 3 deletions

View File

@@ -375,6 +375,7 @@ async fn build_sync_events(
let to_device_events = services
.users
.get_to_device_events(sender_user, sender_device, Some(since), Some(next_batch))
.map(at!(1))
.collect::<Vec<_>>();
let device_one_time_keys_count = services

View File

@@ -1,6 +1,6 @@
use futures::StreamExt;
use ruma::api::client::sync::sync_events::v5::response;
use tuwunel_core::{self, Result};
use tuwunel_core::{self, Result, at};
use super::{Connection, SyncInfo};
@@ -17,6 +17,7 @@ pub(super) async fn collect(
let events: Vec<_> = services
.users
.get_to_device_events(sender_user, sender_device, None, Some(conn.next_batch))
.map(at!(1))
.collect()
.await;

View File

@@ -319,7 +319,7 @@ pub fn get_to_device_events<'a>(
device_id: &'a DeviceId,
since: Option<u64>,
to: Option<u64>,
) -> impl Stream<Item = Raw<AnyToDeviceEvent>> + Send + 'a {
) -> impl Stream<Item = (u64, Raw<AnyToDeviceEvent>)> + Send + 'a {
type Key<'a> = (&'a UserId, &'a DeviceId, u64);
let from = (user_id, device_id, since.map_or(0, |since| since.saturating_add(1)));
@@ -331,7 +331,7 @@ pub fn get_to_device_events<'a>(
.ready_take_while(move |((user_id_, device_id_, count), _): &(Key<'_>, _)| {
user_id == *user_id_ && device_id == *device_id_ && to.is_none_or(|to| *count <= to)
})
.map(at!(1))
.map(|((_, _, count), event)| (count, event))
}
#[implement(super::Service)]