federation-api: Add support to get an event by timestamp
According to MSC3030
This commit is contained in:
parent
74c6e38a6b
commit
b5b74f948e
@ -4,6 +4,10 @@ Bug fixes:
|
||||
|
||||
* Add the `event` field to `RoomState` according to MSC3083 / Matrix v1.2
|
||||
|
||||
Improvements:
|
||||
|
||||
* Add unstable support to get an event by timestamp (MSC3030)
|
||||
|
||||
# 0.6.0
|
||||
|
||||
Breaking changes:
|
||||
|
@ -21,6 +21,7 @@ client = []
|
||||
server = []
|
||||
unstable-exhaustive-types = []
|
||||
unstable-msc2448 = []
|
||||
unstable-msc3030 = []
|
||||
unstable-msc3618 = []
|
||||
unstable-msc3723 = []
|
||||
unstable-unspecified = []
|
||||
|
@ -1,6 +1,8 @@
|
||||
//! Endpoints to get general information about events
|
||||
|
||||
pub mod get_event;
|
||||
#[cfg(feature = "unstable-msc3030")]
|
||||
pub mod get_event_by_timestamp;
|
||||
pub mod get_missing_events;
|
||||
pub mod get_room_state;
|
||||
pub mod get_room_state_ids;
|
||||
|
@ -0,0 +1,63 @@
|
||||
//! `GET /_matrix/federation/*/timestamp_to_event/{roomId}`
|
||||
//!
|
||||
//! Get the ID of the event closest to the given timestamp.
|
||||
|
||||
pub mod unstable {
|
||||
//! `/unstable/` ([spec])
|
||||
//!
|
||||
//! [spec]: https://github.com/matrix-org/matrix-spec-proposals/pull/3030
|
||||
|
||||
use ruma_common::{
|
||||
api::{request, response, Direction, Metadata},
|
||||
metadata, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedRoomId,
|
||||
};
|
||||
|
||||
const METADATA: Metadata = metadata! {
|
||||
method: GET,
|
||||
rate_limited: false,
|
||||
authentication: ServerSignatures,
|
||||
history: {
|
||||
unstable => "/_matrix/federation/unstable/org.matrix.msc3030/timestamp_to_event/:room_id",
|
||||
}
|
||||
};
|
||||
|
||||
/// Request type for the `get_event_by_timestamp` endpoint.
|
||||
#[request]
|
||||
pub struct Request {
|
||||
/// The ID of the room the event is in.
|
||||
#[ruma_api(path)]
|
||||
pub room_id: OwnedRoomId,
|
||||
|
||||
/// The timestamp to search from.
|
||||
#[ruma_api(query)]
|
||||
pub ts: MilliSecondsSinceUnixEpoch,
|
||||
|
||||
/// The direction in which to search.
|
||||
#[ruma_api(query)]
|
||||
pub dir: Direction,
|
||||
}
|
||||
|
||||
/// Response type for the `get_event_by_timestamp` endpoint.
|
||||
#[response]
|
||||
pub struct Response {
|
||||
/// The ID of the event found.
|
||||
pub event_id: OwnedEventId,
|
||||
|
||||
/// The event's timestamp.
|
||||
pub origin_server_ts: MilliSecondsSinceUnixEpoch,
|
||||
}
|
||||
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given room ID, timestamp and direction.
|
||||
pub fn new(room_id: OwnedRoomId, ts: MilliSecondsSinceUnixEpoch, dir: Direction) -> Self {
|
||||
Self { room_id, ts, dir }
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Response` with the given event ID and timestamp.
|
||||
pub fn new(event_id: OwnedEventId, origin_server_ts: MilliSecondsSinceUnixEpoch) -> Self {
|
||||
Self { event_id, origin_server_ts }
|
||||
}
|
||||
}
|
||||
}
|
@ -135,7 +135,10 @@ unstable-msc2746 = ["ruma-common/unstable-msc2746"]
|
||||
unstable-msc2870 = ["ruma-common/unstable-msc2870"]
|
||||
unstable-msc2965 = ["ruma-client-api?/unstable-msc2965"]
|
||||
unstable-msc2967 = ["ruma-client-api?/unstable-msc2967"]
|
||||
unstable-msc3030 = ["ruma-client-api?/unstable-msc3030"]
|
||||
unstable-msc3030 = [
|
||||
"ruma-client-api?/unstable-msc3030",
|
||||
"ruma-federation-api?/unstable-msc3030",
|
||||
]
|
||||
unstable-msc3202 = ["ruma-appservice-api?/unstable-msc3202"]
|
||||
unstable-msc3245 = ["ruma-common/unstable-msc3245"]
|
||||
unstable-msc3246 = ["ruma-common/unstable-msc3246"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user