1//! `GET /_matrix/federation/*/make_join/{roomId}/{userId}`
2//!
3//! Send a request for a join event template to a resident server.
45pub mod v1 {
6//! `/v1/` ([spec])
7 //!
8 //! [spec]: https://spec.matrix.org/latest/server-server-api/#get_matrixfederationv1make_joinroomiduserid
910use ruma_common::{
11 api::{request, response, Metadata},
12 metadata, OwnedRoomId, OwnedUserId, RoomVersionId,
13 };
14use serde_json::value::RawValue as RawJsonValue;
1516const METADATA: Metadata = metadata! {
17 method: GET,
18 rate_limited: false,
19 authentication: ServerSignatures,
20 history: {
211.0 => "/_matrix/federation/v1/make_join/:room_id/:user_id",
22 }
23 };
2425/// Request type for the `create_join_event_template` endpoint.
26#[request]
27pub struct Request {
28/// The room ID that is about to be joined.
29#[ruma_api(path)]
30pub room_id: OwnedRoomId,
3132/// The user ID the join event will be for.
33#[ruma_api(path)]
34pub user_id: OwnedUserId,
3536/// The room versions the sending server has support for.
37 ///
38 /// Defaults to `&[RoomVersionId::V1]`.
39#[ruma_api(query)]
40 #[serde(default = "default_ver", skip_serializing_if = "is_default_ver")]
41pub ver: Vec<RoomVersionId>,
42 }
4344/// Response type for the `create_join_event_template` endpoint.
45#[response]
46pub struct Response {
47/// The version of the room where the server is trying to join.
48#[serde(skip_serializing_if = "Option::is_none")]
49pub room_version: Option<RoomVersionId>,
5051/// An unsigned template event.
52pub event: Box<RawJsonValue>,
53 }
5455fn default_ver() -> Vec<RoomVersionId> {
56vec![RoomVersionId::V1]
57 }
5859fn is_default_ver(ver: &[RoomVersionId]) -> bool {
60*ver == [RoomVersionId::V1]
61 }
6263impl Request {
64/// Creates a new `Request` with the given room id and user id.
65pub fn new(room_id: OwnedRoomId, user_id: OwnedUserId) -> Self {
66Self { room_id, user_id, ver: vec![RoomVersionId::V1] }
67 }
68 }
6970impl Response {
71/// Creates a new `Response` with the given template event.
72pub fn new(event: Box<RawJsonValue>) -> Self {
73Self { room_version: None, event }
74 }
75 }
76}