ruma_federation_api/backfill/get_backfill.rs
1//! `GET /_matrix/federation/*/backfill/{roomId}`
2//!
3//! Get more history from another homeserver.
4
5pub mod v1 {
6 //! `/v1/` ([spec])
7 //!
8 //! [spec]: https://spec.matrix.org/latest/server-server-api/#get_matrixfederationv1backfillroomid
9
10 use js_int::UInt;
11 use ruma_common::{
12 MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId, OwnedServerName,
13 api::{request, response},
14 metadata,
15 };
16 use serde_json::value::RawValue as RawJsonValue;
17
18 use crate::authentication::ServerSignatures;
19
20 metadata! {
21 method: GET,
22 rate_limited: false,
23 authentication: ServerSignatures,
24 path: "/_matrix/federation/v1/backfill/{room_id}",
25 }
26
27 /// Request type for the `get_backfill` endpoint.
28 #[request]
29 pub struct Request {
30 /// The room ID to backfill.
31 #[ruma_api(path)]
32 pub room_id: OwnedRoomId,
33
34 /// The event IDs to backfill from.
35 #[ruma_api(query)]
36 pub v: Vec<OwnedEventId>,
37
38 /// The maximum number of PDUs to retrieve, including the given events.
39 #[ruma_api(query)]
40 pub limit: UInt,
41 }
42
43 /// Response type for the `get_backfill` endpoint.
44 #[response]
45 pub struct Response {
46 /// The `server_name` of the homeserver sending this transaction.
47 pub origin: OwnedServerName,
48
49 /// POSIX timestamp in milliseconds on originating homeserver when this transaction
50 /// started.
51 pub origin_server_ts: MilliSecondsSinceUnixEpoch,
52
53 /// List of persistent updates to rooms.
54 pub pdus: Vec<Box<RawJsonValue>>,
55 }
56
57 impl Request {
58 /// Creates a new `Request` with:
59 /// * the given room id.
60 /// * the event IDs to backfill from.
61 /// * the maximum number of PDUs to retrieve, including the given events.
62 pub fn new(room_id: OwnedRoomId, v: Vec<OwnedEventId>, limit: UInt) -> Self {
63 Self { room_id, v, limit }
64 }
65 }
66
67 impl Response {
68 /// Creates a new `Response` with:
69 /// * the `server_name` of the homeserver.
70 /// * the timestamp in milliseconds of when this transaction started.
71 /// * the list of persistent updates to rooms.
72 pub fn new(
73 origin: OwnedServerName,
74 origin_server_ts: MilliSecondsSinceUnixEpoch,
75 pdus: Vec<Box<RawJsonValue>>,
76 ) -> Self {
77 Self { origin, origin_server_ts, pdus }
78 }
79 }
80}