Refactor to async closures.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-07-08 11:08:58 +00:00
parent cca0f20148
commit c8d35cca57
36 changed files with 78 additions and 80 deletions

View File

@@ -1,5 +1,5 @@
use axum::extract::State;
use futures::StreamExt;
use futures::{StreamExt, TryStreamExt};
use ruma::{api::client::threads::get_threads, uint};
use tuwunel_core::{
Result, at,
@@ -35,18 +35,17 @@ pub(crate) async fn get_threads_route(
.rooms
.threads
.threads_until(body.sender_user(), &body.room_id, from, &body.include)
.await?
.take(limit)
.filter_map(|(count, pdu)| async move {
services
.try_filter_map(async |(count, pdu)| {
Ok(services
.rooms
.state_accessor
.user_can_see_event(body.sender_user(), &body.room_id, &pdu.event_id)
.await
.then_some((count, pdu))
.then_some((count, pdu)))
})
.collect()
.await;
.try_collect()
.await?;
Ok(get_threads::v1::Response {
next_batch: threads