Add join by room id endpoint

This commit is contained in:
Andreas Brönnimann 2016-12-14 23:14:33 +01:00
parent 15b01204cc
commit b9eea6c030
3 changed files with 65 additions and 0 deletions

View File

@ -12,6 +12,7 @@ version = "0.1.0"
[dependencies]
ruma-identifiers = "0.4.3"
ruma-signatures = "0.1.0"
serde = "0.8.19"
serde_derive = "0.8.19"
serde_json = "0.8.3"

View File

@ -6,6 +6,7 @@
extern crate ruma_events;
extern crate ruma_identifiers;
extern crate ruma_signatures;
extern crate serde;
#[macro_use] extern crate serde_derive;
extern crate serde_json;

View File

@ -1 +1,64 @@
//! Endpoints for room membership.
/// POST /_matrix/client/r0/rooms/{roomId}/join
pub mod join_by_room_id {
use ruma_identifiers::RoomId;
use ruma_signatures::Signatures;
/// The request type.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct BodyParams {
pub third_party_signed: Option<ThirdPartySigned>,
}
/// A signature of an `m.third_party_invite` token to prove that this user owns a third party identity which has been invited to the room.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ThirdPartySigned {
/// The state key of the m.third_party_invite event.
pub token: String,
/// A signatures object containing a signature of the entire signed object.
pub signatures: Signatures,
/// The Matrix ID of the invitee.
pub mxid: String,
/// The Matrix ID of the user who issued the invite.
pub sender: String,
}
/// Details about this API endpoint.
pub struct Endpoint;
/// The response type.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Response {
pub room_id: RoomId,
}
/// This API endpoint's path parameters.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PathParams {
pub room_id: RoomId,
}
impl ::Endpoint for Endpoint {
type BodyParams = BodyParams;
type PathParams = PathParams;
type QueryParams = ();
type Response = Response;
fn method() -> ::Method {
::Method::Post
}
fn request_path(params: Self::PathParams) -> String {
format!(
"/_matrix/client/r0/rooms/{}/join",
params.room_id
)
}
fn router_path() -> String {
"/_matrix/client/r0/rooms/:room_id/join".to_string()
}
}
}