mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
refactor: Fix errors in api/server/backfill.rs
This commit is contained in:
+43
-43
@@ -67,48 +67,48 @@ pub(crate) async fn get_backfill_route(
|
|||||||
.ready_fold(PduCount::min(), cmp::max)
|
.ready_fold(PduCount::min(), cmp::max)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
Ok(get_backfill::v1::Response {
|
let pdus = services
|
||||||
origin_server_ts: MilliSecondsSinceUnixEpoch::now(),
|
.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(),
|
Ok(get_backfill::v1::Response::new(
|
||||||
|
services.globals.server_name().to_owned(),
|
||||||
pdus: services
|
MilliSecondsSinceUnixEpoch::now(),
|
||||||
.rooms
|
pdus,
|
||||||
.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?,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user