From db7d378a2ee81a76f4ab23ff97f5f77ce798de19 Mon Sep 17 00:00:00 2001 From: Ginger Date: Sun, 12 Apr 2026 12:03:30 -0400 Subject: [PATCH] refactor: Fix errors in `api/server/backfill.rs` --- src/api/server/backfill.rs | 86 +++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/api/server/backfill.rs b/src/api/server/backfill.rs index 91d1fc042..2359f4a49 100644 --- a/src/api/server/backfill.rs +++ b/src/api/server/backfill.rs @@ -67,48 +67,48 @@ pub(crate) async fn get_backfill_route( .ready_fold(PduCount::min(), cmp::max) .await; - Ok(get_backfill::v1::Response { - origin_server_ts: MilliSecondsSinceUnixEpoch::now(), + let pdus = services + .rooms + .timeline + .pdus_rev(&body.room_id, Some(from.saturating_add(1))) + .try_take(limit) + .try_filter_map(|(_, pdu)| async move { + Ok(services + .rooms + .state_accessor + .server_can_see_event(body.origin(), &pdu.room_id_or_hash(), &pdu.event_id) + .await + .then_some(pdu)) + }) + .and_then(async |mut pdu| { + // Strip the transaction ID, as that is private + pdu.remove_transaction_id().log_err().ok(); + // Add age, as this is specified + pdu.add_age().log_err().ok(); + // It's not clear if we should strip or add any more data, leave as is. + // In particular: Redaction? + Ok(pdu) + }) + .try_filter_map(|pdu| async move { + Ok(services + .rooms + .timeline + .get_pdu_json(&pdu.event_id) + .await + .ok()) + }) + .and_then(|pdu| { + services + .sending + .convert_to_outgoing_federation_event(pdu) + .map(Ok) + }) + .try_collect() + .await?; - origin: services.globals.server_name().to_owned(), - - pdus: services - .rooms - .timeline - .pdus_rev(&body.room_id, Some(from.saturating_add(1))) - .try_take(limit) - .try_filter_map(|(_, pdu)| async move { - Ok(services - .rooms - .state_accessor - .server_can_see_event(body.origin(), &pdu.room_id_or_hash(), &pdu.event_id) - .await - .then_some(pdu)) - }) - .and_then(async |mut pdu| { - // Strip the transaction ID, as that is private - pdu.remove_transaction_id().log_err().ok(); - // Add age, as this is specified - pdu.add_age().log_err().ok(); - // It's not clear if we should strip or add any more data, leave as is. - // In particular: Redaction? - Ok(pdu) - }) - .try_filter_map(|pdu| async move { - Ok(services - .rooms - .timeline - .get_pdu_json(&pdu.event_id) - .await - .ok()) - }) - .and_then(|pdu| { - services - .sending - .convert_to_outgoing_federation_event(pdu) - .map(Ok) - }) - .try_collect() - .await?, - }) + Ok(get_backfill::v1::Response::new( + services.globals.server_name().to_owned(), + MilliSecondsSinceUnixEpoch::now(), + pdus, + )) }