1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
//! `/v2/` ([spec])
//!
//! [spec]: https://spec.matrix.org/latest/server-server-api/#put_matrixfederationv2inviteroomideventid
#[cfg(feature = "unstable-msc4125")]
use ruma_common::OwnedServerName;
use ruma_common::{
api::{request, response, Metadata},
metadata,
serde::Raw,
OwnedEventId, OwnedRoomId, RoomVersionId,
};
use ruma_events::AnyStrippedStateEvent;
use serde_json::value::RawValue as RawJsonValue;
const METADATA: Metadata = metadata! {
method: PUT,
rate_limited: false,
authentication: ServerSignatures,
history: {
1.0 => "/_matrix/federation/v2/invite/:room_id/:event_id",
}
};
/// Request type for the `create_invite` endpoint.
#[request]
pub struct Request {
/// The room ID that the user is being invited to.
#[ruma_api(path)]
pub room_id: OwnedRoomId,
/// The event ID for the invite event, generated by the inviting server.
#[ruma_api(path)]
pub event_id: OwnedEventId,
/// The version of the room where the user is being invited to.
pub room_version: RoomVersionId,
/// The invite event which needs to be signed.
pub event: Box<RawJsonValue>,
/// An optional list of simplified events to help the receiver of the invite identify the room.
pub invite_room_state: Vec<Raw<AnyStrippedStateEvent>>,
/// An optional list of servers the invited homeserver should attempt to join or leave via,
/// according to [MSC4125](https://github.com/matrix-org/matrix-spec-proposals/pull/4125).
///
/// If present, it must not be empty.
#[cfg(feature = "unstable-msc4125")]
#[serde(skip_serializing_if = "Option::is_none", rename = "org.matrix.msc4125.via")]
pub via: Option<Vec<OwnedServerName>>,
}
/// Response type for the `create_invite` endpoint.
#[response]
pub struct Response {
/// The signed invite event.
pub event: Box<RawJsonValue>,
}
impl Request {
/// Creates a new `Request` with the given room ID, event ID, room version, event and invite
/// room state.
pub fn new(
room_id: OwnedRoomId,
event_id: OwnedEventId,
room_version: RoomVersionId,
event: Box<RawJsonValue>,
invite_room_state: Vec<Raw<AnyStrippedStateEvent>>,
) -> Self {
Self {
room_id,
event_id,
room_version,
event,
invite_room_state,
#[cfg(feature = "unstable-msc4125")]
via: None,
}
}
}
impl Response {
/// Creates a new `Response` with the given invite event.
pub fn new(event: Box<RawJsonValue>) -> Self {
Self { event }
}
}