federation-api: Make remaining request / response types non-exhaustive
This commit is contained in:
parent
417b65def5
commit
f84287038e
@ -36,8 +36,10 @@ ruma_api! {
|
|||||||
latest_events: &'a [EventId],
|
latest_events: &'a [EventId],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// The missing events.
|
/// The missing PDUs.
|
||||||
events: Vec<Pdu>
|
events: Vec<Pdu>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,22 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
/// Full state of the room.
|
/// Full state of the room.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub struct RoomState {
|
pub struct RoomState {
|
||||||
/// The resident server's DNS name.
|
/// The resident server's DNS name.
|
||||||
pub origin: String,
|
pub origin: String,
|
||||||
|
|
||||||
/// The full set of authorization events that make up the state of the room,
|
/// The full set of authorization events that make up the state of the room,
|
||||||
/// and their authorization events, recursively.
|
/// and their authorization events, recursively.
|
||||||
pub auth_chain: Vec<Raw<Pdu>>,
|
pub auth_chain: Vec<Raw<Pdu>>,
|
||||||
|
|
||||||
/// The room state.
|
/// The room state.
|
||||||
pub state: Vec<Raw<Pdu>>,
|
pub state: Vec<Raw<Pdu>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl RoomState {
|
||||||
|
/// Creates an empty `RoomState` with the given `origin`.
|
||||||
|
pub fn new(origin: String) -> Self {
|
||||||
|
Self { origin, auth_chain: Vec::new(), state: Vec::new() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -17,6 +17,7 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// The room ID that is about to be joined.
|
/// The room ID that is about to be joined.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
@ -31,6 +32,7 @@ ruma_api! {
|
|||||||
pub pdu_stub: Raw<PduStub>,
|
pub pdu_stub: Raw<PduStub>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// Full state and auth chain of the room prior to the join event.
|
/// Full state and auth chain of the room prior to the join event.
|
||||||
#[ruma_api(body)]
|
#[ruma_api(body)]
|
||||||
@ -38,3 +40,18 @@ ruma_api! {
|
|||||||
pub room_state: RoomState,
|
pub room_state: RoomState,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Construct from Pdu, same for similar endpoints
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a `Request` from the given room ID, event ID and `PduStub`.
|
||||||
|
pub fn new(room_id: &'a RoomId, event_id: &'a EventId, pdu_stub: Raw<PduStub>) -> Self {
|
||||||
|
Self { room_id, event_id, pdu_stub }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given room state.
|
||||||
|
pub fn new(room_state: RoomState) -> Self {
|
||||||
|
Self { room_state }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -17,23 +17,40 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// The room ID that is about to be joined.
|
/// The room ID that is about to be joined.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: RoomId,
|
pub room_id: &'a RoomId,
|
||||||
|
|
||||||
/// The user ID the join event will be for.
|
/// The user ID the join event will be for.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub event_id: EventId,
|
pub event_id: &'a EventId,
|
||||||
|
|
||||||
/// PDU type without event and room IDs.
|
/// PDU type without event and room IDs.
|
||||||
#[ruma_api(body)]
|
#[ruma_api(body)]
|
||||||
pub pdu_stub: Raw<PduStub>,
|
pub pdu_stub: Raw<PduStub>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// Full state of the room.
|
/// Full state of the room.
|
||||||
#[ruma_api(body)]
|
#[ruma_api(body)]
|
||||||
pub room_state: RoomState,
|
pub room_state: RoomState,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Construct from Pdu, same for similar endpoints
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a `Request` from the given room ID, event ID and `PduStub`.
|
||||||
|
pub fn new(room_id: &'a RoomId, event_id: &'a EventId, pdu_stub: Raw<PduStub>) -> Self {
|
||||||
|
Self { room_id, event_id, pdu_stub }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given room state.
|
||||||
|
pub fn new(room_state: RoomState) -> Self {
|
||||||
|
Self { room_state }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -13,14 +13,30 @@ ruma_api! {
|
|||||||
requires_authentication: false,
|
requires_authentication: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// The OpenID access token to get information about the owner for.
|
/// The OpenID access token to get information about the owner for.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub access_token: &'a str,
|
pub access_token: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// The Matrix User ID who generated the token.
|
/// The Matrix User ID who generated the token.
|
||||||
pub sub: UserId,
|
pub sub: UserId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given access token.
|
||||||
|
pub fn new(access_token: &'a str) -> Self {
|
||||||
|
Self { access_token }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given user id.
|
||||||
|
pub fn new(sub: UserId) -> Self {
|
||||||
|
Self { sub }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -14,10 +14,11 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// User ID to query.
|
/// User ID to query.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub user_id: UserId,
|
pub user_id: &'a UserId,
|
||||||
|
|
||||||
/// Profile field to query.
|
/// Profile field to query.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
@ -25,6 +26,8 @@ ruma_api! {
|
|||||||
pub field: Option<ProfileField>,
|
pub field: Option<ProfileField>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// Display name of the user.
|
/// Display name of the user.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
@ -36,8 +39,22 @@ ruma_api! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given user id.
|
||||||
|
pub fn new(user_id: &'a UserId) -> Self {
|
||||||
|
Self { user_id, field: None }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates an empty `Response`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Profile fields to specify in query.
|
/// Profile fields to specify in query.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)]
|
||||||
pub enum ProfileField {
|
pub enum ProfileField {
|
||||||
/// Display name of the user.
|
/// Display name of the user.
|
||||||
#[serde(rename = "displayname")]
|
#[serde(rename = "displayname")]
|
||||||
|
@ -13,12 +13,14 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// Room alias to query.
|
/// Room alias to query.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub room_alias: &'a RoomAliasId,
|
pub room_alias: &'a RoomAliasId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// Room ID mapped to queried alias.
|
/// Room ID mapped to queried alias.
|
||||||
pub room_id: RoomId,
|
pub room_id: RoomId,
|
||||||
@ -27,3 +29,17 @@ ruma_api! {
|
|||||||
pub servers: Vec<String>,
|
pub servers: Vec<String>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given room alias ID.
|
||||||
|
pub fn new(room_alias: &'a RoomAliasId) -> Self {
|
||||||
|
Self { room_alias }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given room IDs and servers.
|
||||||
|
pub fn new(room_id: RoomId, servers: Vec<String>) -> Self {
|
||||||
|
Self { room_id, servers }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -18,6 +18,7 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// A transaction ID unique between sending and receiving homeservers.
|
/// A transaction ID unique between sending and receiving homeservers.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
@ -43,6 +44,8 @@ ruma_api! {
|
|||||||
pub edus: &'a [Edu],
|
pub edus: &'a [Edu],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// Map of event IDs and response for each PDU given in the request.
|
/// Map of event IDs and response for each PDU given in the request.
|
||||||
#[serde(with = "crate::serde::pdu_process_response")]
|
#[serde(with = "crate::serde::pdu_process_response")]
|
||||||
@ -50,6 +53,26 @@ ruma_api! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given transaction ID, origin, timestamp.
|
||||||
|
///
|
||||||
|
/// The PDU and EDU lists will start off empty.
|
||||||
|
pub fn new(
|
||||||
|
transaction_id: &'a str,
|
||||||
|
origin: &'a ServerName,
|
||||||
|
origin_server_ts: SystemTime,
|
||||||
|
) -> Self {
|
||||||
|
Self { transaction_id, origin, origin_server_ts, pdus: &[], edus: &[] }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given PDUs.
|
||||||
|
pub fn new(pdus: BTreeMap<EventId, Result<(), String>>) -> Self {
|
||||||
|
Self { pdus }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Type for passing ephemeral data to homeservers.
|
/// Type for passing ephemeral data to homeservers.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct Edu {
|
pub struct Edu {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user