ruma_federation_api/event/
get_missing_events.rs1pub mod v1 {
6 use js_int::{UInt, uint};
11 use ruma_common::{
12 OwnedEventId, OwnedRoomId,
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: POST,
22 rate_limited: false,
23 authentication: ServerSignatures,
24 path: "/_matrix/federation/v1/get_missing_events/{room_id}",
25 }
26
27 #[request]
29 pub struct Request {
30 #[ruma_api(path)]
32 pub room_id: OwnedRoomId,
33
34 #[serde(default = "default_limit", skip_serializing_if = "is_default_limit")]
38 pub limit: UInt,
39
40 #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
44 pub min_depth: UInt,
45
46 pub earliest_events: Vec<OwnedEventId>,
50
51 pub latest_events: Vec<OwnedEventId>,
53 }
54
55 #[response]
57 #[derive(Default)]
58 pub struct Response {
59 pub events: Vec<Box<RawJsonValue>>,
61 }
62
63 impl Request {
64 pub fn new(
66 room_id: OwnedRoomId,
67 earliest_events: Vec<OwnedEventId>,
68 latest_events: Vec<OwnedEventId>,
69 ) -> Self {
70 Self {
71 room_id,
72 limit: default_limit(),
73 min_depth: UInt::default(),
74 earliest_events,
75 latest_events,
76 }
77 }
78 }
79
80 impl Response {
81 pub fn new(events: Vec<Box<RawJsonValue>>) -> Self {
83 Self { events }
84 }
85 }
86
87 fn default_limit() -> UInt {
88 uint!(10)
89 }
90
91 fn is_default_limit(val: &UInt) -> bool {
92 *val == default_limit()
93 }
94}