mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-09-11 13:23:01 +02:00
significantly improve get_missing_events fed code
Signed-off-by: June Clementine Strawberry <june@3.dog>
This commit is contained in:
parent
ea246d91d9
commit
74012c5289
2 changed files with 65 additions and 58 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue