"README.md" did not exist on "8d0097bef112c848d37b1d2f601eb979e89245f6"
Newer
Older
use ruma::{
api::client::{error::ErrorKind, threads::get_threads},
uint,
};
/// # `GET /_matrix/client/r0/rooms/{roomId}/threads`
pub(crate) async fn get_threads_route(
State(services): State<crate::State>, body: Ruma<get_threads::v1::Request>,
) -> Result<get_threads::v1::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
from.parse()
.map_err(|_| Error::BadRequest(ErrorKind::InvalidParam, ""))?
.rooms
.threads
.threads_until(sender_user, &body.room_id, from, &body.include)?
.take(limit)
.filter_map(Result::ok)
.rooms
.state_accessor
.user_can_see_event(sender_user, &body.room_id, &pdu.event_id)
.unwrap_or(false)
})
.collect::<Vec<_>>();
let next_batch = threads.last().map(|(count, _)| count.to_string());
chunk: threads
.into_iter()
.map(|(_, pdu)| pdu.to_room_event())
.collect(),