pub mod v1 {
use js_int::{UInt, uint};
use ruma_common::{
OwnedEventId, OwnedRoomId,
api::{request, response},
metadata,
};
use serde_json::value::RawValue as RawJsonValue;
use crate::authentication::ServerSignatures;
metadata! {
method: POST,
rate_limited: false,
authentication: ServerSignatures,
path: "/_matrix/federation/v1/get_missing_events/{room_id}",
}
#[request]
pub struct Request {
#[ruma_api(path)]
pub room_id: OwnedRoomId,
#[serde(default = "default_limit", skip_serializing_if = "is_default_limit")]
pub limit: UInt,
#[serde(default, skip_serializing_if = "ruma_common::serde::is_default")]
pub min_depth: UInt,
pub earliest_events: Vec<OwnedEventId>,
pub latest_events: Vec<OwnedEventId>,
}
#[response]
#[derive(Default)]
pub struct Response {
pub events: Vec<Box<RawJsonValue>>,
}
impl Request {
pub fn new(
room_id: OwnedRoomId,
earliest_events: Vec<OwnedEventId>,
latest_events: Vec<OwnedEventId>,
) -> Self {
Self {
room_id,
limit: default_limit(),
min_depth: UInt::default(),
earliest_events,
latest_events,
}
}
}
impl Response {
pub fn new(events: Vec<Box<RawJsonValue>>) -> Self {
Self { events }
}
}
fn default_limit() -> UInt {
uint!(10)
}
#[cfg(feature = "client")]
fn is_default_limit(val: &UInt) -> bool {
*val == default_limit()
}
}