significantly improve get_missing_events fed code
Signed-off-by: June Clementine Strawberry <june@3.dog>
This commit is contained in:
@@ -6,11 +6,17 @@ use conduwuit::{
|
||||
utils::{IterStream, ReadyExt, stream::TryTools},
|
||||
};
|
||||
use futures::{FutureExt, StreamExt, TryStreamExt};
|
||||
use ruma::{MilliSecondsSinceUnixEpoch, api::federation::backfill::get_backfill, uint};
|
||||
use ruma::{MilliSecondsSinceUnixEpoch, api::federation::backfill::get_backfill};
|
||||
|
||||
use super::AccessCheck;
|
||||
use crate::Ruma;
|
||||
|
||||
/// arbitrary number but synapse's is 100 and we can handle lots of these
|
||||
/// anyways
|
||||
const LIMIT_MAX: usize = 150;
|
||||
/// no spec defined number but we can handle a lot of these
|
||||
const LIMIT_DEFAULT: usize = 50;
|
||||
|
||||
/// # `GET /_matrix/federation/v1/backfill/<room_id>`
|
||||
///
|
||||
/// Retrieves events from before the sender joined the room, if the room's
|
||||
@@ -30,9 +36,9 @@ pub(crate) async fn get_backfill_route(
|
||||
|
||||
let limit = body
|
||||
.limit
|
||||
.min(uint!(100))
|
||||
.try_into()
|
||||
.expect("UInt could not be converted to usize");
|
||||
.unwrap_or(LIMIT_DEFAULT)
|
||||
.min(LIMIT_MAX);
|
||||
|
||||
let from = body
|
||||
.v
|
||||
|
||||
Reference in New Issue
Block a user