From 472ce01769d86ba3ca6752cd618a9a0027802bb8 Mon Sep 17 00:00:00 2001 From: Victor Berger Date: Sat, 31 Dec 2016 12:31:39 +0100 Subject: [PATCH] Point-out inconsistencies with spec --- src/r0/account.rs | 6 ++++++ src/r0/contact.rs | 7 ++++--- src/r0/media.rs | 1 + src/r0/membership.rs | 7 +++++-- src/r0/presence.rs | 4 ++-- src/r0/room.rs | 7 ++++--- src/r0/search.rs | 5 +++-- src/r0/session.rs | 2 ++ 8 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/r0/account.rs b/src/r0/account.rs index a10b171c..fa31316d 100644 --- a/src/r0/account.rs +++ b/src/r0/account.rs @@ -10,6 +10,7 @@ pub mod register { pub password: String, #[serde(skip_serializing_if = "Option::is_none")] pub username: Option, + // TODO: `auth` field } /// Details about this API endpoint. @@ -38,6 +39,7 @@ pub mod register { pub access_token: String, pub home_server: String, pub user_id: String, + // TODO: `refresh_token` field? (more or less deprecated?) } impl ::Endpoint for Endpoint { @@ -62,6 +64,7 @@ pub mod register { /// [POST /_matrix/client/r0/account/password/email/requestToken](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-account-password-email-requesttoken) pub mod request_password_change_token { + // TODO: according to the spec, this does not has any params /// This API endpoint's body parameters. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct BodyParams { @@ -102,6 +105,8 @@ pub mod deactivate { #[derive(Clone, Copy, Debug)] pub struct Endpoint; + // TODO: missing BodyParams + impl ::Endpoint for Endpoint { type BodyParams = (); type PathParams = (); @@ -128,6 +133,7 @@ pub mod change_password { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct BodyParams { pub new_password: String, + // TODO: missing `auth` field } /// Details about this API endpoint. diff --git a/src/r0/contact.rs b/src/r0/contact.rs index 19013ef1..571d3bb3 100644 --- a/src/r0/contact.rs +++ b/src/r0/contact.rs @@ -17,9 +17,9 @@ pub mod create_contact { /// The third party credentials to associate with the account. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ThreePidCredentials { - client_secret: String, - id_server: String, - sid: String, + pub client_secret: String, + pub id_server: String, + pub sid: String, } impl ::Endpoint for Endpoint { @@ -90,6 +90,7 @@ pub mod get_contacts { /// [POST /_matrix/client/r0/account/3pid/email/requestToken](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-account-3pid-email-requesttoken) pub mod request_contact_verification_token { + // TODO: according to the spec this takes no parameters /// This API endpoint's body parameters. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct BodyParams { diff --git a/src/r0/media.rs b/src/r0/media.rs index e7a1b8fd..efe68e69 100644 --- a/src/r0/media.rs +++ b/src/r0/media.rs @@ -20,6 +20,7 @@ pub mod get_content { type PathParams = PathParams; type QueryParams = (); type Response = (); // TODO: How should a file be represented as a response? + // must include HTTP headers Content-Type and Content-Disposition (filename) fn method() -> ::Method { ::Method::Get diff --git a/src/r0/membership.rs b/src/r0/membership.rs index 343c2b5d..f5e2fe63 100644 --- a/src/r0/membership.rs +++ b/src/r0/membership.rs @@ -2,6 +2,9 @@ use ruma_signatures::Signatures; +// TODO: spec requires a nesting ThirdPartySigned { signed: Signed { mxid: ..., ... } } +// for join_room_by_id_or_alias but not for join_room_by_id, inconsistency? + /// 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 { @@ -17,12 +20,12 @@ pub struct ThirdPartySigned { /// [POST /_matrix/client/r0/rooms/{roomId}/invite](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-invite) pub mod invite_user { - use ruma_identifiers::RoomId; + use ruma_identifiers::{UserId, RoomId}; /// The request type. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct BodyParams { - pub user_id: String, + pub user_id: UserId, } /// Details about this API endpoint. diff --git a/src/r0/presence.rs b/src/r0/presence.rs index df206f42..ca07ec03 100644 --- a/src/r0/presence.rs +++ b/src/r0/presence.rs @@ -19,8 +19,8 @@ pub mod set_presence { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct BodyParams { #[serde(skip_serializing_if = "Option::is_none")] - status_msg: Option, - presence: PresenceState + pub status_msg: Option, + pub presence: PresenceState } impl ::Endpoint for Endpoint { diff --git a/src/r0/room.rs b/src/r0/room.rs index bd5f3c7c..4880d6f8 100644 --- a/src/r0/room.rs +++ b/src/r0/room.rs @@ -2,7 +2,7 @@ /// [POST /_matrix/client/r0/createRoom](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-createroom) pub mod create_room { - use ruma_identifiers::RoomId; + use ruma_identifiers::{RoomId, UserId}; /// The request type. #[derive(Clone, Debug, Deserialize, Serialize)] @@ -11,7 +11,7 @@ pub mod create_room { pub creation_content: Option, #[serde(skip_serializing_if = "Vec::is_empty")] #[serde(default)] - pub invite: Vec, + pub invite: Vec, #[serde(skip_serializing_if = "Option::is_none")] pub name: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -21,7 +21,8 @@ pub mod create_room { #[serde(skip_serializing_if = "Option::is_none")] pub topic: Option, #[serde(skip_serializing_if = "Option::is_none")] - pub visibility: Option, + pub visibility: Option, // TODO: should be an enum ["public", "private"] + // TODO: missing `invite_3pid`, `initial_state` } /// Extra options to be added to the `m.room.create` event. diff --git a/src/r0/search.rs b/src/r0/search.rs index 3ed04688..f1ddf967 100644 --- a/src/r0/search.rs +++ b/src/r0/search.rs @@ -43,8 +43,9 @@ pub mod search_events { #[serde(skip_serializing_if = "Option::is_none")] pub include_state: Option, /// The keys to search for. Defaults to all keys. - #[serde(skip_serializing_if = "Option::is_none")] - pub keys: Option>, + #[serde(skip_serializing_if = "Vec::is_empty")] + #[serde(default)] + pub keys: Vec, /// The order in which to search for results. #[serde(skip_serializing_if = "Option::is_none")] pub order_by: Option, diff --git a/src/r0/session.rs b/src/r0/session.rs index 70ad2cc6..4ed5c41c 100644 --- a/src/r0/session.rs +++ b/src/r0/session.rs @@ -6,6 +6,8 @@ pub mod login { #[derive(Clone, Copy, Debug)] pub struct Endpoint; + // TODO: missing BodyParams + /// This API endpoint's response. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Response {