federation-api: More small improvements
This commit is contained in:
parent
64c5159f04
commit
135bea8562
@ -11,29 +11,45 @@ ruma_api! {
|
||||
description: "Query for another server's keys.",
|
||||
method: GET,
|
||||
name: "get_remote_server_keys",
|
||||
// Note: The spec has an additional, deprecated path parameter on this. We may want to
|
||||
// support an additional parameter at the end, even if it is ignored.
|
||||
path: "/_matrix/key/v2/query/:server_name",
|
||||
rate_limited: false,
|
||||
requires_authentication: false,
|
||||
}
|
||||
|
||||
#[non_exhaustive]
|
||||
request: {
|
||||
/// The server's DNS name to query
|
||||
#[ruma_api(path)]
|
||||
pub server_name: &'a ServerName,
|
||||
|
||||
/// A millisecond POSIX timestamp in milliseconds indicating when the
|
||||
/// returned certificates will need to be valid until to be useful to
|
||||
/// the requesting server.
|
||||
/// A millisecond POSIX timestamp in milliseconds indicating when the returned certificates
|
||||
/// will need to be valid until to be useful to the requesting server.
|
||||
///
|
||||
/// If not supplied, the current time as determined by the notary server
|
||||
/// is used.
|
||||
/// If not supplied, the current time as determined by the receiving server is used.
|
||||
#[ruma_api(query)]
|
||||
#[serde(with = "ruma_serde::time::ms_since_unix_epoch")]
|
||||
#[serde(default = "SystemTime::now", with = "ruma_serde::time::ms_since_unix_epoch")]
|
||||
pub minimum_valid_until_ts: SystemTime,
|
||||
}
|
||||
|
||||
#[non_exhaustive]
|
||||
response: {
|
||||
/// The queried server's keys, signed by the notary server.
|
||||
pub server_keys: Vec<ServerKey>,
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
/// Creates a new `Request` with the given server name and `minimum_valid_until` timestamp.
|
||||
pub fn new(server_name: &'a ServerName, minimum_valid_until_ts: SystemTime) -> Self {
|
||||
Self { server_name, minimum_valid_until_ts }
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Response` with the given keys.
|
||||
pub fn new(server_keys: Vec<ServerKey>) -> Self {
|
||||
Self { server_keys }
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ ruma_api! {
|
||||
requires_authentication: false,
|
||||
}
|
||||
|
||||
#[non_exhaustive]
|
||||
request: {
|
||||
/// The query criteria. The outer string key on the object is the server
|
||||
/// name (eg: matrix.org). The inner string key is the Key ID to query
|
||||
@ -41,12 +42,30 @@ ruma_api! {
|
||||
pub minimum_valid_until_ts: SystemTime,
|
||||
}
|
||||
|
||||
#[non_exhaustive]
|
||||
response: {
|
||||
/// The queried server's keys, signed by the notary server.
|
||||
pub server_keys: Vec<ServerKey>,
|
||||
}
|
||||
}
|
||||
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given query criteria and `minimum_valid_until` timestamp.
|
||||
pub fn new(
|
||||
server_keys: BTreeMap<ServerNameBox, BTreeMap<ServerKeyId, QueryCriteria>>,
|
||||
minimum_valid_until_ts: SystemTime,
|
||||
) -> Self {
|
||||
Self { server_keys, minimum_valid_until_ts }
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Response` with the given keys.
|
||||
pub fn new(server_keys: Vec<ServerKey>) -> Self {
|
||||
Self { server_keys }
|
||||
}
|
||||
}
|
||||
|
||||
/// The query criteria.
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
#[non_exhaustive]
|
||||
|
@ -15,6 +15,7 @@ ruma_api! {
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
#[non_exhaustive]
|
||||
request: {
|
||||
/// The room ID that is about to be joined.
|
||||
#[ruma_api(path)]
|
||||
@ -24,17 +25,43 @@ ruma_api! {
|
||||
#[ruma_api(path)]
|
||||
pub user_id: &'a UserId,
|
||||
|
||||
/// The room versions the sending server has support for. Defaults to 1.
|
||||
/// The room versions the sending server has support for.
|
||||
///
|
||||
/// Defaults to `&[RoomVersionId::Version1]`.
|
||||
#[ruma_api(query)]
|
||||
#[serde(skip_serializing_if = "<[_]>::is_empty")]
|
||||
#[serde(default = "default_ver", skip_serializing_if = "is_default_ver")]
|
||||
pub ver: &'a [RoomVersionId],
|
||||
}
|
||||
|
||||
#[non_exhaustive]
|
||||
response: {
|
||||
/// The version of the room where the server is trying to join.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub room_version: Option<RoomVersionId>,
|
||||
|
||||
/// An unsigned template event.
|
||||
pub event: Raw<Pdu>,
|
||||
}
|
||||
}
|
||||
|
||||
fn default_ver() -> Vec<RoomVersionId> {
|
||||
vec![RoomVersionId::Version1]
|
||||
}
|
||||
|
||||
fn is_default_ver(ver: &&[RoomVersionId]) -> bool {
|
||||
**ver == [RoomVersionId::Version1]
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
/// Creates a new `Request` with the given room id and user id.
|
||||
pub fn new(room_id: &'a RoomId, user_id: &'a UserId) -> Self {
|
||||
Self { room_id, user_id, ver: &[RoomVersionId::Version1] }
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Response` with the given template event.
|
||||
pub fn new(event: Raw<Pdu>) -> Self {
|
||||
Self { room_version: None, event }
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user