From a1a9064d28d49e4ea7ba35cfc57736709ccb3754 Mon Sep 17 00:00:00 2001 From: Ross Schulman Date: Sat, 1 Jul 2017 15:57:21 -0400 Subject: [PATCH] Squash a bunch of bugs --- src/r0/session.rs | 82 ++++++++++++++++++++++++----------------------- src/r0/sync.rs | 40 +++++++++++------------ 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/r0/session.rs b/src/r0/session.rs index dc8d79bb..63285be2 100644 --- a/src/r0/session.rs +++ b/src/r0/session.rs @@ -5,49 +5,50 @@ pub mod login { use ruma_api_macros::ruma_api; ruma_api! { - metadata { - description: "Login to the homeserver.", - method: ::Method::Post, - name: "login", - path: "/_matrix/client/r0/login", - rate_limited: true, - requires_authentication: false, - } - request { - /// Password of the user - pub password: String, - /// Medium of 3rd party login to use - #[serde(skip_serializing_if = "Option::is_none")] - pub medium: Option, - /// Type of login to do - #[serde(rename = "type")] - pub kind: LoginKind, - /// Localpart or full matrix user id of the user - pub user: String, - /// 3rd party identifier for the user - #[serde(skip_serializing_if = "Option::is_none")] - pub address: Option - } - response { - pub access_token: String, - pub home_server: String, - #[serde(skip_serializing_if = "Option::is_none")] - pub refresh_token: Option, - pub user_id: String, + metadata { + description: "Login to the homeserver.", + method: Method::Post, + name: "login", + path: "/_matrix/client/r0/login", + rate_limited: true, + requires_authentication: false, + } + request { + /// Password of the user + pub password: String, + /// Medium of 3rd party login to use + #[serde(skip_serializing_if = "Option::is_none")] + pub medium: Option, + /// Type of login to do + #[serde(rename = "type")] + pub kind: LoginKind, + /// Localpart or full matrix user id of the user + pub user: String, + /// 3rd party identifier for the user + #[serde(skip_serializing_if = "Option::is_none")] + pub address: Option + } + response { + pub access_token: String, + pub home_server: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub refresh_token: Option, + pub user_id: String, + } } /// Possible login mediums for 3rd party ID #[derive(Clone, Debug, Deserialize, Serialize)] pub enum LoginMedium { #[serde(rename = "email")] - Email + Email, } /// Possible kinds of login #[derive(Clone, Debug, Deserialize, Serialize)] pub enum LoginKind { #[serde(rename = "m.login.password")] - Password + Password, } } @@ -56,14 +57,15 @@ pub mod logout { use ruma_api_macros::ruma_api; ruma_api! { - metadata { - description: "Log out of the homeserver.", - method: ::Method::Post, - name: "logout", - path: "/_matrix/client/r0/logout", - rate_limited: false, - requires_authentication: true, + metadata { + description: "Log out of the homeserver.", + method: Method::Post, + name: "logout", + path: "/_matrix/client/r0/logout", + rate_limited: false, + requires_authentication: true, + } + request {} + response {} } - request {} - response {} } diff --git a/src/r0/sync.rs b/src/r0/sync.rs index cfa22a5a..87ff903a 100644 --- a/src/r0/sync.rs +++ b/src/r0/sync.rs @@ -20,7 +20,7 @@ pub mod get_state_events { pub room_id: RoomId, } response { - pub Vec, + pub room_state: Vec, } } } @@ -28,12 +28,13 @@ pub mod get_state_events { /// [GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-state-eventtype) pub mod get_state_events_for_empty_key { use ruma_api_macros::ruma_api; - use ruma_identifiers::{RoomId, EventType}; + use ruma_identifiers::RoomId; + use ruma_events::EventType; ruma_api! { metadata { description: "Get state events of a given type associated with the empty key.", - method: ::Method::Get, + method: Method::Get, name: "get_state_events_for_empty_key", path: "/_matrix/client/r0/rooms/:room_id/state/:event_type", rate_limited: false, @@ -61,7 +62,7 @@ pub mod get_state_events_for_key { ruma_api! { metadata { description: "Get state events associated with a given key.", - method: ::Method::Get, + method: Method::Get, name: "get_state_events_for_key", path: "/_matrix/client/r0/rooms/:room_id/state/:event_type/:state_key", rate_limited: false, @@ -70,7 +71,7 @@ pub mod get_state_events_for_key { request { /// The room to look up the state in. #[ruma_api(path)] - pub room_id: RoomID, + pub room_id: RoomId, /// The type of state to look up. #[ruma_api(path)] pub event_type: String, @@ -93,7 +94,7 @@ pub mod get_member_events { ruma_api! { metadata { description: "Get membership events for a room.", - method: ::Method::Get, + method: Method::Get, name: "get_member_events", path: "/_matrix/client/r0/rooms/:room_id/members", rate_limited: false, @@ -105,7 +106,7 @@ pub mod get_member_events { request { /// The room to look up the state in. #[ruma_api(path)] - pub room_id: RoomID, + pub room_id: RoomId, } response { pub chunk: Vec @@ -122,7 +123,7 @@ pub mod get_message_events { ruma_api! { metadata { description: "Get message events for a room.", - method: ::Method::Get, + method: Method::Get, name: "get_message_events", path: "/_matrix/client/r0/rooms/:room_id/messages", rate_limited: false, @@ -133,7 +134,7 @@ pub mod get_message_events { // has one, room_id. I've followed the spec here. -- rschulman 6/30/2017 /// The room to look up the state in. #[ruma_api(path)] - pub room_id: RoomID, + pub room_id: RoomId, /// Required. The token to start returning events from. This token can be obtained from a /// prev_batch token returned for each room by the sync API, or from a start or end token /// returned by a previous request to this endpoint. @@ -155,6 +156,14 @@ pub mod get_message_events { pub end: String, } } + + #[derive(Clone, Debug, Deserialize, Serialize)] + pub enum Direction { + #[serde(rename="b")] + Backward, + #[serde(rename="f")] + Forward, + } } /// [GET /_matrix/client/r0/sync](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-sync) @@ -170,7 +179,7 @@ pub mod sync_events { ruma_api! { metadata { description: "Get all new events from all rooms since the last sync or a given point of time.", - method: ::Method::Get, + method: Method::Get, name: "sync", path: "/_matrix/client/r0/sync", rate_limited: false, @@ -195,9 +204,6 @@ pub mod sync_events { } } - /// Details about this API endpoint. - #[derive(Clone, Copy, Debug)] - pub struct Endpoint; /// Whether to set presence or not during sync. #[derive(Clone, Debug, Deserialize, Serialize)] @@ -290,12 +296,4 @@ pub mod sync_events { pub struct Presence { pub events: only::Event, } - - /// This API endpoint's reponse. - #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct Response { - pub next_batch: String, - pub rooms: Rooms, - pub presence: Presence, - } }