diff --git a/src/r0/account/whoami.rs b/src/r0/account/whoami.rs index 0f4f3ea5..cee6c52a 100644 --- a/src/r0/account/whoami.rs +++ b/src/r0/account/whoami.rs @@ -1,4 +1,4 @@ -//! [GET /_matrix/client/r0/account/whoami](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-account-whoami) +//! [GET /_matrix/client/r0/account/whoami](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-account-whoami) use ruma_api::ruma_api; diff --git a/src/r0/alias/delete_alias.rs b/src/r0/alias/delete_alias.rs index cebc3cd7..c8dbedc2 100644 --- a/src/r0/alias/delete_alias.rs +++ b/src/r0/alias/delete_alias.rs @@ -1,4 +1,4 @@ -//! [DELETE /_matrix/client/r0/directory/room/{roomAlias}](https://matrix.org/docs/spec/client_server/r0.4.0.html#delete-matrix-client-r0-directory-room-roomalias) +//! [DELETE /_matrix/client/r0/directory/room/{roomAlias}](https://matrix.org/docs/spec/client_server/r0.6.0#delete-matrix-client-r0-directory-room-roomalias) use ruma_api::ruma_api; use ruma_identifiers::RoomAliasId; diff --git a/src/r0/alias/get_alias.rs b/src/r0/alias/get_alias.rs index d2d49fb4..00ec2100 100644 --- a/src/r0/alias/get_alias.rs +++ b/src/r0/alias/get_alias.rs @@ -1,4 +1,4 @@ -//! [GET /_matrix/client/r0/directory/room/{roomAlias}](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-directory-room-roomalias) +//! [GET /_matrix/client/r0/directory/room/{roomAlias}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-directory-room-roomalias) use ruma_api::ruma_api; use ruma_identifiers::{RoomAliasId, RoomId}; diff --git a/src/r0/config/set_global_account_data.rs b/src/r0/config/set_global_account_data.rs index adc202d4..184f4cf1 100644 --- a/src/r0/config/set_global_account_data.rs +++ b/src/r0/config/set_global_account_data.rs @@ -1,4 +1,4 @@ -//! [PUT /_matrix/client/r0/user/{userId}/account_data/{type}](https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-user-userid-account-data-type) +//! [PUT /_matrix/client/r0/user/{userId}/account_data/{type}](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-user-userid-account-data-type) use ruma_api::ruma_api; use ruma_identifiers::UserId; @@ -18,11 +18,13 @@ ruma_api! { /// Arbitrary JSON to store as config data. #[ruma_api(body)] pub data: JsonValue, + /// The event type of the account_data to set. /// /// Custom types should be namespaced to avoid clashes. #[ruma_api(path)] pub event_type: String, + /// The ID of the user to set account_data for. /// /// The access token must be authorized to make requests for this user ID. diff --git a/src/r0/config/set_room_account_data.rs b/src/r0/config/set_room_account_data.rs index ff2f78bf..26949547 100644 --- a/src/r0/config/set_room_account_data.rs +++ b/src/r0/config/set_room_account_data.rs @@ -1,4 +1,4 @@ -//! [PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}](https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-user-userid-rooms-roomid-account-data-type) +//! [PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-user-userid-rooms-roomid-account-data-type) use ruma_api::ruma_api; use ruma_identifiers::{RoomId, UserId}; @@ -18,14 +18,17 @@ ruma_api! { /// Arbitrary JSON to store as config data. #[ruma_api(body)] pub data: JsonValue, + /// The event type of the account_data to set. /// /// Custom types should be namespaced to avoid clashes. #[ruma_api(path)] pub event_type: String, + /// The ID of the room to set account_data on. #[ruma_api(path)] pub room_id: RoomId, + /// The ID of the user to set account_data for. /// /// The access token must be authorized to make requests for this user ID. diff --git a/src/r0/contact/request_contact_verification_token.rs b/src/r0/contact/request_contact_verification_token.rs index ef8e4903..03cda2ee 100644 --- a/src/r0/contact/request_contact_verification_token.rs +++ b/src/r0/contact/request_contact_verification_token.rs @@ -1,4 +1,4 @@ -//! [POST /_matrix/client/r0/account/3pid/email/requestToken](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-account-3pid-email-requesttoken) +//! [POST /_matrix/client/r0/account/3pid/email/requestToken](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-account-3pid-email-requesttoken) use js_int::UInt; use ruma_api::ruma_api; @@ -16,13 +16,29 @@ ruma_api! { request { /// Client-generated secret string used to protect this session. pub client_secret: String, + /// The email address. pub email: String, - /// The ID server to send the onward request to as a hostname with an appended colon and port number if the port is not the default. + + /// A URL for the identity server to redirect the user to after + /// validation is completed. + #[serde(skip_serializing_if = "Option::is_none")] + pub next_link: Option, + + /// Used to distinguish protocol level retries from requests to re-send + /// the email. + pub send_attempt: UInt, + + /// The identity server to send the onward request to as a hostname with + /// an appended colon and port number if the port is not the default. #[serde(skip_serializing_if = "Option::is_none")] pub id_server: Option, - /// Used to distinguish protocol level retries from requests to re-send the email. - pub send_attempt: UInt, + + /// An access token previously registered with the identity server. + /// + /// Required if an `id_server` is supplied. + #[serde(skip_serializing_if = "Option::is_none")] + pub id_access_token: Option, } response {} diff --git a/src/r0/context/get_context.rs b/src/r0/context/get_context.rs index 0f39509b..a02e9ce4 100644 --- a/src/r0/context/get_context.rs +++ b/src/r0/context/get_context.rs @@ -1,4 +1,4 @@ -//! [GET /_matrix/client/r0/rooms/{roomId}/context/{eventId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-rooms-roomid-context-eventid) +//! [GET /_matrix/client/r0/rooms/{roomId}/context/{eventId}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-context-eventid) use js_int::UInt; use ruma_api::ruma_api; @@ -18,43 +18,63 @@ ruma_api! { } request { - /// The event to get context around. - #[ruma_api(path)] - pub event_id: EventId, - /// The maximum number of events to return. - /// - /// Defaults to 10 if not supplied. - #[ruma_api(query)] - #[serde(skip_serializing_if = "Option::is_none")] - pub limit: Option, /// The room to get events from. #[ruma_api(path)] pub room_id: RoomId, - /// A RoomEventFilter to filter returned events with. - #[serde(skip_serializing_if = "Option::is_none")] + + /// The event to get context around. + #[ruma_api(path)] + pub event_id: EventId, + + /// The maximum number of events to return. + /// + /// Defaults to 10. #[ruma_api(query)] + #[serde(default = "default_limit", skip_serializing_if = "is_default_limit")] + pub limit: UInt, + + /// A RoomEventFilter to filter returned events with. + #[ruma_api(query)] + #[serde(skip_serializing_if = "Option::is_none")] pub filter: Option, } response { - /// A token that can be used to paginate forwards with. - pub end: String, - /// Details of the requested event. - pub event: EventJson, - /// A list of room events that happened just after the requested event, in chronological - /// order. - - pub events_after: Vec>, - /// A list of room events that happened just before the requested event, in - /// reverse-chronological order. - - pub events_before: Vec>, /// A token that can be used to paginate backwards with. - pub start: String, - /// The state of the room at the last event returned. + #[serde(skip_serializing_if = "Option::is_none")] + pub start: Option, + /// A token that can be used to paginate forwards with. + #[serde(skip_serializing_if = "Option::is_none")] + pub end: Option, + + /// A list of room events that happened just before the requested event, + /// in reverse-chronological order. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub events_before: Vec>, + + /// Details of the requested event. + #[serde(skip_serializing_if = "Option::is_none")] + pub event: Option>, + + /// A list of room events that happened just after the requested event, + /// in chronological order. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub events_after: Vec>, + + /// The state of the room at the last event returned. + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub state: Vec>, } error: crate::Error } + +fn default_limit() -> UInt { + UInt::from(10u32) +} + +#[allow(clippy::trivially_copy_pass_by_ref)] +fn is_default_limit(val: &UInt) -> bool { + *val == default_limit() +} diff --git a/src/r0/filter.rs b/src/r0/filter.rs index 21a1649e..707a1c7b 100644 --- a/src/r0/filter.rs +++ b/src/r0/filter.rs @@ -184,21 +184,25 @@ pub struct FilterDefinition { /// include more fields than were requested. #[serde(default, skip_serializing_if = "Option::is_none")] pub event_fields: Option>, + /// The format to use for events. /// /// 'client' will return the events in a format suitable for clients. 'federation' will return /// the raw event as received over federation. The default is 'client'. #[serde(skip_serializing_if = "Option::is_none")] pub event_format: Option, - /// The user account data that isn't associated with rooms to include. - #[serde(skip_serializing_if = "Option::is_none")] - pub account_data: Option, - /// Filters to be applied to room data. - #[serde(skip_serializing_if = "Option::is_none")] - pub room: Option, + /// The presence updates to include. #[serde(skip_serializing_if = "Option::is_none")] pub presence: Option, + + /// The user account data that isn't associated with rooms to include. + #[serde(skip_serializing_if = "Option::is_none")] + pub account_data: Option, + + /// Filters to be applied to room data. + #[serde(skip_serializing_if = "Option::is_none")] + pub room: Option, } impl FilterDefinition { diff --git a/src/r0/filter/create_filter.rs b/src/r0/filter/create_filter.rs index b11d324c..a3d2dc1f 100644 --- a/src/r0/filter/create_filter.rs +++ b/src/r0/filter/create_filter.rs @@ -1,4 +1,4 @@ -//! [POST /_matrix/client/r0/user/{userId}/filter](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-user-userid-filter) +//! [POST /_matrix/client/r0/user/{userId}/filter](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-user-userid-filter) use ruma_api::ruma_api; use ruma_identifiers::UserId; @@ -16,14 +16,15 @@ ruma_api! { } request { - /// The filter definition. - #[ruma_api(body)] - pub filter: FilterDefinition, /// The ID of the user uploading the filter. /// /// The access token must be authorized to make requests for this user ID. #[ruma_api(path)] pub user_id: UserId, + + /// The filter definition. + #[ruma_api(body)] + pub filter: FilterDefinition, } response { diff --git a/src/r0/filter/get_filter.rs b/src/r0/filter/get_filter.rs index 0209d6c3..c69c57d9 100644 --- a/src/r0/filter/get_filter.rs +++ b/src/r0/filter/get_filter.rs @@ -1,4 +1,4 @@ -//! [GET /_matrix/client/r0/user/{userId}/filter/{filterId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-user-userid-filter-filterid) +//! [GET /_matrix/client/r0/user/{userId}/filter/{filterId}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-user-userid-filter-filterid) use ruma_api::ruma_api; use ruma_identifiers::UserId; @@ -16,12 +16,13 @@ ruma_api! { } request { - /// The ID of the filter to download. - #[ruma_api(path)] - pub filter_id: String, /// The user ID to download a filter for. #[ruma_api(path)] pub user_id: UserId, + + /// The ID of the filter to download. + #[ruma_api(path)] + pub filter_id: String, } response { diff --git a/src/r0/media/create_content.rs b/src/r0/media/create_content.rs index 959e8611..1f75f0de 100644 --- a/src/r0/media/create_content.rs +++ b/src/r0/media/create_content.rs @@ -1,4 +1,4 @@ -//! [POST /_matrix/media/r0/upload](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-media-r0-upload) +//! [POST /_matrix/media/r0/upload](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-media-r0-upload) use ruma_api::ruma_api; @@ -14,12 +14,15 @@ ruma_api! { request { /// The name of the file being uploaded. - #[serde(skip_serializing_if = "Option::is_none")] #[ruma_api(query)] + #[serde(skip_serializing_if = "Option::is_none")] pub filename: Option, + /// The content type of the file being uploaded. + // TODO: This should be optional. #[ruma_api(header = CONTENT_TYPE)] pub content_type: String, + /// The file contents to upload. #[ruma_api(raw_body)] pub file: Vec, diff --git a/src/r0/membership.rs b/src/r0/membership.rs index ce885afb..4acac3db 100644 --- a/src/r0/membership.rs +++ b/src/r0/membership.rs @@ -22,14 +22,17 @@ use crate::r0::thirdparty::Medium; /// identity which has been invited to the room. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ThirdPartySigned { - /// The Matrix ID of the invitee. - pub mxid: String, /// The Matrix ID of the user who issued the invite. pub sender: String, - /// A signatures object containing a signature of the entire signed object. - pub signatures: BTreeMap>, + + /// The Matrix ID of the invitee. + pub mxid: String, + /// 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: BTreeMap>, } /// Represents third party IDs to invite to the room. diff --git a/src/r0/membership/ban_user.rs b/src/r0/membership/ban_user.rs index 20ccacbc..0da3e1a8 100644 --- a/src/r0/membership/ban_user.rs +++ b/src/r0/membership/ban_user.rs @@ -1,4 +1,4 @@ -//! [POST /_matrix/client/r0/rooms/{roomId}/ban](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-rooms-roomid-ban) +//! [POST /_matrix/client/r0/rooms/{roomId}/ban](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-ban) use ruma_api::ruma_api; use ruma_identifiers::{RoomId, UserId}; @@ -14,14 +14,16 @@ ruma_api! { } request { - /// The reason for banning the user. - #[serde(skip_serializing_if = "Option::is_none")] - pub reason: Option, /// The room to kick the user from. #[ruma_api(path)] pub room_id: RoomId, + /// The user to ban. pub user_id: UserId, + + /// The reason for banning the user. + #[serde(skip_serializing_if = "Option::is_none")] + pub reason: Option, } response {} diff --git a/src/r0/membership/forget_room.rs b/src/r0/membership/forget_room.rs index ffabe3cd..39644b06 100644 --- a/src/r0/membership/forget_room.rs +++ b/src/r0/membership/forget_room.rs @@ -1,4 +1,4 @@ -//! [POST /_matrix/client/r0/rooms/{roomId}/forget](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-rooms-roomid-forget) +//! [POST /_matrix/client/r0/rooms/{roomId}/forget](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-forget) use ruma_api::ruma_api; use ruma_identifiers::RoomId; diff --git a/src/r0/membership/join_room_by_id.rs b/src/r0/membership/join_room_by_id.rs index 6555f6fc..340a677c 100644 --- a/src/r0/membership/join_room_by_id.rs +++ b/src/r0/membership/join_room_by_id.rs @@ -1,4 +1,4 @@ -//! [POST /_matrix/client/r0/rooms/{roomId}/join](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-rooms-roomid-join) +//! [POST /_matrix/client/r0/rooms/{roomId}/join](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-join) use ruma_api::ruma_api; use ruma_identifiers::RoomId; @@ -19,6 +19,7 @@ ruma_api! { /// The room where the user should be invited. #[ruma_api(path)] pub room_id: RoomId, + /// The signature of a `m.third_party_invite` token to prove that this user owns a third /// party identity which has been invited to the room. #[serde(skip_serializing_if = "Option::is_none")] diff --git a/src/r0/membership/joined_rooms.rs b/src/r0/membership/joined_rooms.rs index e9f84431..f3ec413c 100644 --- a/src/r0/membership/joined_rooms.rs +++ b/src/r0/membership/joined_rooms.rs @@ -1,4 +1,4 @@ -//! [GET /_matrix/client/r0/joined_rooms](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-joined-rooms) +//! [GET /_matrix/client/r0/joined_rooms](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-joined-rooms) use ruma_api::ruma_api; use ruma_identifiers::RoomId; @@ -16,8 +16,8 @@ ruma_api! { request {} response { - /// A list of the rooms the user is in, i.e. - /// the ID of each room in which the user has joined membership. + /// A list of the rooms the user is in, i.e. the ID of each room in + /// which the user has joined membership. pub joined_rooms: Vec, } diff --git a/src/r0/membership/kick_user.rs b/src/r0/membership/kick_user.rs index d9276324..f6c5da5b 100644 --- a/src/r0/membership/kick_user.rs +++ b/src/r0/membership/kick_user.rs @@ -1,4 +1,4 @@ -//! [POST /_matrix/client/r0/rooms/{roomId}/kick](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-rooms-roomid-kick) +//! [POST /_matrix/client/r0/rooms/{roomId}/kick](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-kick) use ruma_api::ruma_api; use ruma_identifiers::{RoomId, UserId}; @@ -14,14 +14,16 @@ ruma_api! { } request { - /// The reason for kicking the user. - #[serde(skip_serializing_if = "Option::is_none")] - pub reason: Option, /// The room to kick the user from. #[ruma_api(path)] pub room_id: RoomId, + /// The user to kick. pub user_id: UserId, + + /// The reason for kicking the user. + #[serde(skip_serializing_if = "Option::is_none")] + pub reason: Option, } response {} diff --git a/src/r0/membership/leave_room.rs b/src/r0/membership/leave_room.rs index d9487759..c0227806 100644 --- a/src/r0/membership/leave_room.rs +++ b/src/r0/membership/leave_room.rs @@ -1,4 +1,4 @@ -//! [POST /_matrix/client/r0/rooms/{roomId}/leave](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-rooms-roomid-leave) +//! [POST /_matrix/client/r0/rooms/{roomId}/leave](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-leave) use ruma_api::ruma_api; use ruma_identifiers::RoomId; diff --git a/src/r0/membership/unban_user.rs b/src/r0/membership/unban_user.rs index 27bd9e93..b754b701 100644 --- a/src/r0/membership/unban_user.rs +++ b/src/r0/membership/unban_user.rs @@ -1,4 +1,4 @@ -//! [POST /_matrix/client/r0/rooms/{roomId}/unban](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-rooms-roomid-unban) +//! [POST /_matrix/client/r0/rooms/{roomId}/unban](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-unban) use ruma_api::ruma_api; use ruma_identifiers::{RoomId, UserId}; @@ -17,6 +17,7 @@ ruma_api! { /// The room to unban the user from. #[ruma_api(path)] pub room_id: RoomId, + /// The user to unban. pub user_id: UserId, } diff --git a/src/r0/presence/set_presence.rs b/src/r0/presence/set_presence.rs index b295b5a5..4d3636f8 100644 --- a/src/r0/presence/set_presence.rs +++ b/src/r0/presence/set_presence.rs @@ -1,4 +1,4 @@ -//! [PUT /_matrix/client/r0/presence/{userId}/status](https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-presence-userid-status) +//! [PUT /_matrix/client/r0/presence/{userId}/status](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-presence-userid-status) use ruma_api::ruma_api; use ruma_events::presence::PresenceState; @@ -15,14 +15,16 @@ ruma_api! { } request { - /// The new presence state. - pub presence: PresenceState, - /// The status message to attach to this state. - #[serde(skip_serializing_if = "Option::is_none")] - pub status_msg: Option, /// The user whose presence state will be updated. #[ruma_api(path)] pub user_id: UserId, + + /// The new presence state. + pub presence: PresenceState, + + /// The status message to attach to this state. + #[serde(skip_serializing_if = "Option::is_none")] + pub status_msg: Option, } response {} diff --git a/src/r0/profile/get_avatar_url.rs b/src/r0/profile/get_avatar_url.rs index d6fa0cb5..6a950c01 100644 --- a/src/r0/profile/get_avatar_url.rs +++ b/src/r0/profile/get_avatar_url.rs @@ -1,4 +1,4 @@ -//! [GET /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-profile-userid-avatar-url) +//! [GET /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-profile-userid-avatar-url) use ruma_api::ruma_api; use ruma_identifiers::UserId; diff --git a/src/r0/profile/get_display_name.rs b/src/r0/profile/get_display_name.rs index 9f4aa150..d864cb60 100644 --- a/src/r0/profile/get_display_name.rs +++ b/src/r0/profile/get_display_name.rs @@ -1,4 +1,4 @@ -//! [GET /_matrix/client/r0/profile/{userId}/displayname](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-profile-userid-displayname) +//! [GET /_matrix/client/r0/profile/{userId}/displayname](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-profile-userid-displayname) use ruma_api::ruma_api; use ruma_identifiers::UserId; diff --git a/src/r0/profile/get_profile.rs b/src/r0/profile/get_profile.rs index 2aa014b2..5bdb781e 100644 --- a/src/r0/profile/get_profile.rs +++ b/src/r0/profile/get_profile.rs @@ -1,4 +1,4 @@ -//! [GET /_matrix/client/r0/profile/{userId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-profile-userid) +//! [GET /_matrix/client/r0/profile/{userId}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-profile-userid) use ruma_api::ruma_api; use ruma_identifiers::UserId; @@ -23,6 +23,7 @@ ruma_api! { /// The user's avatar URL, if set. #[serde(skip_serializing_if = "Option::is_none")] pub avatar_url: Option, + /// The user's display name, if set. #[serde(skip_serializing_if = "Option::is_none")] pub displayname: Option, diff --git a/src/r0/profile/set_avatar_url.rs b/src/r0/profile/set_avatar_url.rs index 6333f516..b48c4a2e 100644 --- a/src/r0/profile/set_avatar_url.rs +++ b/src/r0/profile/set_avatar_url.rs @@ -1,4 +1,4 @@ -//! [PUT /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-profile-userid-avatar-url) +//! [PUT /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-profile-userid-avatar-url) use ruma_api::ruma_api; use ruma_identifiers::UserId; @@ -14,11 +14,12 @@ ruma_api! { } request { - /// The new avatar URL for the user. - pub avatar_url: String, /// The user whose avatar URL will be set. #[ruma_api(path)] - pub user_id: UserId + pub user_id: UserId, + + /// The new avatar URL for the user. + pub avatar_url: String, } response {} diff --git a/src/r0/profile/set_display_name.rs b/src/r0/profile/set_display_name.rs index 93898a7e..147740df 100644 --- a/src/r0/profile/set_display_name.rs +++ b/src/r0/profile/set_display_name.rs @@ -1,4 +1,4 @@ -//! [PUT /_matrix/client/r0/profile/{userId}/displayname](https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-profile-userid-displayname) +//! [PUT /_matrix/client/r0/profile/{userId}/displayname](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-profile-userid-displayname) use ruma_api::ruma_api; use ruma_identifiers::UserId; @@ -14,12 +14,13 @@ ruma_api! { } request { - /// The new display name for the user. - #[serde(skip_serializing_if = "Option::is_none")] - pub displayname: Option, /// The user whose display name will be set. #[ruma_api(path)] pub user_id: UserId, + + /// The new display name for the user. + #[serde(skip_serializing_if = "Option::is_none")] + pub displayname: Option, } response {} diff --git a/src/r0/receipt/create_receipt.rs b/src/r0/receipt/create_receipt.rs index 9a963dc9..0b4b25e7 100644 --- a/src/r0/receipt/create_receipt.rs +++ b/src/r0/receipt/create_receipt.rs @@ -1,4 +1,4 @@ -//! [POST /_matrix/client/r0/rooms/{roomId}/receipt/{receiptType}/{eventId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-rooms-roomid-receipt-receipttype-eventid) +//! [POST /_matrix/client/r0/rooms/{roomId}/receipt/{receiptType}/{eventId}](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-rooms-roomid-receipt-receipttype-eventid) use std::convert::TryFrom; @@ -17,15 +17,17 @@ ruma_api! { } request { - /// The event ID to acknowledge up to. - #[ruma_api(path)] - pub event_id: EventId, - /// The type of receipt to send. - #[ruma_api(path)] - pub receipt_type: ReceiptType, /// The room in which to send the event. #[ruma_api(path)] pub room_id: RoomId, + + /// The type of receipt to send. + #[ruma_api(path)] + pub receipt_type: ReceiptType, + + /// The event ID to acknowledge up to. + #[ruma_api(path)] + pub event_id: EventId, } response {} diff --git a/src/r0/redact/redact_event.rs b/src/r0/redact/redact_event.rs index fde2818c..30bc294b 100644 --- a/src/r0/redact/redact_event.rs +++ b/src/r0/redact/redact_event.rs @@ -1,4 +1,4 @@ -//! [PUT /_matrix/client/r0/rooms/{roomId}/redact/{eventId}/{txnId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-rooms-roomid-redact-eventid-txnid) +//! [PUT /_matrix/client/r0/rooms/{roomId}/redact/{eventId}/{txnId}](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-rooms-roomid-redact-eventid-txnid) use ruma_api::ruma_api; use ruma_identifiers::{EventId, RoomId}; @@ -14,20 +14,23 @@ ruma_api! { } request { - /// The ID of the event to redact. - #[ruma_api(path)] - pub event_id: EventId, - /// The reason for the redaction. - #[serde(skip_serializing_if = "Option::is_none")] - pub reason: Option, /// The ID of the room of the event to redact. #[ruma_api(path)] pub room_id: RoomId, + + /// The ID of the event to redact. + #[ruma_api(path)] + pub event_id: EventId, + /// The transaction ID for this event. /// /// Clients should generate a unique ID; it will be used by the server to ensure idempotency of requests. #[ruma_api(path)] pub txn_id: String, + + /// The reason for the redaction. + #[serde(skip_serializing_if = "Option::is_none")] + pub reason: Option, } response { diff --git a/src/r0/search/search_events.rs b/src/r0/search/search_events.rs index ee0bb836..e2e7b240 100644 --- a/src/r0/search/search_events.rs +++ b/src/r0/search/search_events.rs @@ -1,4 +1,4 @@ -//! [POST /_matrix/client/r0/search](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-search) +//! [POST /_matrix/client/r0/search](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-search) use std::collections::BTreeMap; @@ -29,6 +29,7 @@ ruma_api! { /// If given, this should be a `next_batch` result from a previous call to this endpoint. #[ruma_api(query)] pub next_batch: Option, + /// Describes which categories to search in and their criteria. pub search_categories: Categories, } @@ -52,57 +53,85 @@ pub struct Categories { /// Criteria for searching a category of events. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Criteria { - /// Configures whether any context for the events returned are included in the response. + /// The string to search events for. + pub search_term: String, + + /// The keys to search for. Defaults to all keys. #[serde(skip_serializing_if = "Option::is_none")] - pub event_context: Option, + pub keys: Option>, + /// A `Filter` to apply to the search. #[serde(skip_serializing_if = "Option::is_none")] pub filter: Option, - /// Requests that the server partitions the result set based on the provided list of keys. - #[serde(skip_serializing_if = "Option::is_none")] - pub groupings: Option, - /// Requests the server return the current state for each room returned. - #[serde(skip_serializing_if = "Option::is_none")] - pub include_state: Option, - /// The keys to search for. Defaults to all keys. - #[serde(default, skip_serializing_if = "Vec::is_empty")] - pub keys: Vec, + /// The order in which to search for results. #[serde(skip_serializing_if = "Option::is_none")] pub order_by: Option, - /// The string to search events for. - pub search_term: String, + + /// Configures whether any context for the events returned are included in the response. + #[serde(skip_serializing_if = "Option::is_none")] + pub event_context: Option, + + /// Requests the server return the current state for each room returned. + #[serde(skip_serializing_if = "Option::is_none")] + pub include_state: Option, + + /// Requests that the server partitions the result set based on the provided list of keys. + #[serde(skip_serializing_if = "Option::is_none")] + pub groupings: Option, } /// Configures whether any context for the events returned are included in the response. #[derive(Clone, Copy, Debug, Deserialize, Serialize)] pub struct EventContext { - /// How many events after the result are returned. - #[serde(skip_serializing_if = "Option::is_none")] - pub after_limit: Option, /// How many events before the result are returned. - #[serde(skip_serializing_if = "Option::is_none")] - pub before_limit: Option, + #[serde( + default = "default_event_context_limit", + skip_serializing_if = "is_default_event_context_limit" + )] + pub before_limit: UInt, + + /// How many events after the result are returned. + #[serde( + default = "default_event_context_limit", + skip_serializing_if = "is_default_event_context_limit" + )] + pub after_limit: UInt, + /// Requests that the server returns the historic profile information for the users that /// sent the events that were returned. + #[serde(default, skip_serializing_if = "ruma_serde::is_default")] pub include_profile: bool, } +fn default_event_context_limit() -> UInt { + UInt::from(5u32) +} + +#[allow(clippy::trivially_copy_pass_by_ref)] +fn is_default_event_context_limit(val: &UInt) -> bool { + *val == default_event_context_limit() +} + /// Context for search results, if requested. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct EventContextResult { /// Pagination token for the end of the chunk. #[serde(skip_serializing_if = "Option::is_none")] pub end: Option, + /// Events just after the result. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub events_after: Vec>, + /// Events just before the result. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub events_before: Vec>, + /// The historic profile information of the users that sent the events returned. #[serde(skip_serializing_if = "Option::is_none")] pub profile_info: Option>, + /// Pagination token for the start of the chunk. #[serde(skip_serializing_if = "Option::is_none")] pub start: Option, @@ -121,6 +150,7 @@ pub struct Grouping { pub enum GroupingKey { /// `room_id` RoomId, + /// `sender` Sender, } @@ -139,9 +169,11 @@ pub enum SearchKeys { /// content.body #[serde(rename = "content.body")] ContentBody, + /// content.name #[serde(rename = "content.name")] ContentName, + /// content.topic #[serde(rename = "content.topic")] ContentTopic, @@ -151,11 +183,12 @@ pub enum SearchKeys { #[derive(Clone, Copy, Debug, Deserialize, Serialize)] #[serde(rename_all = "snake_case")] pub enum OrderBy { + /// Prioritize recent events. + Recent, + /// Prioritize events by a numerical ranking of how closely they matched the search /// criteria. Rank, - /// Prioritize recent events. - Recent, } /// Categories of events that can be searched for. diff --git a/src/r0/server/get_user_info.rs b/src/r0/server/get_user_info.rs index 5b06a70e..4f00ddd8 100644 --- a/src/r0/server/get_user_info.rs +++ b/src/r0/server/get_user_info.rs @@ -1,4 +1,4 @@ -//! [GET /_matrix/client/r0/admin/whois/{userId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-admin-whois-userid) +//! [GET /_matrix/client/r0/admin/whois/{userId}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-admin-whois-userid) use std::{collections::BTreeMap, time::SystemTime}; @@ -24,30 +24,22 @@ ruma_api! { response { /// The Matrix user ID of the user. - pub user_id: UserId, + #[serde(skip_serializing_if = "Option::is_none")] + pub user_id: Option, + /// A map of the user's device identifiers to information about that device. + #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] pub devices: BTreeMap, } error: crate::Error } -/// Information about a connection in a user session. -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct ConnectionInfo { - /// Most recently seen IP address of the session. - pub ip: String, - /// Time when that the session was last active. - #[serde(with = "ruma_serde::time::ms_since_unix_epoch")] - pub last_seen: SystemTime, - /// User agent string last seen in the session. - pub user_agent: String, -} - /// Information about a user's device. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct DeviceInfo { /// A list of user sessions on this device. + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub sessions: Vec, } @@ -55,5 +47,20 @@ pub struct DeviceInfo { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SessionInfo { /// A list of connections in this session. + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub connections: Vec, } + +/// Information about a connection in a user session. +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct ConnectionInfo { + /// Most recently seen IP address of the session. + pub ip: Option, + + /// Time when that the session was last active. + #[serde(with = "ruma_serde::time::opt_ms_since_unix_epoch")] + pub last_seen: Option, + + /// User agent string last seen in the session. + pub user_agent: Option, +} diff --git a/src/r0/session/logout.rs b/src/r0/session/logout.rs index 1c33d716..f3bd75e4 100644 --- a/src/r0/session/logout.rs +++ b/src/r0/session/logout.rs @@ -1,4 +1,4 @@ -//! [POST /_matrix/client/r0/logout](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-logout) +//! [POST /_matrix/client/r0/logout](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-logout) use ruma_api::ruma_api; diff --git a/src/r0/session/logout_all.rs b/src/r0/session/logout_all.rs index b70493b9..afc20fe1 100644 --- a/src/r0/session/logout_all.rs +++ b/src/r0/session/logout_all.rs @@ -1,4 +1,4 @@ -//! [POST /_matrix/client/r0/logout/all](https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-logout-all) +//! [POST /_matrix/client/r0/logout/all](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-logout-all) use ruma_api::ruma_api; diff --git a/src/r0/state/get_state_events.rs b/src/r0/state/get_state_events.rs index 35968905..6947b717 100644 --- a/src/r0/state/get_state_events.rs +++ b/src/r0/state/get_state_events.rs @@ -1,4 +1,4 @@ -//! [GET /_matrix/client/r0/rooms/{roomId}/state](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-rooms-roomid-state) +//! [GET /_matrix/client/r0/rooms/{roomId}/state](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-state) use ruma_api::ruma_api; use ruma_events::{collections::all::StateEvent, EventJson}; diff --git a/src/r0/state/get_state_events_for_empty_key.rs b/src/r0/state/get_state_events_for_empty_key.rs index 30747c36..42320472 100644 --- a/src/r0/state/get_state_events_for_empty_key.rs +++ b/src/r0/state/get_state_events_for_empty_key.rs @@ -1,4 +1,4 @@ -//! [GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-rooms-roomid-state-eventtype) +//! [GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-state-eventtype) use ruma_api::ruma_api; use ruma_events::EventType; @@ -19,6 +19,7 @@ ruma_api! { /// The room to look up the state for. #[ruma_api(path)] pub room_id: RoomId, + /// The type of state to look up. #[ruma_api(path)] pub event_type: EventType, diff --git a/src/r0/state/get_state_events_for_key.rs b/src/r0/state/get_state_events_for_key.rs index 5317be65..efd8c364 100644 --- a/src/r0/state/get_state_events_for_key.rs +++ b/src/r0/state/get_state_events_for_key.rs @@ -1,4 +1,4 @@ -//! [GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-rooms-roomid-state-eventtype-state-key) +//! [GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-state-eventtype-state-key) use ruma_api::ruma_api; use ruma_events::EventType; @@ -19,9 +19,11 @@ ruma_api! { /// The room to look up the state for. #[ruma_api(path)] pub room_id: RoomId, + /// The type of state to look up. #[ruma_api(path)] pub event_type: EventType, + /// The key of the state to look up. #[ruma_api(path)] pub state_key: String, diff --git a/src/r0/tag/create_tag.rs b/src/r0/tag/create_tag.rs index e0337918..36e63af9 100644 --- a/src/r0/tag/create_tag.rs +++ b/src/r0/tag/create_tag.rs @@ -1,4 +1,4 @@ -//! [PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}](https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-user-userid-rooms-roomid-tags-tag) +//! [PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-user-userid-rooms-roomid-tags-tag) use ruma_api::ruma_api; use ruma_events::tag::TagInfo; @@ -15,18 +15,21 @@ ruma_api! { } request { - /// The room to tag. - #[ruma_api(path)] - pub room_id: RoomId, - /// The name of the tag to create. - #[ruma_api(path)] - pub tag: String, - /// Info about the tag. - #[ruma_api(body)] - pub tag_info: TagInfo, /// The ID of the user creating the tag. #[ruma_api(path)] pub user_id: UserId, + + /// The room to tag. + #[ruma_api(path)] + pub room_id: RoomId, + + /// The name of the tag to create. + #[ruma_api(path)] + pub tag: String, + + /// Info about the tag. + #[ruma_api(body)] + pub tag_info: TagInfo, } response {} diff --git a/src/r0/tag/delete_tag.rs b/src/r0/tag/delete_tag.rs index 633903d9..5d086ddc 100644 --- a/src/r0/tag/delete_tag.rs +++ b/src/r0/tag/delete_tag.rs @@ -1,4 +1,4 @@ -//! [DELETE /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}](https://matrix.org/docs/spec/client_server/r0.4.0.html#delete-matrix-client-r0-user-userid-rooms-roomid-tags-tag) +//! [DELETE /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}](https://matrix.org/docs/spec/client_server/r0.6.0#delete-matrix-client-r0-user-userid-rooms-roomid-tags-tag) use ruma_api::ruma_api; use ruma_identifiers::{RoomId, UserId}; @@ -14,15 +14,17 @@ ruma_api! { } request { - /// The tagged room. - #[ruma_api(path)] - pub room_id: RoomId, - /// The name of the tag to delete. - #[ruma_api(path)] - pub tag: String, /// The user whose tag will be deleted. #[ruma_api(path)] pub user_id: UserId, + + /// The tagged room. + #[ruma_api(path)] + pub room_id: RoomId, + + /// The name of the tag to delete. + #[ruma_api(path)] + pub tag: String, } response {} diff --git a/src/r0/tag/get_tags.rs b/src/r0/tag/get_tags.rs index d02cbe27..e4e0d40d 100644 --- a/src/r0/tag/get_tags.rs +++ b/src/r0/tag/get_tags.rs @@ -1,4 +1,4 @@ -//! [GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-user-userid-rooms-roomid-tags) +//! [GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-user-userid-rooms-roomid-tags) use ruma_api::ruma_api; use ruma_events::{tag::TagEventContent, EventJson}; @@ -15,12 +15,13 @@ ruma_api! { } request { - /// The room from which tags will be retrieved. - #[ruma_api(path)] - pub room_id: RoomId, /// The user whose tags will be retrieved. #[ruma_api(path)] pub user_id: UserId, + + /// The room from which tags will be retrieved. + #[ruma_api(path)] + pub room_id: RoomId, } response { diff --git a/src/r0/typing/create_typing_event.rs b/src/r0/typing/create_typing_event.rs index 6d1a4d84..23f245ff 100644 --- a/src/r0/typing/create_typing_event.rs +++ b/src/r0/typing/create_typing_event.rs @@ -1,4 +1,4 @@ -//! [PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-rooms-roomid-typing-userid) +//! [PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}](https://matrix.org/docs/spec/client_server/r0.6.0#put-matrix-client-r0-rooms-roomid-typing-userid) use std::time::Duration; @@ -16,9 +16,19 @@ ruma_api! { } request { + /// The user who has started to type. + #[ruma_api(path)] + pub user_id: UserId, + /// The room in which the user is typing. #[ruma_api(path)] pub room_id: RoomId, + + // TODO: Group the following two body fields into an enum + + /// Whether the user is typing or not. If `false`, the `timeout` key can be omitted. + pub typing: bool, + /// The length of time in milliseconds to mark this user as typing. #[serde( with = "ruma_serde::duration::opt_ms", @@ -26,11 +36,6 @@ ruma_api! { skip_serializing_if = "Option::is_none", )] pub timeout: Option, - /// Whether the user is typing or not. If `false`, the `timeout` key can be omitted. - pub typing: bool, - /// The user who has started to type. - #[ruma_api(path)] - pub user_id: UserId, } response {} diff --git a/src/r0/voip/get_turn_server_info.rs b/src/r0/voip/get_turn_server_info.rs index 420a3382..dd056ea6 100644 --- a/src/r0/voip/get_turn_server_info.rs +++ b/src/r0/voip/get_turn_server_info.rs @@ -1,4 +1,4 @@ -//! [GET /_matrix/client/r0/voip/turnServer](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-voip-turnserver) +//! [GET /_matrix/client/r0/voip/turnServer](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-voip-turnserver) use std::time::Duration; @@ -17,15 +17,18 @@ ruma_api! { request {} response { + /// The username to use. + pub username: String, + /// The password to use. pub password: String, + + /// A list of TURN URIs. + pub uris: Vec, + /// The time-to-live in seconds. #[serde(with = "ruma_serde::duration::secs")] pub ttl: Duration, - /// A list of TURN URIs. - pub uris: Vec, - /// The username to use. - pub username: String, } error: crate::Error diff --git a/src/unversioned/discover_homeserver.rs b/src/unversioned/discover_homeserver.rs index 3c3dd557..99b076db 100644 --- a/src/unversioned/discover_homeserver.rs +++ b/src/unversioned/discover_homeserver.rs @@ -1,23 +1,9 @@ -//! [GET /.well-known/matrix/client](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-well-known-matrix-client) +//! [GET /.well-known/matrix/client](https://matrix.org/docs/spec/client_server/r0.6.0#get-well-known-matrix-client) use ruma_api::ruma_api; use serde::{Deserialize, Serialize}; use url::Url; -/// Information about a discovered homeserver. -#[derive(Clone, Debug, Deserialize, Hash, PartialEq, PartialOrd, Serialize)] -pub struct HomeserverInfo { - /// The base URL for the homeserver for client-server connections. - pub base_url: Url, -} - -/// Information about a discovered identity server. -#[derive(Clone, Debug, Deserialize, Hash, PartialEq, PartialOrd, Serialize)] -pub struct IdentityServerInfo { - /// The base URL for the identity server for client-server connections. - pub base_url: Url, -} - ruma_api! { metadata { description: "Get discovery information about the domain.", @@ -42,3 +28,17 @@ ruma_api! { error: crate::Error } + +/// Information about a discovered homeserver. +#[derive(Clone, Debug, Deserialize, Hash, PartialEq, PartialOrd, Serialize)] +pub struct HomeserverInfo { + /// The base URL for the homeserver for client-server connections. + pub base_url: Url, +} + +/// Information about a discovered identity server. +#[derive(Clone, Debug, Deserialize, Hash, PartialEq, PartialOrd, Serialize)] +pub struct IdentityServerInfo { + /// The base URL for the identity server for client-server connections. + pub base_url: Url, +}