use ruma_common::{
MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId,
api::{Direction, Metadata, path_builder::SinglePath, request, response},
};
#[request]
pub struct Request {
#[ruma_api(path)]
pub room_id: OwnedRoomId,
#[ruma_api(query)]
pub ts: MilliSecondsSinceUnixEpoch,
#[ruma_api(query)]
pub dir: Direction,
}
impl Request {
pub fn new(room_id: OwnedRoomId, ts: MilliSecondsSinceUnixEpoch, dir: Direction) -> Self {
Self { room_id, ts, dir }
}
}
impl Metadata for Request {
const METHOD: http::Method = super::v1::Request::METHOD;
const RATE_LIMITED: bool = super::v1::Request::RATE_LIMITED;
type Authentication = <super::v1::Request as Metadata>::Authentication;
type PathBuilder = <super::v1::Request as Metadata>::PathBuilder;
const PATH_BUILDER: Self::PathBuilder = SinglePath::new(
"/_matrix/federation/unstable/org.matrix.msc3030/timestamp_to_event/{room_id}",
);
}
impl From<super::v1::Request> for Request {
fn from(value: super::v1::Request) -> Self {
let super::v1::Request { room_id, ts, dir } = value;
Self { room_id, ts, dir }
}
}
impl From<Request> for super::v1::Request {
fn from(value: Request) -> Self {
let Request { room_id, ts, dir } = value;
Self { room_id, ts, dir }
}
}
#[response]
pub struct Response {
pub event_id: OwnedEventId,
pub origin_server_ts: MilliSecondsSinceUnixEpoch,
}
impl Response {
pub fn new(event_id: OwnedEventId, origin_server_ts: MilliSecondsSinceUnixEpoch) -> Self {
Self { event_id, origin_server_ts }
}
}
impl From<super::v1::Response> for Response {
fn from(value: super::v1::Response) -> Self {
let super::v1::Response { event_id, origin_server_ts } = value;
Self { event_id, origin_server_ts }
}
}
impl From<Response> for super::v1::Response {
fn from(value: Response) -> Self {
let Response { event_id, origin_server_ts } = value;
Self { event_id, origin_server_ts }
}
}