Remove usage of ruma_api!
This commit is contained in:
		
							parent
							
								
									c5fb935472
								
							
						
					
					
						commit
						80c060cb69
					
				| @ -17,7 +17,11 @@ pub mod v1 { | ||||
|     #[cfg(any(feature = "unstable-msc2409", feature = "unstable-msc3202"))] | ||||
|     use ruma_common::OwnedUserId; | ||||
|     use ruma_common::{ | ||||
|         api::ruma_api, events::AnyTimelineEvent, serde::Raw, OwnedTransactionId, TransactionId, | ||||
|         api::{request, response, Metadata}, | ||||
|         events::AnyTimelineEvent, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|         OwnedTransactionId, TransactionId, | ||||
|     }; | ||||
|     #[cfg(feature = "unstable-msc2409")] | ||||
|     use ruma_common::{ | ||||
| @ -33,77 +37,82 @@ pub mod v1 { | ||||
|     #[cfg(feature = "unstable-msc2409")] | ||||
|     use serde_json::{value::RawValue as RawJsonValue, Value as JsonValue}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "This API is called by the homeserver when it wants to push an event (or batch of events) to the application service.", | ||||
|             method: PUT, | ||||
|             name: "push_events", | ||||
|             stable_path: "/_matrix/app/v1/transactions/:txn_id", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "This API is called by the homeserver when it wants to push an event (or batch of events) to the application service.", | ||||
|         method: PUT, | ||||
|         name: "push_events", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/app/v1/transactions/:txn_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The transaction ID for this set of events.
 | ||||
|             ///
 | ||||
|             /// Homeservers generate these IDs and they are used to ensure idempotency of results.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub txn_id: &'a TransactionId, | ||||
|     #[request] | ||||
|     pub struct Request<'a> { | ||||
|         /// The transaction ID for this set of events.
 | ||||
|         ///
 | ||||
|         /// Homeservers generate these IDs and they are used to ensure idempotency of results.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub txn_id: &'a TransactionId, | ||||
| 
 | ||||
|             /// A list of events.
 | ||||
|             pub events: &'a [Raw<AnyTimelineEvent>], | ||||
|         /// A list of events.
 | ||||
|         pub events: &'a [Raw<AnyTimelineEvent>], | ||||
| 
 | ||||
|             /// Information on E2E device updates.
 | ||||
|             #[cfg(feature = "unstable-msc3202")] | ||||
|             #[serde(
 | ||||
|                 default, | ||||
|                 skip_serializing_if = "DeviceLists::is_empty", | ||||
|                 rename = "org.matrix.msc3202.device_lists" | ||||
|             )] | ||||
|             pub device_lists: DeviceLists, | ||||
|         /// Information on E2E device updates.
 | ||||
|         #[cfg(feature = "unstable-msc3202")] | ||||
|         #[serde(
 | ||||
|             default, | ||||
|             skip_serializing_if = "DeviceLists::is_empty", | ||||
|             rename = "org.matrix.msc3202.device_lists" | ||||
|         )] | ||||
|         pub device_lists: DeviceLists, | ||||
| 
 | ||||
|             /// The number of unclaimed one-time keys currently held on the server for this device, for each algorithm.
 | ||||
|             #[cfg(feature = "unstable-msc3202")] | ||||
|             #[serde(
 | ||||
|                 default, | ||||
|                 skip_serializing_if = "BTreeMap::is_empty", | ||||
|                 rename = "org.matrix.msc3202.device_one_time_keys_count" | ||||
|             )] | ||||
|             pub device_one_time_keys_count: BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, BTreeMap<DeviceKeyAlgorithm, UInt>>>, | ||||
|         /// The number of unclaimed one-time keys currently held on the server for this device, for
 | ||||
|         /// each algorithm.
 | ||||
|         #[cfg(feature = "unstable-msc3202")] | ||||
|         #[serde(
 | ||||
|             default, | ||||
|             skip_serializing_if = "BTreeMap::is_empty", | ||||
|             rename = "org.matrix.msc3202.device_one_time_keys_count" | ||||
|         )] | ||||
|         pub device_one_time_keys_count: | ||||
|             BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, BTreeMap<DeviceKeyAlgorithm, UInt>>>, | ||||
| 
 | ||||
|             /// A list of key algorithms for which the server has an unused fallback key for the device.
 | ||||
|             #[cfg(feature = "unstable-msc3202")] | ||||
|             #[serde(
 | ||||
|                 default, | ||||
|                 skip_serializing_if = "BTreeMap::is_empty", | ||||
|                 rename = "org.matrix.msc3202.device_unused_fallback_key_types" | ||||
|             )] | ||||
|             pub device_unused_fallback_key_types: BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, Vec<DeviceKeyAlgorithm>>>, | ||||
|         /// A list of key algorithms for which the server has an unused fallback key for the
 | ||||
|         /// device.
 | ||||
|         #[cfg(feature = "unstable-msc3202")] | ||||
|         #[serde(
 | ||||
|             default, | ||||
|             skip_serializing_if = "BTreeMap::is_empty", | ||||
|             rename = "org.matrix.msc3202.device_unused_fallback_key_types" | ||||
|         )] | ||||
|         pub device_unused_fallback_key_types: | ||||
|             BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, Vec<DeviceKeyAlgorithm>>>, | ||||
| 
 | ||||
|             /// A list of EDUs.
 | ||||
|             #[cfg(feature = "unstable-msc2409")] | ||||
|             #[serde(
 | ||||
|                 default, | ||||
|                 skip_serializing_if = "<[_]>::is_empty", | ||||
|                 rename = "de.sorunome.msc2409.ephemeral" | ||||
|             )] | ||||
|             pub ephemeral: &'a [Edu], | ||||
|         /// A list of EDUs.
 | ||||
|         #[cfg(feature = "unstable-msc2409")] | ||||
|         #[serde(
 | ||||
|             default, | ||||
|             skip_serializing_if = "<[_]>::is_empty", | ||||
|             rename = "de.sorunome.msc2409.ephemeral" | ||||
|         )] | ||||
|         pub ephemeral: &'a [Edu], | ||||
| 
 | ||||
|             /// A list of to-device messages.
 | ||||
|             #[cfg(feature = "unstable-msc2409")] | ||||
|             #[serde(
 | ||||
|                 default, | ||||
|                 skip_serializing_if = "<[_]>::is_empty", | ||||
|                 rename = "de.sorunome.msc2409.to_device" | ||||
|             )] | ||||
|             pub to_device: &'a [Raw<AnyToDeviceEvent>] | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
|         /// A list of to-device messages.
 | ||||
|         #[cfg(feature = "unstable-msc2409")] | ||||
|         #[serde(
 | ||||
|             default, | ||||
|             skip_serializing_if = "<[_]>::is_empty", | ||||
|             rename = "de.sorunome.msc2409.to_device" | ||||
|         )] | ||||
|         pub to_device: &'a [Raw<AnyToDeviceEvent>], | ||||
|     } | ||||
| 
 | ||||
|     #[response] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given transaction ID and list of events.
 | ||||
|         pub fn new(txn_id: &'a TransactionId, events: &'a [Raw<AnyTimelineEvent>]) -> Self { | ||||
|  | ||||
| @ -5,7 +5,7 @@ | ||||
| //!
 | ||||
| //! [appservice-api]: https://spec.matrix.org/v1.4/application-service-api/
 | ||||
| 
 | ||||
| #![warn(missing_docs)] | ||||
| // #![warn(missing_docs)] FIXME
 | ||||
| 
 | ||||
| use serde::{Deserialize, Serialize}; | ||||
| 
 | ||||
|  | ||||
| @ -7,29 +7,33 @@ pub mod v1 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/application-service-api/#get_matrixappv1roomsroomalias
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, RoomAliasId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, RoomAliasId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "This endpoint is invoked by the homeserver on an application service to query the existence of a given room alias.", | ||||
|             method: GET, | ||||
|             name: "query_room_alias", | ||||
|             stable_path: "/_matrix/app/v1/rooms/:room_alias", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "This endpoint is invoked by the homeserver on an application service to query the existence of a given room alias.", | ||||
|         method: GET, | ||||
|         name: "query_room_alias", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/app/v1/rooms/:room_alias", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The room alias being queried.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_alias: &'a RoomAliasId, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
|     #[request] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room alias being queried.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_alias: &'a RoomAliasId, | ||||
|     } | ||||
| 
 | ||||
|     #[response] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room alias.
 | ||||
|         pub fn new(room_alias: &'a RoomAliasId) -> Self { | ||||
|  | ||||
| @ -7,29 +7,33 @@ pub mod v1 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/application-service-api/#get_matrixappv1usersuserid
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, UserId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, UserId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "This endpoint is invoked by the homeserver on an application service to query the existence of a given user ID.", | ||||
|             method: GET, | ||||
|             name: "query_user_id", | ||||
|             stable_path: "/_matrix/app/v1/users/:user_id", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "This endpoint is invoked by the homeserver on an application service to query the existence of a given user ID.", | ||||
|         method: GET, | ||||
|         name: "query_user_id", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/app/v1/users/:user_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The user ID being queried.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: &'a UserId, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
|     #[request] | ||||
|     pub struct Request<'a> { | ||||
|         /// The user ID being queried.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
|     } | ||||
| 
 | ||||
|     #[response] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given user id.
 | ||||
|         pub fn new(user_id: &'a UserId) -> Self { | ||||
|  | ||||
| @ -10,35 +10,40 @@ pub mod v1 { | ||||
| 
 | ||||
|     use std::collections::BTreeMap; | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, thirdparty::Location}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         thirdparty::Location, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Fetches third party locations for a protocol.", | ||||
|             method: GET, | ||||
|             name: "get_location_for_protocol", | ||||
|             stable_path: "/_matrix/app/v1/thirdparty/location/:protocol", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Fetches third party locations for a protocol.", | ||||
|         method: GET, | ||||
|         name: "get_location_for_protocol", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/app/v1/thirdparty/location/:protocol", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The protocol used to communicate to the third party network.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub protocol: &'a str, | ||||
|     #[request] | ||||
|     pub struct Request<'a> { | ||||
|         /// The protocol used to communicate to the third party network.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub protocol: &'a str, | ||||
| 
 | ||||
|             /// One or more custom fields to help identify the third party location.
 | ||||
|             // The specification is incorrect for this parameter. See [matrix-spec#560](https://github.com/matrix-org/matrix-spec/issues/560).
 | ||||
|             #[ruma_api(query_map)] | ||||
|             pub fields: BTreeMap<String, String>, | ||||
|         } | ||||
|         /// One or more custom fields to help identify the third party location.
 | ||||
|         // The specification is incorrect for this parameter. See [matrix-spec#560](https://github.com/matrix-org/matrix-spec/issues/560).
 | ||||
|         #[ruma_api(query_map)] | ||||
|         pub fields: BTreeMap<String, String>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// List of matched third party locations.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub locations: Vec<Location>, | ||||
|         } | ||||
|     #[response] | ||||
|     pub struct Response { | ||||
|         /// List of matched third party locations.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub locations: Vec<Location>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -7,30 +7,36 @@ pub mod v1 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/application-service-api/#get_matrixappv1thirdpartylocation
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, thirdparty::Location, RoomAliasId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         thirdparty::Location, | ||||
|         RoomAliasId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Retrieve an array of third party network locations from a Matrix room alias.", | ||||
|             method: GET, | ||||
|             name: "get_location_for_room_alias", | ||||
|             stable_path: "/_matrix/app/v1/thirdparty/location", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Retrieve an array of third party network locations from a Matrix room alias.", | ||||
|         method: GET, | ||||
|         name: "get_location_for_room_alias", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/app/v1/thirdparty/location", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The Matrix room alias to look up.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub alias: &'a RoomAliasId, | ||||
|         } | ||||
|     #[request] | ||||
|     pub struct Request<'a> { | ||||
|         /// The Matrix room alias to look up.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub alias: &'a RoomAliasId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// List of matched third party locations.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub locations: Vec<Location>, | ||||
|         } | ||||
|     #[response] | ||||
|     pub struct Response { | ||||
|         /// List of matched third party locations.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub locations: Vec<Location>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -8,30 +8,35 @@ pub mod v1 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/application-service-api/#get_matrixappv1thirdpartyprotocolprotocol
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, thirdparty::Protocol}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         thirdparty::Protocol, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Fetches the metadata from the homeserver about a particular third party protocol.", | ||||
|             method: GET, | ||||
|             name: "get_protocol", | ||||
|             stable_path: "/_matrix/app/v1/thirdparty/protocol/:protocol", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Fetches the metadata from the homeserver about a particular third party protocol.", | ||||
|         method: GET, | ||||
|         name: "get_protocol", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/app/v1/thirdparty/protocol/:protocol", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The name of the protocol.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub protocol: &'a str, | ||||
|         } | ||||
|     #[request] | ||||
|     pub struct Request<'a> { | ||||
|         /// The name of the protocol.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub protocol: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// Metadata about the protocol.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub protocol: Protocol, | ||||
|         } | ||||
|     #[response] | ||||
|     pub struct Response { | ||||
|         /// Metadata about the protocol.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub protocol: Protocol, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -10,35 +10,40 @@ pub mod v1 { | ||||
| 
 | ||||
|     use std::collections::BTreeMap; | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, thirdparty::User}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         thirdparty::User, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Fetches third party users for a protocol.", | ||||
|             method: GET, | ||||
|             name: "get_user_for_protocol", | ||||
|             stable_path: "/_matrix/app/v1/thirdparty/user/:protocol", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Fetches third party users for a protocol.", | ||||
|         method: GET, | ||||
|         name: "get_user_for_protocol", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/app/v1/thirdparty/user/:protocol", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The protocol used to communicate to the third party network.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub protocol: &'a str, | ||||
|     #[request] | ||||
|     pub struct Request<'a> { | ||||
|         /// The protocol used to communicate to the third party network.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub protocol: &'a str, | ||||
| 
 | ||||
|             /// One or more custom fields that are passed to the AS to help identify the user.
 | ||||
|             // The specification is incorrect for this parameter. See [matrix-spec#560](https://github.com/matrix-org/matrix-spec/issues/560).
 | ||||
|             #[ruma_api(query_map)] | ||||
|             pub fields: BTreeMap<String, String>, | ||||
|         } | ||||
|         /// One or more custom fields that are passed to the AS to help identify the user.
 | ||||
|         // The specification is incorrect for this parameter. See [matrix-spec#560](https://github.com/matrix-org/matrix-spec/issues/560).
 | ||||
|         #[ruma_api(query_map)] | ||||
|         pub fields: BTreeMap<String, String>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// List of matched third party users.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub users: Vec<User>, | ||||
|         } | ||||
|     #[response] | ||||
|     pub struct Response { | ||||
|         /// List of matched third party users.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub users: Vec<User>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -7,30 +7,36 @@ pub mod v1 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/application-service-api/#get_matrixappv1thirdpartyuser
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, thirdparty::User, UserId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         thirdparty::User, | ||||
|         UserId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Retrieve an array of third party users from a Matrix User ID.", | ||||
|             method: GET, | ||||
|             name: "get_user_for_user_id", | ||||
|             stable_path: "/_matrix/app/v1/thirdparty/user", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Retrieve an array of third party users from a Matrix User ID.", | ||||
|         method: GET, | ||||
|         name: "get_user_for_user_id", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/app/v1/thirdparty/user", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The Matrix User ID to look up.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub userid: &'a UserId, | ||||
|         } | ||||
|     #[request] | ||||
|     pub struct Request<'a> { | ||||
|         /// The Matrix User ID to look up.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub userid: &'a UserId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// List of matched third party users.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub users: Vec<User>, | ||||
|         } | ||||
|     #[response] | ||||
|     pub struct Response { | ||||
|         /// List of matched third party users.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub users: Vec<User>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,40 +5,42 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3account3pidadd
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, ClientSecret, SessionId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, ClientSecret, SessionId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::uiaa::{AuthData, IncomingAuthData, UiaaResponse}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Add contact information to a user's account", | ||||
|             method: POST, | ||||
|             name: "add_3pid", | ||||
|             r0_path: "/_matrix/client/r0/account/3pid/add", | ||||
|             stable_path: "/_matrix/client/v3/account/3pid/add", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Add contact information to a user's account", | ||||
|         method: POST, | ||||
|         name: "add_3pid", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/3pid/add", | ||||
|             1.1 => "/_matrix/client/v3/account/3pid/add", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// Additional information for the User-Interactive Authentication API.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub auth: Option<AuthData<'a>>, | ||||
|     #[request(error = UiaaResponse)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Additional information for the User-Interactive Authentication API.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub auth: Option<AuthData<'a>>, | ||||
| 
 | ||||
|             /// Client-generated secret string used to protect this session.
 | ||||
|             pub client_secret: &'a ClientSecret, | ||||
|         /// Client-generated secret string used to protect this session.
 | ||||
|         pub client_secret: &'a ClientSecret, | ||||
| 
 | ||||
|             /// The session identifier given by the identity server.
 | ||||
|             pub sid: &'a SessionId, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: UiaaResponse | ||||
|         /// The session identifier given by the identity server.
 | ||||
|         pub sid: &'a SessionId, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = UiaaResponse)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given client secret and session identifier.
 | ||||
|         pub fn new(client_secret: &'a ClientSecret, sid: &'a SessionId) -> Self { | ||||
|  | ||||
| @ -5,41 +5,43 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3account3pidbind
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, ClientSecret, SessionId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, ClientSecret, SessionId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::account::{IdentityServerInfo, IncomingIdentityServerInfo}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Bind a 3PID to a user's account on an identity server", | ||||
|             method: POST, | ||||
|             name: "bind_3pid", | ||||
|             r0_path: "/_matrix/client/r0/account/3pid/bind", | ||||
|             stable_path: "/_matrix/client/v3/account/3pid/bind", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Bind a 3PID to a user's account on an identity server", | ||||
|         method: POST, | ||||
|         name: "bind_3pid", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/3pid/bind", | ||||
|             1.1 => "/_matrix/client/v3/account/3pid/bind", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// Client-generated secret string used to protect this session.
 | ||||
|             pub client_secret: &'a ClientSecret, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Client-generated secret string used to protect this session.
 | ||||
|         pub client_secret: &'a ClientSecret, | ||||
| 
 | ||||
|             /// 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.
 | ||||
|             #[serde(flatten)] | ||||
|             pub identity_server_info: IdentityServerInfo<'a>, | ||||
|         /// 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.
 | ||||
|         #[serde(flatten)] | ||||
|         pub identity_server_info: IdentityServerInfo<'a>, | ||||
| 
 | ||||
|             /// The session identifier given by the identity server.
 | ||||
|             pub sid: &'a SessionId, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The session identifier given by the identity server.
 | ||||
|         pub sid: &'a SessionId, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given client secret, identity server information and
 | ||||
|         /// session identifier.
 | ||||
|  | ||||
| @ -5,47 +5,52 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3accountpassword
 | ||||
| 
 | ||||
|     use ruma_common::api::ruma_api; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::uiaa::{AuthData, IncomingAuthData, UiaaResponse}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Change the password of the current user's account.", | ||||
|             method: POST, | ||||
|             name: "change_password", | ||||
|             r0_path: "/_matrix/client/r0/account/password", | ||||
|             stable_path: "/_matrix/client/v3/account/password", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Change the password of the current user's account.", | ||||
|         method: POST, | ||||
|         name: "change_password", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/password", | ||||
|             1.1 => "/_matrix/client/v3/account/password", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The new password for the account.
 | ||||
|             pub new_password: &'a str, | ||||
|     #[request(error = UiaaResponse)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The new password for the account.
 | ||||
|         pub new_password: &'a str, | ||||
| 
 | ||||
|             /// True to revoke the user's other access tokens, and their associated devices if the
 | ||||
|             /// request succeeds.
 | ||||
|             ///
 | ||||
|             /// Defaults to true.
 | ||||
|             ///
 | ||||
|             /// When false, the server can still take advantage of the soft logout method for the user's
 | ||||
|             /// remaining devices.
 | ||||
|             #[serde(default = "ruma_common::serde::default_true", skip_serializing_if = "ruma_common::serde::is_true")] | ||||
|             pub logout_devices: bool, | ||||
|         /// True to revoke the user's other access tokens, and their associated devices if the
 | ||||
|         /// request succeeds.
 | ||||
|         ///
 | ||||
|         /// Defaults to true.
 | ||||
|         ///
 | ||||
|         /// When false, the server can still take advantage of the soft logout method for the
 | ||||
|         /// user's remaining devices.
 | ||||
|         #[serde(
 | ||||
|             default = "ruma_common::serde::default_true", | ||||
|             skip_serializing_if = "ruma_common::serde::is_true" | ||||
|         )] | ||||
|         pub logout_devices: bool, | ||||
| 
 | ||||
|             /// Additional authentication information for the user-interactive authentication API.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub auth: Option<AuthData<'a>>, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: UiaaResponse | ||||
|         /// Additional authentication information for the user-interactive authentication API.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub auth: Option<AuthData<'a>>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = UiaaResponse)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given password.
 | ||||
|         pub fn new(new_password: &'a str) -> Self { | ||||
|  | ||||
| @ -5,32 +5,34 @@ pub mod v1 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv1registermloginregistration_tokenvalidity
 | ||||
| 
 | ||||
|     use ruma_common::api::ruma_api; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Checks to see if the given registration token is valid.", | ||||
|             method: GET, | ||||
|             name: "check_registration_token_validity", | ||||
|             unstable_path: "/_matrix/client/unstable/org.matrix.msc3231/register/org.matrix.msc3231.login.registration_token/validity", | ||||
|             stable_path: "/_matrix/client/v1/register/m.login.registration_token/validity", | ||||
|             rate_limited: true, | ||||
|             authentication: None, | ||||
|             added: 1.2, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Checks to see if the given registration token is valid.", | ||||
|         method: GET, | ||||
|         name: "check_registration_token_validity", | ||||
|         rate_limited: true, | ||||
|         authentication: None, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/org.matrix.msc3231/register/org.matrix.msc3231.login.registration_token/validity", | ||||
|             1.2 => "/_matrix/client/v1/register/m.login.registration_token/validity", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The registration token to check the validity of.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub registration_token: &'a str, | ||||
|         } | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The registration token to check the validity of.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub registration_token: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// A flag to indicate that the registration token is valid.
 | ||||
|             pub valid: bool, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A flag to indicate that the registration token is valid.
 | ||||
|         pub valid: bool, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,43 +5,45 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3accountdeactivate
 | ||||
| 
 | ||||
|     use ruma_common::api::ruma_api; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::{ | ||||
|         account::ThirdPartyIdRemovalStatus, | ||||
|         uiaa::{AuthData, IncomingAuthData, UiaaResponse}, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Deactivate the current user's account.", | ||||
|             method: POST, | ||||
|             name: "deactivate", | ||||
|             r0_path: "/_matrix/client/r0/account/deactivate", | ||||
|             stable_path: "/_matrix/client/v3/account/deactivate", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Deactivate the current user's account.", | ||||
|         method: POST, | ||||
|         name: "deactivate", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/deactivate", | ||||
|             1.1 => "/_matrix/client/v3/account/deactivate", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         request: { | ||||
|             /// Additional authentication information for the user-interactive authentication API.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub auth: Option<AuthData<'a>>, | ||||
|     #[request(error = UiaaResponse)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Additional authentication information for the user-interactive authentication API.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub auth: Option<AuthData<'a>>, | ||||
| 
 | ||||
|             /// Identity server from which to unbind the user's third party
 | ||||
|             /// identifier.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub id_server: Option<&'a str>, | ||||
|         } | ||||
|         /// Identity server from which to unbind the user's third party
 | ||||
|         /// identifier.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub id_server: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// Result of unbind operation.
 | ||||
|             pub id_server_unbind_result: ThirdPartyIdRemovalStatus, | ||||
|         } | ||||
| 
 | ||||
|         error: UiaaResponse | ||||
|     #[response(error = UiaaResponse)] | ||||
|     pub struct Response { | ||||
|         /// Result of unbind operation.
 | ||||
|         pub id_server_unbind_result: ThirdPartyIdRemovalStatus, | ||||
|     } | ||||
| 
 | ||||
|     impl Request<'_> { | ||||
|  | ||||
| @ -5,40 +5,43 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3account3piddelete
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, thirdparty::Medium}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         thirdparty::Medium, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::account::ThirdPartyIdRemovalStatus; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Delete a 3PID from a user's account on an identity server.", | ||||
|             method: POST, | ||||
|             name: "delete_3pid", | ||||
|             r0_path: "/_matrix/client/r0/account/3pid/delete", | ||||
|             stable_path: "/_matrix/client/v3/account/3pid/delete", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Delete a 3PID from a user's account on an identity server.", | ||||
|         method: POST, | ||||
|         name: "delete_3pid", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/3pid/delete", | ||||
|             1.1 => "/_matrix/client/v3/account/3pid/delete", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// Identity server to delete from.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub id_server: Option<&'a str>, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Identity server to delete from.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub id_server: Option<&'a str>, | ||||
| 
 | ||||
|             /// Medium of the 3PID to be removed.
 | ||||
|             pub medium: Medium, | ||||
|         /// Medium of the 3PID to be removed.
 | ||||
|         pub medium: Medium, | ||||
| 
 | ||||
|             /// Third-party address being removed.
 | ||||
|             pub address: &'a str, | ||||
|         } | ||||
|         /// Third-party address being removed.
 | ||||
|         pub address: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// Result of unbind operation.
 | ||||
|             pub id_server_unbind_result: ThirdPartyIdRemovalStatus, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// Result of unbind operation.
 | ||||
|         pub id_server_unbind_result: ThirdPartyIdRemovalStatus, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,32 +5,37 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3account3pid
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, thirdparty::ThirdPartyIdentifier}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         thirdparty::ThirdPartyIdentifier, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get a list of 3rd party contacts associated with the user's account.", | ||||
|             method: GET, | ||||
|             name: "get_3pids", | ||||
|             r0_path: "/_matrix/client/r0/account/3pid", | ||||
|             stable_path: "/_matrix/client/v3/account/3pid", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get a list of 3rd party contacts associated with the user's account.", | ||||
|         method: GET, | ||||
|         name: "get_3pids", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/3pid", | ||||
|             1.1 => "/_matrix/client/v3/account/3pid", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         request: {} | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Request {} | ||||
| 
 | ||||
|         response: { | ||||
|             /// A list of third party identifiers the homeserver has associated with the user's account.
 | ||||
|             #[serde(default)] | ||||
|             #[cfg_attr(not(feature = "compat"), serde(skip_serializing_if = "Vec::is_empty"))] | ||||
|             pub threepids: Vec<ThirdPartyIdentifier>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A list of third party identifiers the homeserver has associated with the user's
 | ||||
|         /// account.
 | ||||
|         #[serde(default)] | ||||
|         #[cfg_attr(not(feature = "compat"), serde(skip_serializing_if = "Vec::is_empty"))] | ||||
|         pub threepids: Vec<ThirdPartyIdentifier>, | ||||
|     } | ||||
| 
 | ||||
|     impl Request { | ||||
|         /// Creates an empty `Request`.
 | ||||
|         pub fn new() -> Self { | ||||
|  | ||||
| @ -5,33 +5,35 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3registeravailable
 | ||||
| 
 | ||||
|     use ruma_common::api::ruma_api; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Checks to see if a username is available, and valid, for the server.", | ||||
|             method: GET, | ||||
|             name: "get_username_availability", | ||||
|             r0_path: "/_matrix/client/r0/register/available", | ||||
|             stable_path: "/_matrix/client/v3/register/available", | ||||
|             rate_limited: true, | ||||
|             authentication: None, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Checks to see if a username is available, and valid, for the server.", | ||||
|         method: GET, | ||||
|         name: "get_username_availability", | ||||
|         rate_limited: true, | ||||
|         authentication: None, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/register/available", | ||||
|             1.1 => "/_matrix/client/v3/register/available", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The username to check the availability of.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub username: &'a str, | ||||
|         } | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The username to check the availability of.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub username: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// A flag to indicate that the username is available.
 | ||||
|             /// This should always be true when the server replies with 200 OK.
 | ||||
|             pub available: bool, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A flag to indicate that the username is available.
 | ||||
|         /// This should always be true when the server replies with 200 OK.
 | ||||
|         pub available: bool, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -9,138 +9,140 @@ pub mod v3 { | ||||
| 
 | ||||
|     use std::time::Duration; | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, DeviceId, OwnedDeviceId, OwnedUserId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, DeviceId, OwnedDeviceId, OwnedUserId, | ||||
|     }; | ||||
| 
 | ||||
|     use super::{LoginType, RegistrationKind}; | ||||
|     use crate::uiaa::{AuthData, IncomingAuthData, UiaaResponse}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Register an account on this homeserver.", | ||||
|             method: POST, | ||||
|             name: "register", | ||||
|             r0_path: "/_matrix/client/r0/register", | ||||
|             stable_path: "/_matrix/client/v3/register", | ||||
|             rate_limited: true, | ||||
|             authentication: None, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Register an account on this homeserver.", | ||||
|         method: POST, | ||||
|         name: "register", | ||||
|         rate_limited: true, | ||||
|         authentication: None, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/register", | ||||
|             1.1 => "/_matrix/client/v3/register", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         request: { | ||||
|             /// The desired password for the account.
 | ||||
|             ///
 | ||||
|             /// May be empty for accounts that should not be able to log in again
 | ||||
|             /// with a password, e.g., for guest or application service accounts.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub password: Option<&'a str>, | ||||
|     #[request(error = UiaaResponse)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The desired password for the account.
 | ||||
|         ///
 | ||||
|         /// May be empty for accounts that should not be able to log in again
 | ||||
|         /// with a password, e.g., for guest or application service accounts.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub password: Option<&'a str>, | ||||
| 
 | ||||
|             /// Localpart of the desired Matrix ID.
 | ||||
|             ///
 | ||||
|             /// If omitted, the homeserver MUST generate a Matrix ID local part.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub username: Option<&'a str>, | ||||
|         /// Localpart of the desired Matrix ID.
 | ||||
|         ///
 | ||||
|         /// If omitted, the homeserver MUST generate a Matrix ID local part.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub username: Option<&'a str>, | ||||
| 
 | ||||
|             /// ID of the client device.
 | ||||
|             ///
 | ||||
|             /// If this does not correspond to a known client device, a new device will be created.
 | ||||
|             /// The server will auto-generate a device_id if this is not specified.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub device_id: Option<&'a DeviceId>, | ||||
|         /// ID of the client device.
 | ||||
|         ///
 | ||||
|         /// If this does not correspond to a known client device, a new device will be created.
 | ||||
|         /// The server will auto-generate a device_id if this is not specified.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub device_id: Option<&'a DeviceId>, | ||||
| 
 | ||||
|             /// A display name to assign to the newly-created device.
 | ||||
|             ///
 | ||||
|             /// Ignored if `device_id` corresponds to a known device.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub initial_device_display_name: Option<&'a str>, | ||||
|         /// A display name to assign to the newly-created device.
 | ||||
|         ///
 | ||||
|         /// Ignored if `device_id` corresponds to a known device.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub initial_device_display_name: Option<&'a str>, | ||||
| 
 | ||||
|             /// Additional authentication information for the user-interactive authentication API.
 | ||||
|             ///
 | ||||
|             /// Note that this information is not used to define how the registered user should be
 | ||||
|             /// authenticated, but is instead used to authenticate the register call itself.
 | ||||
|             /// It should be left empty, or omitted, unless an earlier call returned an response
 | ||||
|             /// with status code 401.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub auth: Option<AuthData<'a>>, | ||||
|         /// Additional authentication information for the user-interactive authentication API.
 | ||||
|         ///
 | ||||
|         /// Note that this information is not used to define how the registered user should be
 | ||||
|         /// authenticated, but is instead used to authenticate the register call itself.
 | ||||
|         /// It should be left empty, or omitted, unless an earlier call returned an response
 | ||||
|         /// with status code 401.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub auth: Option<AuthData<'a>>, | ||||
| 
 | ||||
|             /// Kind of account to register
 | ||||
|             ///
 | ||||
|             /// Defaults to `User` if omitted.
 | ||||
|             #[ruma_api(query)] | ||||
|             #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")] | ||||
|             pub kind: RegistrationKind, | ||||
|         /// Kind of account to register
 | ||||
|         ///
 | ||||
|         /// Defaults to `User` if omitted.
 | ||||
|         #[ruma_api(query)] | ||||
|         #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")] | ||||
|         pub kind: RegistrationKind, | ||||
| 
 | ||||
|             /// If `true`, an `access_token` and `device_id` should not be returned
 | ||||
|             /// from this call, therefore preventing an automatic login.
 | ||||
|             #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")] | ||||
|             pub inhibit_login: bool, | ||||
|         /// If `true`, an `access_token` and `device_id` should not be returned
 | ||||
|         /// from this call, therefore preventing an automatic login.
 | ||||
|         #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")] | ||||
|         pub inhibit_login: bool, | ||||
| 
 | ||||
|             /// Login `type` used by Appservices.
 | ||||
|             ///
 | ||||
|             /// Appservices can [bypass the registration flows][admin] entirely by providing their
 | ||||
|             /// token in the header and setting this login `type` to `m.login.application_service`.
 | ||||
|             ///
 | ||||
|             /// [admin]: https://spec.matrix.org/v1.4/application-service-api/#server-admin-style-permissions
 | ||||
|             #[serde(rename = "type", skip_serializing_if = "Option::is_none")] | ||||
|             pub login_type: Option<&'a LoginType>, | ||||
|         /// Login `type` used by Appservices.
 | ||||
|         ///
 | ||||
|         /// Appservices can [bypass the registration flows][admin] entirely by providing their
 | ||||
|         /// token in the header and setting this login `type` to `m.login.application_service`.
 | ||||
|         ///
 | ||||
|         /// [admin]: https://spec.matrix.org/v1.4/application-service-api/#server-admin-style-permissions
 | ||||
|         #[serde(rename = "type", skip_serializing_if = "Option::is_none")] | ||||
|         pub login_type: Option<&'a LoginType>, | ||||
| 
 | ||||
|             /// If set to `true`, the client supports [refresh tokens].
 | ||||
|             ///
 | ||||
|             /// [refresh tokens]: https://spec.matrix.org/v1.4/client-server-api/#refreshing-access-tokens
 | ||||
|             #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")] | ||||
|             pub refresh_token: bool, | ||||
|         } | ||||
|         /// If set to `true`, the client supports [refresh tokens].
 | ||||
|         ///
 | ||||
|         /// [refresh tokens]: https://spec.matrix.org/v1.4/client-server-api/#refreshing-access-tokens
 | ||||
|         #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")] | ||||
|         pub refresh_token: bool, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// An access token for the account.
 | ||||
|             ///
 | ||||
|             /// This access token can then be used to authorize other requests.
 | ||||
|             ///
 | ||||
|             /// Required if the request's `inhibit_login` was set to `false`.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub access_token: Option<String>, | ||||
|     #[response(error = UiaaResponse)] | ||||
|     pub struct Response { | ||||
|         /// An access token for the account.
 | ||||
|         ///
 | ||||
|         /// This access token can then be used to authorize other requests.
 | ||||
|         ///
 | ||||
|         /// Required if the request's `inhibit_login` was set to `false`.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub access_token: Option<String>, | ||||
| 
 | ||||
|             /// The fully-qualified Matrix ID that has been registered.
 | ||||
|             pub user_id: OwnedUserId, | ||||
|         /// The fully-qualified Matrix ID that has been registered.
 | ||||
|         pub user_id: OwnedUserId, | ||||
| 
 | ||||
|             /// ID of the registered device.
 | ||||
|             ///
 | ||||
|             /// Will be the same as the corresponding parameter in the request, if one was specified.
 | ||||
|             ///
 | ||||
|             /// Required if the request's `inhibit_login` was set to `false`.
 | ||||
|             pub device_id: Option<OwnedDeviceId>, | ||||
|         /// ID of the registered device.
 | ||||
|         ///
 | ||||
|         /// Will be the same as the corresponding parameter in the request, if one was specified.
 | ||||
|         ///
 | ||||
|         /// Required if the request's `inhibit_login` was set to `false`.
 | ||||
|         pub device_id: Option<OwnedDeviceId>, | ||||
| 
 | ||||
|             /// A [refresh token] for the account.
 | ||||
|             ///
 | ||||
|             /// This token can be used to obtain a new access token when it expires by calling the
 | ||||
|             /// [`refresh_token`] endpoint.
 | ||||
|             ///
 | ||||
|             /// Omitted if the request's `inhibit_login` was set to `true`.
 | ||||
|             ///
 | ||||
|             /// [refresh token]: https://spec.matrix.org/v1.4/client-server-api/#refreshing-access-tokens
 | ||||
|             /// [`refresh_token`]: crate::session::refresh_token
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub refresh_token: Option<String>, | ||||
|         /// A [refresh token] for the account.
 | ||||
|         ///
 | ||||
|         /// This token can be used to obtain a new access token when it expires by calling the
 | ||||
|         /// [`refresh_token`] endpoint.
 | ||||
|         ///
 | ||||
|         /// Omitted if the request's `inhibit_login` was set to `true`.
 | ||||
|         ///
 | ||||
|         /// [refresh token]: https://spec.matrix.org/v1.4/client-server-api/#refreshing-access-tokens
 | ||||
|         /// [`refresh_token`]: crate::session::refresh_token
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub refresh_token: Option<String>, | ||||
| 
 | ||||
|             /// The lifetime of the access token, in milliseconds.
 | ||||
|             ///
 | ||||
|             /// Once the access token has expired, a new access token can be obtained by using the
 | ||||
|             /// provided refresh token. If no refresh token is provided, the client will need to
 | ||||
|             /// re-login to obtain a new access token.
 | ||||
|             ///
 | ||||
|             /// If this is `None`, the client can assume that the access token will not expire.
 | ||||
|             ///
 | ||||
|             /// Omitted if the request's `inhibit_login` was set to `true`.
 | ||||
|             #[serde(
 | ||||
|                 with = "ruma_common::serde::duration::opt_ms", | ||||
|                 default, | ||||
|                 skip_serializing_if = "Option::is_none", | ||||
|                 rename = "expires_in_ms", | ||||
|             )] | ||||
|             pub expires_in: Option<Duration>, | ||||
|         } | ||||
| 
 | ||||
|         error: UiaaResponse | ||||
|         /// The lifetime of the access token, in milliseconds.
 | ||||
|         ///
 | ||||
|         /// Once the access token has expired, a new access token can be obtained by using the
 | ||||
|         /// provided refresh token. If no refresh token is provided, the client will need to
 | ||||
|         /// re-login to obtain a new access token.
 | ||||
|         ///
 | ||||
|         /// If this is `None`, the client can assume that the access token will not expire.
 | ||||
|         ///
 | ||||
|         /// Omitted if the request's `inhibit_login` was set to `true`.
 | ||||
|         #[serde(
 | ||||
|             with = "ruma_common::serde::duration::opt_ms", | ||||
|             default, | ||||
|             skip_serializing_if = "Option::is_none", | ||||
|             rename = "expires_in_ms" | ||||
|         )] | ||||
|         pub expires_in: Option<Duration>, | ||||
|     } | ||||
| 
 | ||||
|     impl Request<'_> { | ||||
|  | ||||
| @ -6,62 +6,64 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3account3pidemailrequesttoken
 | ||||
| 
 | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::{api::ruma_api, ClientSecret, OwnedSessionId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, ClientSecret, OwnedSessionId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::account::{IdentityServerInfo, IncomingIdentityServerInfo}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Request a 3PID management token with a 3rd party email.", | ||||
|             method: POST, | ||||
|             name: "request_3pid_management_token_via_email", | ||||
|             r0_path: "/_matrix/client/r0/account/3pid/email/requestToken", | ||||
|             stable_path: "/_matrix/client/v3/account/3pid/email/requestToken", | ||||
|             rate_limited: false, | ||||
|             authentication: None, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Request a 3PID management token with a 3rd party email.", | ||||
|         method: POST, | ||||
|         name: "request_3pid_management_token_via_email", | ||||
|         rate_limited: false, | ||||
|         authentication: None, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/3pid/email/requestToken", | ||||
|             1.1 => "/_matrix/client/v3/account/3pid/email/requestToken", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// Client-generated secret string used to protect this session.
 | ||||
|             pub client_secret: &'a ClientSecret, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Client-generated secret string used to protect this session.
 | ||||
|         pub client_secret: &'a ClientSecret, | ||||
| 
 | ||||
|             /// The email address.
 | ||||
|             pub email: &'a str, | ||||
|         /// The email address.
 | ||||
|         pub email: &'a str, | ||||
| 
 | ||||
|             /// Used to distinguish protocol level retries from requests to re-send the email.
 | ||||
|             pub send_attempt: UInt, | ||||
|         /// Used to distinguish protocol level retries from requests to re-send the email.
 | ||||
|         pub send_attempt: UInt, | ||||
| 
 | ||||
|             /// Return URL for identity server to redirect the client back to.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub next_link: Option<&'a str>, | ||||
|         /// Return URL for identity server to redirect the client back to.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub next_link: Option<&'a str>, | ||||
| 
 | ||||
|             /// Optional identity server hostname and access token.
 | ||||
|             ///
 | ||||
|             /// Deprecated since r0.6.0.
 | ||||
|             #[serde(flatten, skip_serializing_if = "Option::is_none")] | ||||
|             pub identity_server_info: Option<IdentityServerInfo<'a>>, | ||||
|         } | ||||
|         /// Optional identity server hostname and access token.
 | ||||
|         ///
 | ||||
|         /// Deprecated since r0.6.0.
 | ||||
|         #[serde(flatten, skip_serializing_if = "Option::is_none")] | ||||
|         pub identity_server_info: Option<IdentityServerInfo<'a>>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// The session identifier given by the identity server.
 | ||||
|             pub sid: OwnedSessionId, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The session identifier given by the identity server.
 | ||||
|         pub sid: OwnedSessionId, | ||||
| 
 | ||||
|             /// URL to submit validation token to.
 | ||||
|             ///
 | ||||
|             /// If omitted, verification happens without client.
 | ||||
|             ///
 | ||||
|             /// If you activate the `compat` feature, this field being an empty string in JSON will
 | ||||
|             /// result in `None` here during deserialization.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[cfg_attr(
 | ||||
|                 feature = "compat", | ||||
|                 serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") | ||||
|             )] | ||||
|             pub submit_url: Option<String>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// URL to submit validation token to.
 | ||||
|         ///
 | ||||
|         /// If omitted, verification happens without client.
 | ||||
|         ///
 | ||||
|         /// If you activate the `compat` feature, this field being an empty string in JSON will
 | ||||
|         /// result in `None` here during deserialization.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[cfg_attr(
 | ||||
|             feature = "compat", | ||||
|             serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") | ||||
|         )] | ||||
|         pub submit_url: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -6,66 +6,69 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3account3pidmsisdnrequesttoken
 | ||||
| 
 | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::{api::ruma_api, ClientSecret, OwnedSessionId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, ClientSecret, OwnedSessionId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::account::{IdentityServerInfo, IncomingIdentityServerInfo}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Request a 3PID management token with a phone number.", | ||||
|             method: POST, | ||||
|             name: "request_3pid_management_token_via_msisdn", | ||||
|             r0_path: "/_matrix/client/r0/account/3pid/msisdn/requestToken", | ||||
|             stable_path: "/_matrix/client/v3/account/3pid/msisdn/requestToken", | ||||
|             rate_limited: false, | ||||
|             authentication: None, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Request a 3PID management token with a phone number.", | ||||
|         method: POST, | ||||
|         name: "request_3pid_management_token_via_msisdn", | ||||
|         rate_limited: false, | ||||
|         authentication: None, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/3pid/msisdn/requestToken", | ||||
|             1.1 => "/_matrix/client/v3/account/3pid/msisdn/requestToken", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// Client-generated secret string used to protect this session.
 | ||||
|             pub client_secret: &'a ClientSecret, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Client-generated secret string used to protect this session.
 | ||||
|         pub client_secret: &'a ClientSecret, | ||||
| 
 | ||||
|             /// Two-letter ISO 3166 country code for the phone number.
 | ||||
|             pub country: &'a str, | ||||
|         /// Two-letter ISO 3166 country code for the phone number.
 | ||||
|         pub country: &'a str, | ||||
| 
 | ||||
|             /// Phone number to validate.
 | ||||
|             pub phone_number: &'a str, | ||||
|         /// Phone number to validate.
 | ||||
|         pub phone_number: &'a str, | ||||
| 
 | ||||
|             /// Used to distinguish protocol level retries from requests to re-send the SMS.
 | ||||
|             pub send_attempt: UInt, | ||||
|         /// Used to distinguish protocol level retries from requests to re-send the SMS.
 | ||||
|         pub send_attempt: UInt, | ||||
| 
 | ||||
|             /// Return URL for identity server to redirect the client back to.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub next_link: Option<&'a str>, | ||||
|         /// Return URL for identity server to redirect the client back to.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub next_link: Option<&'a str>, | ||||
| 
 | ||||
|             /// Optional identity server hostname and access token.
 | ||||
|             ///
 | ||||
|             /// Deprecated since r0.6.0.
 | ||||
|             #[serde(flatten, skip_serializing_if = "Option::is_none")] | ||||
|             pub identity_server_info: Option<IdentityServerInfo<'a>>, | ||||
|         } | ||||
| 
 | ||||
|         response: { | ||||
|             /// The session identifier given by the identity server.
 | ||||
|             pub sid: OwnedSessionId, | ||||
| 
 | ||||
|             /// URL to submit validation token to.
 | ||||
|             ///
 | ||||
|             /// If omitted, verification happens without client.
 | ||||
|             ///
 | ||||
|             /// If you activate the `compat` feature, this field being an empty string in JSON will
 | ||||
|             /// result in `None` here during deserialization.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[cfg_attr(
 | ||||
|                 feature = "compat", | ||||
|                 serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") | ||||
|             )] | ||||
|             pub submit_url: Option<String>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// Optional identity server hostname and access token.
 | ||||
|         ///
 | ||||
|         /// Deprecated since r0.6.0.
 | ||||
|         #[serde(flatten, skip_serializing_if = "Option::is_none")] | ||||
|         pub identity_server_info: Option<IdentityServerInfo<'a>>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The session identifier given by the identity server.
 | ||||
|         pub sid: OwnedSessionId, | ||||
| 
 | ||||
|         /// URL to submit validation token to.
 | ||||
|         ///
 | ||||
|         /// If omitted, verification happens without client.
 | ||||
|         ///
 | ||||
|         /// If you activate the `compat` feature, this field being an empty string in JSON will
 | ||||
|         /// result in `None` here during deserialization.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[cfg_attr(
 | ||||
|             feature = "compat", | ||||
|             serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") | ||||
|         )] | ||||
|         pub submit_url: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given client secret, country code, phone number and
 | ||||
|         /// send-attempt counter.
 | ||||
|  | ||||
| @ -7,42 +7,45 @@ pub mod v3 { | ||||
| 
 | ||||
|     use std::time::Duration; | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, authentication::TokenType, OwnedServerName, UserId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         authentication::TokenType, | ||||
|         metadata, OwnedServerName, UserId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Request an OpenID 1.0 token to verify identity with a third party.", | ||||
|             name: "request_openid_token", | ||||
|             method: POST, | ||||
|             r0_path: "/_matrix/client/r0/user/:user_id/openid/request_token", | ||||
|             stable_path: "/_matrix/client/v3/user/:user_id/openid/request_token", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Request an OpenID 1.0 token to verify identity with a third party.", | ||||
|         method: POST, | ||||
|         name: "request_openid_token", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/user/:user_id/openid/request_token", | ||||
|             1.1 => "/_matrix/client/v3/user/:user_id/openid/request_token", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// User ID of authenticated user.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: &'a UserId, | ||||
|         } | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// User ID of authenticated user.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// Access token for verifying user's identity.
 | ||||
|             pub access_token: String, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// Access token for verifying user's identity.
 | ||||
|         pub access_token: String, | ||||
| 
 | ||||
|             /// Access token type.
 | ||||
|             pub token_type: TokenType, | ||||
|         /// Access token type.
 | ||||
|         pub token_type: TokenType, | ||||
| 
 | ||||
|             /// Homeserver domain for verification of user's identity.
 | ||||
|             pub matrix_server_name: OwnedServerName, | ||||
|         /// Homeserver domain for verification of user's identity.
 | ||||
|         pub matrix_server_name: OwnedServerName, | ||||
| 
 | ||||
|             /// Seconds until token expiration.
 | ||||
|             #[serde(with = "ruma_common::serde::duration::secs")] | ||||
|             pub expires_in: Duration, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// Seconds until token expiration.
 | ||||
|         #[serde(with = "ruma_common::serde::duration::secs")] | ||||
|         pub expires_in: Duration, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -6,62 +6,64 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3accountpasswordemailrequesttoken
 | ||||
| 
 | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::{api::ruma_api, ClientSecret, OwnedSessionId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, ClientSecret, OwnedSessionId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::account::{IdentityServerInfo, IncomingIdentityServerInfo}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Request that a password change token is sent to the given email address.", | ||||
|             method: POST, | ||||
|             name: "request_password_change_token_via_email", | ||||
|             r0_path: "/_matrix/client/r0/account/password/email/requestToken", | ||||
|             stable_path: "/_matrix/client/v3/account/password/email/requestToken", | ||||
|             rate_limited: false, | ||||
|             authentication: None, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Request that a password change token is sent to the given email address.", | ||||
|         method: POST, | ||||
|         name: "request_password_change_token_via_email", | ||||
|         rate_limited: false, | ||||
|         authentication: None, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/password/email/requestToken", | ||||
|             1.1 => "/_matrix/client/v3/account/password/email/requestToken", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// Client-generated secret string used to protect this session.
 | ||||
|             pub client_secret: &'a ClientSecret, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Client-generated secret string used to protect this session.
 | ||||
|         pub client_secret: &'a ClientSecret, | ||||
| 
 | ||||
|             /// The email address.
 | ||||
|             pub email: &'a str, | ||||
|         /// The email address.
 | ||||
|         pub email: &'a str, | ||||
| 
 | ||||
|             /// Used to distinguish protocol level retries from requests to re-send the email.
 | ||||
|             pub send_attempt: UInt, | ||||
|         /// Used to distinguish protocol level retries from requests to re-send the email.
 | ||||
|         pub send_attempt: UInt, | ||||
| 
 | ||||
|             /// Return URL for identity server to redirect the client back to.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub next_link: Option<&'a str>, | ||||
|         /// Return URL for identity server to redirect the client back to.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub next_link: Option<&'a str>, | ||||
| 
 | ||||
|             /// Optional identity server hostname and access token.
 | ||||
|             ///
 | ||||
|             /// Deprecated since r0.6.0.
 | ||||
|             #[serde(flatten, skip_serializing_if = "Option::is_none")] | ||||
|             pub identity_server_info: Option<IdentityServerInfo<'a>>, | ||||
|         } | ||||
|         /// Optional identity server hostname and access token.
 | ||||
|         ///
 | ||||
|         /// Deprecated since r0.6.0.
 | ||||
|         #[serde(flatten, skip_serializing_if = "Option::is_none")] | ||||
|         pub identity_server_info: Option<IdentityServerInfo<'a>>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// The session identifier given by the identity server.
 | ||||
|             pub sid: OwnedSessionId, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The session identifier given by the identity server.
 | ||||
|         pub sid: OwnedSessionId, | ||||
| 
 | ||||
|             /// URL to submit validation token to.
 | ||||
|             ///
 | ||||
|             /// If omitted, verification happens without client.
 | ||||
|             ///
 | ||||
|             /// If you activate the `compat` feature, this field being an empty string in JSON will result
 | ||||
|             /// in `None` here during deserialization.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[cfg_attr(
 | ||||
|                 feature = "compat", | ||||
|                 serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") | ||||
|             )] | ||||
|             pub submit_url: Option<String>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// URL to submit validation token to.
 | ||||
|         ///
 | ||||
|         /// If omitted, verification happens without client.
 | ||||
|         ///
 | ||||
|         /// If you activate the `compat` feature, this field being an empty string in JSON will
 | ||||
|         /// result in `None` here during deserialization.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[cfg_attr(
 | ||||
|             feature = "compat", | ||||
|             serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") | ||||
|         )] | ||||
|         pub submit_url: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -6,57 +6,59 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3accountpasswordmsisdnrequesttoken
 | ||||
| 
 | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::{api::ruma_api, ClientSecret, OwnedSessionId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, ClientSecret, OwnedSessionId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Request that a password change token is sent to the given phone number.", | ||||
|             method: POST, | ||||
|             name: "request_password_change_token_via_msisdn", | ||||
|             r0_path: "/_matrix/client/r0/account/password/msisdn/requestToken", | ||||
|             stable_path: "/_matrix/client/v3/account/password/msisdn/requestToken", | ||||
|             rate_limited: false, | ||||
|             authentication: None, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Request that a password change token is sent to the given phone number.", | ||||
|         method: POST, | ||||
|         name: "request_password_change_token_via_msisdn", | ||||
|         rate_limited: false, | ||||
|         authentication: None, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/password/msisdn/requestToken", | ||||
|             1.1 => "/_matrix/client/v3/account/password/msisdn/requestToken", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// Client-generated secret string used to protect this session.
 | ||||
|             pub client_secret: &'a ClientSecret, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Client-generated secret string used to protect this session.
 | ||||
|         pub client_secret: &'a ClientSecret, | ||||
| 
 | ||||
|             /// Two-letter ISO 3166 country code for the phone number.
 | ||||
|             pub country: &'a str, | ||||
|         /// Two-letter ISO 3166 country code for the phone number.
 | ||||
|         pub country: &'a str, | ||||
| 
 | ||||
|             /// Phone number to validate.
 | ||||
|             pub phone_number: &'a str, | ||||
|         /// Phone number to validate.
 | ||||
|         pub phone_number: &'a str, | ||||
| 
 | ||||
|             /// Used to distinguish protocol level retries from requests to re-send the SMS.
 | ||||
|             pub send_attempt: UInt, | ||||
|         /// Used to distinguish protocol level retries from requests to re-send the SMS.
 | ||||
|         pub send_attempt: UInt, | ||||
| 
 | ||||
|             /// Return URL for identity server to redirect the client back to.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub next_link: Option<&'a str>, | ||||
|         } | ||||
|         /// Return URL for identity server to redirect the client back to.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub next_link: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// The session identifier given by the identity server.
 | ||||
|             pub sid: OwnedSessionId, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The session identifier given by the identity server.
 | ||||
|         pub sid: OwnedSessionId, | ||||
| 
 | ||||
|             /// URL to submit validation token to.
 | ||||
|             ///
 | ||||
|             /// If omitted, verification happens without client.
 | ||||
|             ///
 | ||||
|             /// If you activate the `compat` feature, this field being an empty string in JSON will result
 | ||||
|             /// in `None` here during deserialization.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[cfg_attr(
 | ||||
|                 feature = "compat", | ||||
|                 serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") | ||||
|             )] | ||||
|             pub submit_url: Option<String>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// URL to submit validation token to.
 | ||||
|         ///
 | ||||
|         /// If omitted, verification happens without client.
 | ||||
|         ///
 | ||||
|         /// If you activate the `compat` feature, this field being an empty string in JSON will
 | ||||
|         /// result in `None` here during deserialization.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[cfg_attr(
 | ||||
|             feature = "compat", | ||||
|             serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") | ||||
|         )] | ||||
|         pub submit_url: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -6,62 +6,64 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3registeremailrequesttoken
 | ||||
| 
 | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::{api::ruma_api, ClientSecret, OwnedSessionId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, ClientSecret, OwnedSessionId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::account::{IdentityServerInfo, IncomingIdentityServerInfo}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Request a registration token with a 3rd party email.", | ||||
|             method: POST, | ||||
|             name: "request_registration_token_via_email", | ||||
|             r0_path: "/_matrix/client/r0/register/email/requestToken", | ||||
|             stable_path: "/_matrix/client/v3/register/email/requestToken", | ||||
|             rate_limited: false, | ||||
|             authentication: None, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Request a registration token with a 3rd party email.", | ||||
|         method: POST, | ||||
|         name: "request_registration_token_via_email", | ||||
|         rate_limited: false, | ||||
|         authentication: None, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/register/email/requestToken", | ||||
|             1.1 => "/_matrix/client/v3/register/email/requestToken", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// Client-generated secret string used to protect this session.
 | ||||
|             pub client_secret: &'a ClientSecret, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Client-generated secret string used to protect this session.
 | ||||
|         pub client_secret: &'a ClientSecret, | ||||
| 
 | ||||
|             /// The email address.
 | ||||
|             pub email: &'a str, | ||||
|         /// The email address.
 | ||||
|         pub email: &'a str, | ||||
| 
 | ||||
|             /// Used to distinguish protocol level retries from requests to re-send the email.
 | ||||
|             pub send_attempt: UInt, | ||||
|         /// Used to distinguish protocol level retries from requests to re-send the email.
 | ||||
|         pub send_attempt: UInt, | ||||
| 
 | ||||
|             /// Return URL for identity server to redirect the client back to.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub next_link: Option<&'a str>, | ||||
|         /// Return URL for identity server to redirect the client back to.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub next_link: Option<&'a str>, | ||||
| 
 | ||||
|             /// Optional identity server hostname and access token.
 | ||||
|             ///
 | ||||
|             /// Deprecated since r0.6.0.
 | ||||
|             #[serde(flatten, skip_serializing_if = "Option::is_none")] | ||||
|             pub identity_server_info: Option<IdentityServerInfo<'a>>, | ||||
|         } | ||||
|         /// Optional identity server hostname and access token.
 | ||||
|         ///
 | ||||
|         /// Deprecated since r0.6.0.
 | ||||
|         #[serde(flatten, skip_serializing_if = "Option::is_none")] | ||||
|         pub identity_server_info: Option<IdentityServerInfo<'a>>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// The session identifier given by the identity server.
 | ||||
|             pub sid: OwnedSessionId, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The session identifier given by the identity server.
 | ||||
|         pub sid: OwnedSessionId, | ||||
| 
 | ||||
|             /// URL to submit validation token to.
 | ||||
|             ///
 | ||||
|             /// If omitted, verification happens without client.
 | ||||
|             ///
 | ||||
|             /// If you activate the `compat` feature, this field being an empty string in JSON will result
 | ||||
|             /// in `None` here during deserialization.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[cfg_attr(
 | ||||
|                 feature = "compat", | ||||
|                 serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") | ||||
|             )] | ||||
|             pub submit_url: Option<String>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// URL to submit validation token to.
 | ||||
|         ///
 | ||||
|         /// If omitted, verification happens without client.
 | ||||
|         ///
 | ||||
|         /// If you activate the `compat` feature, this field being an empty string in JSON will
 | ||||
|         /// result in `None` here during deserialization.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[cfg_attr(
 | ||||
|             feature = "compat", | ||||
|             serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") | ||||
|         )] | ||||
|         pub submit_url: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -6,65 +6,67 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3registermsisdnrequesttoken
 | ||||
| 
 | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::{api::ruma_api, ClientSecret, OwnedSessionId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, ClientSecret, OwnedSessionId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::account::{IdentityServerInfo, IncomingIdentityServerInfo}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Request a registration token with a phone number.", | ||||
|             method: POST, | ||||
|             name: "request_registration_token_via_msisdn", | ||||
|             r0_path: "/_matrix/client/r0/register/msisdn/requestToken", | ||||
|             stable_path: "/_matrix/client/v3/register/msisdn/requestToken", | ||||
|             rate_limited: false, | ||||
|             authentication: None, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Request a registration token with a phone number.", | ||||
|         method: POST, | ||||
|         name: "request_registration_token_via_msisdn", | ||||
|         rate_limited: false, | ||||
|         authentication: None, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/register/msisdn/requestToken", | ||||
|             1.1 => "/_matrix/client/v3/register/msisdn/requestToken", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// Client-generated secret string used to protect this session.
 | ||||
|             pub client_secret: &'a ClientSecret, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Client-generated secret string used to protect this session.
 | ||||
|         pub client_secret: &'a ClientSecret, | ||||
| 
 | ||||
|             /// Two-letter ISO 3166 country code for the phone number.
 | ||||
|             pub country: &'a str, | ||||
|         /// Two-letter ISO 3166 country code for the phone number.
 | ||||
|         pub country: &'a str, | ||||
| 
 | ||||
|             /// Phone number to validate.
 | ||||
|             pub phone_number: &'a str, | ||||
|         /// Phone number to validate.
 | ||||
|         pub phone_number: &'a str, | ||||
| 
 | ||||
|             /// Used to distinguish protocol level retries from requests to re-send the SMS.
 | ||||
|             pub send_attempt: UInt, | ||||
|         /// Used to distinguish protocol level retries from requests to re-send the SMS.
 | ||||
|         pub send_attempt: UInt, | ||||
| 
 | ||||
|             /// Return URL for identity server to redirect the client back to.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub next_link: Option<&'a str>, | ||||
|         /// Return URL for identity server to redirect the client back to.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub next_link: Option<&'a str>, | ||||
| 
 | ||||
|             /// Optional identity server hostname and access token.
 | ||||
|             ///
 | ||||
|             /// Deprecated since r0.6.0.
 | ||||
|             #[serde(flatten, skip_serializing_if = "Option::is_none")] | ||||
|             pub identity_server_info: Option<IdentityServerInfo<'a>>, | ||||
|         } | ||||
|         /// Optional identity server hostname and access token.
 | ||||
|         ///
 | ||||
|         /// Deprecated since r0.6.0.
 | ||||
|         #[serde(flatten, skip_serializing_if = "Option::is_none")] | ||||
|         pub identity_server_info: Option<IdentityServerInfo<'a>>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// The session identifier given by the identity server.
 | ||||
|             pub sid: OwnedSessionId, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The session identifier given by the identity server.
 | ||||
|         pub sid: OwnedSessionId, | ||||
| 
 | ||||
|             /// URL to submit validation token to.
 | ||||
|             ///
 | ||||
|             /// If omitted, verification happens without client.
 | ||||
|             ///
 | ||||
|             /// If you activate the `compat` feature, this field being an empty string in JSON will result
 | ||||
|             /// in `None` here during deserialization.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[cfg_attr(
 | ||||
|                 feature = "compat", | ||||
|                 serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") | ||||
|             )] | ||||
|             pub submit_url: Option<String>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// URL to submit validation token to.
 | ||||
|         ///
 | ||||
|         /// If omitted, verification happens without client.
 | ||||
|         ///
 | ||||
|         /// If you activate the `compat` feature, this field being an empty string in JSON will
 | ||||
|         /// result in `None` here during deserialization.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[cfg_attr(
 | ||||
|             feature = "compat", | ||||
|             serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") | ||||
|         )] | ||||
|         pub submit_url: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,40 +5,43 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3account3pidunbind
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, thirdparty::Medium}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         thirdparty::Medium, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::account::ThirdPartyIdRemovalStatus; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Unbind a 3PID from a user's account on an identity server.", | ||||
|             method: POST, | ||||
|             name: "unbind_3pid", | ||||
|             r0_path: "/_matrix/client/r0/account/3pid/unbind", | ||||
|             stable_path: "/_matrix/client/v3/account/3pid/unbind", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Unbind a 3PID from a user's account on an identity server.", | ||||
|         method: POST, | ||||
|         name: "unbind_3pid", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/3pid/unbind", | ||||
|             1.1 => "/_matrix/client/v3/account/3pid/unbind", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// Identity server to unbind from.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub id_server: Option<&'a str>, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Identity server to unbind from.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub id_server: Option<&'a str>, | ||||
| 
 | ||||
|             /// Medium of the 3PID to be removed.
 | ||||
|             pub medium: Medium, | ||||
|         /// Medium of the 3PID to be removed.
 | ||||
|         pub medium: Medium, | ||||
| 
 | ||||
|             /// Third-party address being removed.
 | ||||
|             pub address: &'a str, | ||||
|         } | ||||
|         /// Third-party address being removed.
 | ||||
|         pub address: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// Result of unbind operation.
 | ||||
|             pub id_server_unbind_result: ThirdPartyIdRemovalStatus, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// Result of unbind operation.
 | ||||
|         pub id_server_unbind_result: ThirdPartyIdRemovalStatus, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,37 +5,39 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3accountwhoami
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, OwnedDeviceId, OwnedUserId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, OwnedDeviceId, OwnedUserId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get information about the owner of a given access token.", | ||||
|             method: GET, | ||||
|             name: "whoami", | ||||
|             r0_path: "/_matrix/client/r0/account/whoami", | ||||
|             stable_path: "/_matrix/client/v3/account/whoami", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get information about the owner of a given access token.", | ||||
|         method: GET, | ||||
|         name: "whoami", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/whoami", | ||||
|             1.1 => "/_matrix/client/v3/account/whoami", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         request: {} | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Request {} | ||||
| 
 | ||||
|         response: { | ||||
|             /// The id of the user that owns the access token.
 | ||||
|             pub user_id: OwnedUserId, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The id of the user that owns the access token.
 | ||||
|         pub user_id: OwnedUserId, | ||||
| 
 | ||||
|             /// The device ID associated with the access token, if any.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub device_id: Option<OwnedDeviceId>, | ||||
|         /// The device ID associated with the access token, if any.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub device_id: Option<OwnedDeviceId>, | ||||
| 
 | ||||
|             /// If `true`, the user is a guest user.
 | ||||
|             #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")] | ||||
|             pub is_guest: bool, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// If `true`, the user is a guest user.
 | ||||
|         #[serde(default, skip_serializing_if = "ruma_common::serde::is_default")] | ||||
|         pub is_guest: bool, | ||||
|     } | ||||
| 
 | ||||
|     impl Request { | ||||
|  | ||||
| @ -5,35 +5,37 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#put_matrixclientv3directoryroomroomalias
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, RoomAliasId, RoomId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, RoomAliasId, RoomId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Add an alias to a room.", | ||||
|             method: PUT, | ||||
|             name: "create_alias", | ||||
|             r0_path: "/_matrix/client/r0/directory/room/:room_alias", | ||||
|             stable_path: "/_matrix/client/v3/directory/room/:room_alias", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Add an alias to a room.", | ||||
|         method: PUT, | ||||
|         name: "create_alias", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/directory/room/:room_alias", | ||||
|             1.1 => "/_matrix/client/v3/directory/room/:room_alias", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The room alias to set.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_alias: &'a RoomAliasId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room alias to set.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_alias: &'a RoomAliasId, | ||||
| 
 | ||||
|             /// The room ID to set.
 | ||||
|             pub room_id: &'a RoomId, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The room ID to set.
 | ||||
|         pub room_id: &'a RoomId, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room alias and room id.
 | ||||
|         pub fn new(room_alias: &'a RoomAliasId, room_id: &'a RoomId) -> Self { | ||||
|  | ||||
| @ -5,32 +5,34 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#delete_matrixclientv3directoryroomroomalias
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, RoomAliasId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, RoomAliasId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Remove an alias from a room.", | ||||
|             method: DELETE, | ||||
|             name: "delete_alias", | ||||
|             r0_path: "/_matrix/client/r0/directory/room/:room_alias", | ||||
|             stable_path: "/_matrix/client/v3/directory/room/:room_alias", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Remove an alias from a room.", | ||||
|         method: DELETE, | ||||
|         name: "delete_alias", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/directory/room/:room_alias", | ||||
|             1.1 => "/_matrix/client/v3/directory/room/:room_alias", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The room alias to remove.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_alias: &'a RoomAliasId, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room alias to remove.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_alias: &'a RoomAliasId, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room alias.
 | ||||
|         pub fn new(room_alias: &'a RoomAliasId) -> Self { | ||||
|  | ||||
| @ -5,35 +5,37 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3directoryroomroomalias
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, OwnedRoomId, OwnedServerName, RoomAliasId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, OwnedRoomId, OwnedServerName, RoomAliasId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Resolve a room alias to a room ID.", | ||||
|             method: GET, | ||||
|             name: "get_alias", | ||||
|             r0_path: "/_matrix/client/r0/directory/room/:room_alias", | ||||
|             stable_path: "/_matrix/client/v3/directory/room/:room_alias", | ||||
|             rate_limited: false, | ||||
|             authentication: None, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Resolve a room alias to a room ID.", | ||||
|         method: GET, | ||||
|         name: "get_alias", | ||||
|         rate_limited: false, | ||||
|         authentication: None, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/directory/room/:room_alias", | ||||
|             1.1 => "/_matrix/client/v3/directory/room/:room_alias", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The room alias.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_alias: &'a RoomAliasId, | ||||
|         } | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room alias.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_alias: &'a RoomAliasId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// The room ID for this room alias.
 | ||||
|             pub room_id: OwnedRoomId, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The room ID for this room alias.
 | ||||
|         pub room_id: OwnedRoomId, | ||||
| 
 | ||||
|             /// A list of servers that are aware of this room ID.
 | ||||
|             pub servers: Vec<OwnedServerName>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// A list of servers that are aware of this room ID.
 | ||||
|         pub servers: Vec<OwnedServerName>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,41 +5,43 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/application-service-api/#put_matrixclientv3directorylistappservicenetworkidroomid
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, RoomId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, RoomId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::room::Visibility; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Updates the visibility of a given room on the application service's room directory.", | ||||
|             method: PUT, | ||||
|             name: "set_room_visibility", | ||||
|             r0_path: "/_matrix/client/r0/directory/list/appservice/:network_id/:room_id", | ||||
|             stable_path: "/_matrix/client/v3/directory/list/appservice/:network_id/:room_id", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Updates the visibility of a given room on the application service's room directory.", | ||||
|         method: PUT, | ||||
|         name: "set_room_visibility", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/directory/list/appservice/:network_id/:room_id", | ||||
|             1.1 => "/_matrix/client/v3/directory/list/appservice/:network_id/:room_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The protocol (network) ID to update the room list for.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub network_id: &'a str, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The protocol (network) ID to update the room list for.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub network_id: &'a str, | ||||
| 
 | ||||
|             /// The room ID to add to the directory.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|         /// The room ID to add to the directory.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| 
 | ||||
|             /// Whether the room should be visible (public) in the directory or not (private).
 | ||||
|             pub visibility: Visibility, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// Whether the room should be visible (public) in the directory or not (private).
 | ||||
|         pub visibility: Visibility, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given network ID, room ID and visibility.
 | ||||
|         pub fn new(network_id: &'a str, room_id: &'a RoomId, visibility: Visibility) -> Self { | ||||
|  | ||||
| @ -8,45 +8,47 @@ pub mod v3 { | ||||
|     use std::collections::BTreeMap; | ||||
| 
 | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::{api::ruma_api, OwnedRoomId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, OwnedRoomId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::backup::RoomKeyBackup; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Store keys in the backup.", | ||||
|             method: PUT, | ||||
|             name: "add_backup_keys", | ||||
|             unstable_path: "/_matrix/client/unstable/room_keys/keys", | ||||
|             stable_path: "/_matrix/client/v3/room_keys/keys", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.1, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Store keys in the backup.", | ||||
|         method: PUT, | ||||
|         name: "add_backup_keys", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/room_keys/keys", | ||||
|             1.1 => "/_matrix/client/v3/room_keys/keys", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The backup version to add keys to.
 | ||||
|             ///
 | ||||
|             /// Must be the current backup.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub version: &'a str, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version to add keys to.
 | ||||
|         ///
 | ||||
|         /// Must be the current backup.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub version: &'a str, | ||||
| 
 | ||||
|             /// A map of room IDs to session IDs to key data to store.
 | ||||
|             pub rooms: BTreeMap<OwnedRoomId, RoomKeyBackup>, | ||||
|         } | ||||
|         /// A map of room IDs to session IDs to key data to store.
 | ||||
|         pub rooms: BTreeMap<OwnedRoomId, RoomKeyBackup>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// An opaque string representing stored keys in the backup.
 | ||||
|             ///
 | ||||
|             /// Clients can compare it with  the etag value they received in the request of their last
 | ||||
|             /// key storage request.
 | ||||
|             pub etag: String, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// An opaque string representing stored keys in the backup.
 | ||||
|         ///
 | ||||
|         /// Clients can compare it with  the etag value they received in the request of their last
 | ||||
|         /// key storage request.
 | ||||
|         pub etag: String, | ||||
| 
 | ||||
|             /// The number of keys stored in the backup.
 | ||||
|             pub count: UInt, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The number of keys stored in the backup.
 | ||||
|         pub count: UInt, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -8,50 +8,54 @@ pub mod v3 { | ||||
|     use std::collections::BTreeMap; | ||||
| 
 | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::{api::ruma_api, serde::Raw, RoomId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|         RoomId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::backup::KeyBackupData; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Store keys in the backup for a room.", | ||||
|             method: PUT, | ||||
|             name: "add_backup_keys_for_room", | ||||
|             unstable_path: "/_matrix/client/unstable/room_keys/keys/:room_id", | ||||
|             r0_path: "/_matrix/client/r0/room_keys/keys/:room_id", | ||||
|             stable_path: "/_matrix/client/v3/room_keys/keys/:room_id", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Store keys in the backup for a room.", | ||||
|         method: PUT, | ||||
|         name: "add_backup_keys_for_room", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/room_keys/keys/:room_id", | ||||
|             1.0 => "/_matrix/client/r0/room_keys/keys/:room_id", | ||||
|             1.1 => "/_matrix/client/v3/room_keys/keys/:room_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The backup version to add keys to.
 | ||||
|             ///
 | ||||
|             /// Must be the current backup.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub version: &'a str, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version to add keys to.
 | ||||
|         ///
 | ||||
|         /// Must be the current backup.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub version: &'a str, | ||||
| 
 | ||||
|             /// The ID of the room to add keys to.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|         /// The ID of the room to add keys to.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| 
 | ||||
|             /// A map of session IDs to key data to store.
 | ||||
|             pub sessions: BTreeMap<String, Raw<KeyBackupData>>, | ||||
|         } | ||||
|         /// A map of session IDs to key data to store.
 | ||||
|         pub sessions: BTreeMap<String, Raw<KeyBackupData>>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// An opaque string representing stored keys in the backup.
 | ||||
|             ///
 | ||||
|             /// Clients can compare it with the etag value they received in the request of their last
 | ||||
|             /// key storage request.
 | ||||
|             pub etag: String, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// An opaque string representing stored keys in the backup.
 | ||||
|         ///
 | ||||
|         /// Clients can compare it with the etag value they received in the request of their last
 | ||||
|         /// key storage request.
 | ||||
|         pub etag: String, | ||||
| 
 | ||||
|             /// The number of keys stored in the backup.
 | ||||
|             pub count: UInt, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The number of keys stored in the backup.
 | ||||
|         pub count: UInt, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -6,55 +6,59 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#put_matrixclientv3room_keyskeysroomidsessionid
 | ||||
| 
 | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::{api::ruma_api, serde::Raw, RoomId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|         RoomId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::backup::KeyBackupData; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Store keys in the backup for a session.", | ||||
|             method: PUT, | ||||
|             name: "add_backup_keys_for_session", | ||||
|             unstable_path: "/_matrix/client/unstable/room_keys/keys/:room_id/:session_id", | ||||
|             r0_path: "/_matrix/client/r0/room_keys/keys/:room_id/:session_id", | ||||
|             stable_path: "/_matrix/client/v3/room_keys/keys/:room_id/:session_id", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Store keys in the backup for a session.", | ||||
|         method: PUT, | ||||
|         name: "add_backup_keys_for_session", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/room_keys/keys/:room_id/:session_id", | ||||
|             1.0 => "/_matrix/client/r0/room_keys/keys/:room_id/:session_id", | ||||
|             1.1 => "/_matrix/client/v3/room_keys/keys/:room_id/:session_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The backup version to add keys to.
 | ||||
|             ///
 | ||||
|             /// Must be the current backup.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub version: &'a str, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version to add keys to.
 | ||||
|         ///
 | ||||
|         /// Must be the current backup.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub version: &'a str, | ||||
| 
 | ||||
|             /// The ID of the room to add keys to.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|         /// The ID of the room to add keys to.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| 
 | ||||
|             /// The ID of the megolm session to add keys to.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub session_id: &'a str, | ||||
|         /// The ID of the megolm session to add keys to.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub session_id: &'a str, | ||||
| 
 | ||||
|             /// The key information to store.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub session_data: Raw<KeyBackupData>, | ||||
|         } | ||||
|         /// The key information to store.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub session_data: Raw<KeyBackupData>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// An opaque string representing stored keys in the backup.
 | ||||
|             ///
 | ||||
|             /// Clients can compare it with the etag value they received in the request of their last
 | ||||
|             /// key storage request.
 | ||||
|             pub etag: String, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// An opaque string representing stored keys in the backup.
 | ||||
|         ///
 | ||||
|         /// Clients can compare it with the etag value they received in the request of their last
 | ||||
|         /// key storage request.
 | ||||
|         pub etag: String, | ||||
| 
 | ||||
|             /// The number of keys stored in the backup.
 | ||||
|             pub count: UInt, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The number of keys stored in the backup.
 | ||||
|         pub count: UInt, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,34 +5,37 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3room_keysversion
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, serde::Raw}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::backup::BackupAlgorithm; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Create a new backup version.", | ||||
|             method: POST, | ||||
|             name: "create_backup_version", | ||||
|             unstable_path: "/_matrix/client/unstable/room_keys/version", | ||||
|             stable_path: "/_matrix/client/v3/room_keys/version", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.1, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Create a new backup version.", | ||||
|         method: POST, | ||||
|         name: "create_backup_version", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/room_keys/version", | ||||
|             1.1 => "/_matrix/client/v3/room_keys/version", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The algorithm used for storing backups.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub algorithm: Raw<BackupAlgorithm>, | ||||
|         } | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request { | ||||
|         /// The algorithm used for storing backups.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub algorithm: Raw<BackupAlgorithm>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// The backup version.
 | ||||
|             pub version: String, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The backup version.
 | ||||
|         pub version: String, | ||||
|     } | ||||
| 
 | ||||
|     impl Request { | ||||
|  | ||||
| @ -8,39 +8,41 @@ pub mod v3 { | ||||
|     //! This deletes keys from a backup version, but not the version itself.
 | ||||
| 
 | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::api::ruma_api; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Delete all keys from a backup.", | ||||
|             method: DELETE, | ||||
|             name: "delete_backup_keys", | ||||
|             unstable_path: "/_matrix/client/unstable/room_keys/keys", | ||||
|             r0_path: "/_matrix/client/r0/room_keys/keys", | ||||
|             stable_path: "/_matrix/client/v3/room_keys/keys", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Delete all keys from a backup.", | ||||
|         method: DELETE, | ||||
|         name: "delete_backup_keys", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/room_keys/keys", | ||||
|             1.0 => "/_matrix/client/r0/room_keys/keys", | ||||
|             1.1 => "/_matrix/client/v3/room_keys/keys", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The backup version from which to delete keys.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub version: &'a str, | ||||
|         } | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version from which to delete keys.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub version: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// An opaque string representing stored keys in the backup.
 | ||||
|             ///
 | ||||
|             /// Clients can compare it with the etag value they received in the request of their last
 | ||||
|             /// key storage request.
 | ||||
|             pub etag: String, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// An opaque string representing stored keys in the backup.
 | ||||
|         ///
 | ||||
|         /// Clients can compare it with the etag value they received in the request of their last
 | ||||
|         /// key storage request.
 | ||||
|         pub etag: String, | ||||
| 
 | ||||
|             /// The number of keys stored in the backup.
 | ||||
|             pub count: UInt, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The number of keys stored in the backup.
 | ||||
|         pub count: UInt, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -6,43 +6,45 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#delete_matrixclientv3room_keyskeysroomid
 | ||||
| 
 | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::{api::ruma_api, RoomId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, RoomId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Delete keys from a backup for a given room.", | ||||
|             method: DELETE, | ||||
|             name: "delete_backup_keys_for_room", | ||||
|             unstable_path: "/_matrix/client/unstable/room_keys/keys/:room_id", | ||||
|             r0_path: "/_matrix/client/r0/room_keys/keys/:room_id", | ||||
|             stable_path: "/_matrix/client/v3/room_keys/keys/:room_id", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Delete keys from a backup for a given room.", | ||||
|         method: DELETE, | ||||
|         name: "delete_backup_keys_for_room", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/room_keys/keys/:room_id", | ||||
|             1.0 => "/_matrix/client/r0/room_keys/keys/:room_id", | ||||
|             1.1 => "/_matrix/client/v3/room_keys/keys/:room_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The backup version from which to delete keys.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub version: &'a str, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version from which to delete keys.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub version: &'a str, | ||||
| 
 | ||||
|             /// The ID of the room to delete keys from.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|         } | ||||
|         /// The ID of the room to delete keys from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// An opaque string representing stored keys in the backup.
 | ||||
|             ///
 | ||||
|             /// Clients can compare it with the etag value they received in the request of their last
 | ||||
|             /// key storage request.
 | ||||
|             pub etag: String, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// An opaque string representing stored keys in the backup.
 | ||||
|         ///
 | ||||
|         /// Clients can compare it with the etag value they received in the request of their last
 | ||||
|         /// key storage request.
 | ||||
|         pub etag: String, | ||||
| 
 | ||||
|             /// The number of keys stored in the backup.
 | ||||
|             pub count: UInt, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The number of keys stored in the backup.
 | ||||
|         pub count: UInt, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -6,47 +6,49 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#delete_matrixclientv3room_keyskeysroomidsessionid
 | ||||
| 
 | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::{api::ruma_api, RoomId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, RoomId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Delete keys from a backup for a given session.", | ||||
|             method: DELETE, | ||||
|             name: "delete_backup_keys_for_session", | ||||
|             unstable_path: "/_matrix/client/unstable/room_keys/keys/:room_id/:session_id", | ||||
|             r0_path: "/_matrix/client/r0/room_keys/keys/:room_id/:session_id", | ||||
|             stable_path: "/_matrix/client/v3/room_keys/keys/:room_id/:session_id", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Delete keys from a backup for a given session.", | ||||
|         method: DELETE, | ||||
|         name: "delete_backup_keys_for_session", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/room_keys/keys/:room_id/:session_id", | ||||
|             1.0 => "/_matrix/client/r0/room_keys/keys/:room_id/:session_id", | ||||
|             1.1 => "/_matrix/client/v3/room_keys/keys/:room_id/:session_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The backup version from which to delete keys.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub version: &'a str, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version from which to delete keys.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub version: &'a str, | ||||
| 
 | ||||
|             /// The ID of the room to delete keys from.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|         /// The ID of the room to delete keys from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| 
 | ||||
|             /// The ID of the megolm session to delete keys from.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub session_id: &'a str, | ||||
|         } | ||||
|         /// The ID of the megolm session to delete keys from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub session_id: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// An opaque string representing stored keys in the backup.
 | ||||
|             ///
 | ||||
|             /// Clients can compare it with  the etag value they received in the request of their last
 | ||||
|             /// key storage request.
 | ||||
|             pub etag: String, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// An opaque string representing stored keys in the backup.
 | ||||
|         ///
 | ||||
|         /// Clients can compare it with  the etag value they received in the request of their last
 | ||||
|         /// key storage request.
 | ||||
|         pub etag: String, | ||||
| 
 | ||||
|             /// The number of keys stored in the backup.
 | ||||
|             pub count: UInt, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The number of keys stored in the backup.
 | ||||
|         pub count: UInt, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -7,33 +7,35 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! This deletes a backup version and its room keys.
 | ||||
| 
 | ||||
|     use ruma_common::api::ruma_api; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Delete a backup version.", | ||||
|             method: DELETE, | ||||
|             name: "delete_backup_version", | ||||
|             unstable_path: "/_matrix/client/unstable/room_keys/version/:version", | ||||
|             r0_path: "/_matrix/client/r0/room_keys/version/:version", | ||||
|             stable_path: "/_matrix/client/v3/room_keys/version/:version", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Delete a backup version.", | ||||
|         method: DELETE, | ||||
|         name: "delete_backup_version", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/room_keys/version/:version", | ||||
|             1.0 => "/_matrix/client/r0/room_keys/version/:version", | ||||
|             1.1 => "/_matrix/client/v3/room_keys/version/:version", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The backup version to delete.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub version: &'a str, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version to delete.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub version: &'a str, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given version, room_id and sessions.
 | ||||
|         pub fn new(version: &'a str) -> Self { | ||||
|  | ||||
| @ -8,49 +8,52 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3room_keysversionversion
 | ||||
| 
 | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::{api::ruma_api, serde::Raw}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|     }; | ||||
|     use serde::{ser, Deserialize, Deserializer, Serialize}; | ||||
|     use serde_json::value::{to_raw_value as to_raw_json_value, RawValue as RawJsonValue}; | ||||
| 
 | ||||
|     use crate::backup::BackupAlgorithm; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get information about a specific backup.", | ||||
|             method: GET, | ||||
|             name: "get_backup_info", | ||||
|             unstable_path: "/_matrix/client/unstable/room_keys/version/:version", | ||||
|             stable_path: "/_matrix/client/v3/room_keys/version/:version", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.1, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get information about a specific backup.", | ||||
|         method: GET, | ||||
|         name: "get_backup_info", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/room_keys/version/:version", | ||||
|             1.1 => "/_matrix/client/v3/room_keys/version/:version", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The backup version to retrieve info from.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub version: &'a str, | ||||
|         } | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version to retrieve info from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub version: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         #[ruma_api(manual_body_serde)] | ||||
|         response: { | ||||
|             /// The algorithm used for storing backups.
 | ||||
|             pub algorithm: Raw<BackupAlgorithm>, | ||||
|     #[response(error = crate::Error)] | ||||
|     #[ruma_api(manual_body_serde)] | ||||
|     pub struct Response { | ||||
|         /// The algorithm used for storing backups.
 | ||||
|         pub algorithm: Raw<BackupAlgorithm>, | ||||
| 
 | ||||
|             /// The number of keys stored in the backup.
 | ||||
|             pub count: UInt, | ||||
|         /// The number of keys stored in the backup.
 | ||||
|         pub count: UInt, | ||||
| 
 | ||||
|             /// An opaque string representing stored keys in the backup.
 | ||||
|             ///
 | ||||
|             /// Clients can compare it with the etag value they received in the request of their last
 | ||||
|             /// key storage request.
 | ||||
|             pub etag: String, | ||||
|         /// An opaque string representing stored keys in the backup.
 | ||||
|         ///
 | ||||
|         /// Clients can compare it with the etag value they received in the request of their last
 | ||||
|         /// key storage request.
 | ||||
|         pub etag: String, | ||||
| 
 | ||||
|             /// The backup version.
 | ||||
|             pub version: String, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The backup version.
 | ||||
|         pub version: String, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -9,35 +9,37 @@ pub mod v3 { | ||||
| 
 | ||||
|     use std::collections::BTreeMap; | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, OwnedRoomId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, OwnedRoomId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::backup::RoomKeyBackup; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Retrieve all keys from a backup version.", | ||||
|             method: GET, | ||||
|             name: "get_backup_keys", | ||||
|             unstable_path: "/_matrix/client/unstable/room_keys/keys", | ||||
|             r0_path: "/_matrix/client/r0/room_keys/keys", | ||||
|             stable_path: "/_matrix/client/v3/room_keys/keys", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Retrieve all keys from a backup version.", | ||||
|         method: GET, | ||||
|         name: "get_backup_keys", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/room_keys/keys", | ||||
|             1.0 => "/_matrix/client/r0/room_keys/keys", | ||||
|             1.1 => "/_matrix/client/v3/room_keys/keys", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The backup version to retrieve keys from.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub version: &'a str, | ||||
|         } | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version to retrieve keys from.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub version: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// A map from room IDs to session IDs to key data.
 | ||||
|             pub rooms: BTreeMap<OwnedRoomId, RoomKeyBackup>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A map from room IDs to session IDs to key data.
 | ||||
|         pub rooms: BTreeMap<OwnedRoomId, RoomKeyBackup>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -7,39 +7,43 @@ pub mod v3 { | ||||
| 
 | ||||
|     use std::collections::BTreeMap; | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, serde::Raw, RoomId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|         RoomId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::backup::KeyBackupData; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Retrieve sessions from the backup for a given room.", | ||||
|             method: GET, | ||||
|             name: "get_backup_keys_for_room", | ||||
|             unstable_path: "/_matrix/client/unstable/room_keys/keys/:room_id", | ||||
|             r0_path: "/_matrix/client/r0/room_keys/keys/:room_id", | ||||
|             stable_path: "/_matrix/client/v3/room_keys/keys/:room_id", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Retrieve sessions from the backup for a given room.", | ||||
|         method: GET, | ||||
|         name: "get_backup_keys_for_room", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/room_keys/keys/:room_id", | ||||
|             1.0 => "/_matrix/client/r0/room_keys/keys/:room_id", | ||||
|             1.1 => "/_matrix/client/v3/room_keys/keys/:room_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The backup version to retrieve keys from.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub version: &'a str, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version to retrieve keys from.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub version: &'a str, | ||||
| 
 | ||||
|             /// The ID of the room that the requested key is for.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|         } | ||||
|         /// The ID of the room that the requested key is for.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// A map of session IDs to key data.
 | ||||
|             pub sessions: BTreeMap<String, Raw<KeyBackupData>>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A map of session IDs to key data.
 | ||||
|         pub sessions: BTreeMap<String, Raw<KeyBackupData>>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,44 +5,48 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3room_keyskeysroomidsessionid
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, serde::Raw, RoomId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|         RoomId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::backup::KeyBackupData; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Retrieve a key from the backup for a given session.", | ||||
|             method: GET, | ||||
|             name: "get_backup_keys_for_session", | ||||
|             unstable_path: "/_matrix/client/unstable/room_keys/keys/:room_id/:session_id", | ||||
|             r0_path: "/_matrix/client/r0/room_keys/keys/:room_id/:session_id", | ||||
|             stable_path: "/_matrix/client/v3/room_keys/keys/:room_id/:session_id", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Retrieve a key from the backup for a given session.", | ||||
|         method: GET, | ||||
|         name: "get_backup_keys_for_session", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/room_keys/keys/:room_id/:session_id", | ||||
|             1.0 => "/_matrix/client/r0/room_keys/keys/:room_id/:session_id", | ||||
|             1.1 => "/_matrix/client/v3/room_keys/keys/:room_id/:session_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The backup version to retrieve keys from.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub version: &'a str, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version to retrieve keys from.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub version: &'a str, | ||||
| 
 | ||||
|             /// The ID of the room that the requested key is for.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|         /// The ID of the room that the requested key is for.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| 
 | ||||
|             /// The ID of the megolm session whose key is requested.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub session_id: &'a str, | ||||
|         } | ||||
|         /// The ID of the megolm session whose key is requested.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub session_id: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// Information about the requested backup key.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub key_data: Raw<KeyBackupData>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// Information about the requested backup key.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub key_data: Raw<KeyBackupData>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -6,7 +6,11 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3room_keysversion
 | ||||
| 
 | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::{api::ruma_api, serde::Raw}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|     }; | ||||
|     use serde::{ser, Deserialize, Deserializer, Serialize}; | ||||
|     use serde_json::value::to_raw_value as to_raw_json_value; | ||||
| 
 | ||||
| @ -15,41 +19,40 @@ pub mod v3 { | ||||
|         BackupAlgorithm, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get information about the latest backup.", | ||||
|             method: GET, | ||||
|             name: "get_latest_backup_info", | ||||
|             unstable_path: "/_matrix/client/unstable/room_keys/version", | ||||
|             r0_path: "/_matrix/client/r0/room_keys/version", | ||||
|             stable_path: "/_matrix/client/v3/room_keys/version", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get information about the latest backup.", | ||||
|         method: GET, | ||||
|         name: "get_latest_backup_info", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/room_keys/version", | ||||
|             1.0 => "/_matrix/client/r0/room_keys/version", | ||||
|             1.1 => "/_matrix/client/v3/room_keys/version", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         request: {} | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Request {} | ||||
| 
 | ||||
|         #[ruma_api(manual_body_serde)] | ||||
|         response: { | ||||
|             /// The algorithm used for storing backups.
 | ||||
|             pub algorithm: Raw<BackupAlgorithm>, | ||||
|     #[response(error = crate::Error)] | ||||
|     #[ruma_api(manual_body_serde)] | ||||
|     pub struct Response { | ||||
|         /// The algorithm used for storing backups.
 | ||||
|         pub algorithm: Raw<BackupAlgorithm>, | ||||
| 
 | ||||
|             /// The number of keys stored in the backup.
 | ||||
|             pub count: UInt, | ||||
|         /// The number of keys stored in the backup.
 | ||||
|         pub count: UInt, | ||||
| 
 | ||||
|             /// An opaque string representing stored keys in the backup.
 | ||||
|             ///
 | ||||
|             /// Clients can compare it with the etag value they received in the request of their last
 | ||||
|             /// key storage request.
 | ||||
|             pub etag: String, | ||||
|         /// An opaque string representing stored keys in the backup.
 | ||||
|         ///
 | ||||
|         /// Clients can compare it with the etag value they received in the request of their last
 | ||||
|         /// key storage request.
 | ||||
|         pub etag: String, | ||||
| 
 | ||||
|             /// The backup version.
 | ||||
|             pub version: String, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The backup version.
 | ||||
|         pub version: String, | ||||
|     } | ||||
| 
 | ||||
|     impl Request { | ||||
|  | ||||
| @ -5,38 +5,41 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#put_matrixclientv3room_keysversionversion
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, serde::Raw}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::backup::BackupAlgorithm; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Update information about an existing backup.", | ||||
|             method: PUT, | ||||
|             name: "update_backup_version", | ||||
|             unstable_path: "/_matrix/client/unstable/room_keys/version/:version", | ||||
|             stable_path: "/_matrix/client/v3/room_keys/version/:version", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Update information about an existing backup.", | ||||
|         method: PUT, | ||||
|         name: "update_backup_version", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/room_keys/version/:version", | ||||
|             1.1 => "/_matrix/client/v3/room_keys/version/:version", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The backup version.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub version: &'a str, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub version: &'a str, | ||||
| 
 | ||||
|             /// The algorithm used for storing backups.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub algorithm: Raw<BackupAlgorithm>, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The algorithm used for storing backups.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub algorithm: Raw<BackupAlgorithm>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given backup version and algorithm.
 | ||||
|         pub fn new(version: &'a str, algorithm: Raw<BackupAlgorithm>) -> Self { | ||||
|  | ||||
| @ -6,40 +6,43 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3useruseridaccount_datatype
 | ||||
| 
 | ||||
|     use ruma_common::{ | ||||
|         api::ruma_api, events::AnyGlobalAccountDataEventContent, serde::Raw, UserId, | ||||
|         api::{request, response, Metadata}, | ||||
|         events::AnyGlobalAccountDataEventContent, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|         UserId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Gets global account data for a user.", | ||||
|             name: "get_global_account_data", | ||||
|             method: GET, | ||||
|             r0_path: "/_matrix/client/r0/user/:user_id/account_data/:event_type", | ||||
|             stable_path: "/_matrix/client/v3/user/:user_id/account_data/:event_type", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Gets global account data for a user.", | ||||
|         method: GET, | ||||
|         name: "get_global_account_data", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/user/:user_id/account_data/:event_type", | ||||
|             1.1 => "/_matrix/client/v3/user/:user_id/account_data/:event_type", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// User ID of user for whom to retrieve data.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: &'a UserId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// User ID of user for whom to retrieve data.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
| 
 | ||||
|             /// Type of data to retrieve.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub event_type: &'a str, | ||||
|         } | ||||
|         /// Type of data to retrieve.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub event_type: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// Account data content for the given type.
 | ||||
|             ///
 | ||||
|             /// Use [`Raw::deserialize_content`] for deserialization.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub account_data: Raw<AnyGlobalAccountDataEventContent>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// Account data content for the given type.
 | ||||
|         ///
 | ||||
|         /// Use [`Raw::deserialize_content`] for deserialization.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub account_data: Raw<AnyGlobalAccountDataEventContent>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -6,44 +6,47 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3useruseridroomsroomidaccount_datatype
 | ||||
| 
 | ||||
|     use ruma_common::{ | ||||
|         api::ruma_api, events::AnyRoomAccountDataEventContent, serde::Raw, RoomId, UserId, | ||||
|         api::{request, response, Metadata}, | ||||
|         events::AnyRoomAccountDataEventContent, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|         RoomId, UserId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Gets account data room for a user for a given room", | ||||
|             name: "get_room_account_data", | ||||
|             method: GET, | ||||
|             r0_path: "/_matrix/client/r0/user/:user_id/rooms/:room_id/account_data/:event_type", | ||||
|             stable_path: "/_matrix/client/v3/user/:user_id/rooms/:room_id/account_data/:event_type", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Gets account data room for a user for a given room", | ||||
|         method: GET, | ||||
|         name: "get_room_account_data", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/user/:user_id/rooms/:room_id/account_data/:event_type", | ||||
|             1.1 => "/_matrix/client/v3/user/:user_id/rooms/:room_id/account_data/:event_type", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// User ID of user for whom to retrieve data.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: &'a UserId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// User ID of user for whom to retrieve data.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
| 
 | ||||
|             /// Room ID for which to retrieve data.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|         /// Room ID for which to retrieve data.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| 
 | ||||
|             /// Type of data to retrieve.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub event_type: &'a str, | ||||
|         } | ||||
|         /// Type of data to retrieve.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub event_type: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// Account data content for the given type.
 | ||||
|             ///
 | ||||
|             /// Use [`Raw::deserialize_content`] for deserialization.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub account_data: Raw<AnyRoomAccountDataEventContent>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// Account data content for the given type.
 | ||||
|         ///
 | ||||
|         /// Use [`Raw::deserialize_content`] for deserialization.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub account_data: Raw<AnyRoomAccountDataEventContent>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -6,54 +6,54 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#put_matrixclientv3useruseridaccount_datatype
 | ||||
| 
 | ||||
|     use ruma_common::{ | ||||
|         api::ruma_api, | ||||
|         api::{request, response, Metadata}, | ||||
|         events::{ | ||||
|             AnyGlobalAccountDataEventContent, GlobalAccountDataEventContent, | ||||
|             GlobalAccountDataEventType, | ||||
|         }, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|         UserId, | ||||
|     }; | ||||
|     use serde_json::value::to_raw_value as to_raw_json_value; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Sets global account data.", | ||||
|             method: PUT, | ||||
|             name: "set_global_account_data", | ||||
|             r0_path: "/_matrix/client/r0/user/:user_id/account_data/:event_type", | ||||
|             stable_path: "/_matrix/client/v3/user/:user_id/account_data/:event_type", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Sets global account data.", | ||||
|         method: PUT, | ||||
|         name: "set_global_account_data", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/user/:user_id/account_data/:event_type", | ||||
|             1.1 => "/_matrix/client/v3/user/:user_id/account_data/:event_type", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The ID of the user to set account_data for.
 | ||||
|             ///
 | ||||
|             /// The access token must be authorized to make requests for this user ID.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: &'a UserId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The ID of the user to set account_data for.
 | ||||
|         ///
 | ||||
|         /// The access token must be authorized to make requests for this user ID.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
| 
 | ||||
|             /// The event type of the account_data to set.
 | ||||
|             ///
 | ||||
|             /// Custom types should be namespaced to avoid clashes.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub event_type: GlobalAccountDataEventType, | ||||
|         /// The event type of the account_data to set.
 | ||||
|         ///
 | ||||
|         /// Custom types should be namespaced to avoid clashes.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub event_type: GlobalAccountDataEventType, | ||||
| 
 | ||||
|             /// Arbitrary JSON to store as config data.
 | ||||
|             ///
 | ||||
|             /// To create a `RawJsonValue`, use `serde_json::value::to_raw_value`.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub data: Raw<AnyGlobalAccountDataEventContent>, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// Arbitrary JSON to store as config data.
 | ||||
|         ///
 | ||||
|         /// To create a `RawJsonValue`, use `serde_json::value::to_raw_value`.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub data: Raw<AnyGlobalAccountDataEventContent>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given data, event type and user ID.
 | ||||
|         ///
 | ||||
|  | ||||
| @ -6,57 +6,57 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#put_matrixclientv3useruseridroomsroomidaccount_datatype
 | ||||
| 
 | ||||
|     use ruma_common::{ | ||||
|         api::ruma_api, | ||||
|         api::{request, response, Metadata}, | ||||
|         events::{ | ||||
|             AnyRoomAccountDataEventContent, RoomAccountDataEventContent, RoomAccountDataEventType, | ||||
|         }, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|         RoomId, UserId, | ||||
|     }; | ||||
|     use serde_json::value::to_raw_value as to_raw_json_value; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Associate account data with a room.", | ||||
|             method: PUT, | ||||
|             name: "set_room_account_data", | ||||
|             r0_path: "/_matrix/client/r0/user/:user_id/rooms/:room_id/account_data/:event_type", | ||||
|             stable_path: "/_matrix/client/v3/user/:user_id/rooms/:room_id/account_data/:event_type", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Associate account data with a room.", | ||||
|         method: PUT, | ||||
|         name: "set_room_account_data", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/user/:user_id/rooms/:room_id/account_data/:event_type", | ||||
|             1.1 => "/_matrix/client/v3/user/:user_id/rooms/:room_id/account_data/:event_type", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The ID of the user to set account_data for.
 | ||||
|             ///
 | ||||
|             /// The access token must be authorized to make requests for this user ID.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: &'a UserId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The ID of the user to set account_data for.
 | ||||
|         ///
 | ||||
|         /// The access token must be authorized to make requests for this user ID.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
| 
 | ||||
|             /// The ID of the room to set account_data on.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|         /// The ID of the room to set account_data on.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| 
 | ||||
|             /// The event type of the account_data to set.
 | ||||
|             ///
 | ||||
|             /// Custom types should be namespaced to avoid clashes.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub event_type: RoomAccountDataEventType, | ||||
|         /// The event type of the account_data to set.
 | ||||
|         ///
 | ||||
|         /// Custom types should be namespaced to avoid clashes.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub event_type: RoomAccountDataEventType, | ||||
| 
 | ||||
|             /// Arbitrary JSON to store as config data.
 | ||||
|             ///
 | ||||
|             /// To create a `RawJsonValue`, use `serde_json::value::to_raw_value`.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub data: Raw<AnyRoomAccountDataEventContent>, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// Arbitrary JSON to store as config data.
 | ||||
|         ///
 | ||||
|         /// To create a `RawJsonValue`, use `serde_json::value::to_raw_value`.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub data: Raw<AnyRoomAccountDataEventContent>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given data, event type, room ID and user ID.
 | ||||
|         ///
 | ||||
|  | ||||
| @ -7,82 +7,82 @@ pub mod v3 { | ||||
| 
 | ||||
|     use js_int::{uint, UInt}; | ||||
|     use ruma_common::{ | ||||
|         api::ruma_api, | ||||
|         api::{request, response, Metadata}, | ||||
|         events::{AnyStateEvent, AnyTimelineEvent}, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|         EventId, RoomId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::filter::{IncomingRoomEventFilter, RoomEventFilter}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get the events immediately preceding and following a given event.", | ||||
|             method: GET, | ||||
|             r0_path: "/_matrix/client/r0/rooms/:room_id/context/:event_id", | ||||
|             stable_path: "/_matrix/client/v3/rooms/:room_id/context/:event_id", | ||||
|             name: "get_context", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get the events immediately preceding and following a given event.", | ||||
|         method: GET, | ||||
|         name: "get_context", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/context/:event_id", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/context/:event_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The room to get events from.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room to get events from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| 
 | ||||
|             /// The event to get context around.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub event_id: &'a EventId, | ||||
|         /// The event to get context around.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub event_id: &'a 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, | ||||
|         /// 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(
 | ||||
|                 with = "ruma_common::serde::json_string", | ||||
|                 default, | ||||
|                 skip_serializing_if = "RoomEventFilter::is_empty" | ||||
|             )] | ||||
|             pub filter: RoomEventFilter<'a>, | ||||
|         } | ||||
|         /// A RoomEventFilter to filter returned events with.
 | ||||
|         #[ruma_api(query)] | ||||
|         #[serde(
 | ||||
|             with = "ruma_common::serde::json_string", | ||||
|             default, | ||||
|             skip_serializing_if = "RoomEventFilter::is_empty" | ||||
|         )] | ||||
|         pub filter: RoomEventFilter<'a>, | ||||
|     } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: { | ||||
|             /// A token that can be used to paginate backwards with.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub start: Option<String>, | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response { | ||||
|         /// A token that can be used to paginate backwards with.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub start: Option<String>, | ||||
| 
 | ||||
|             /// A token that can be used to paginate forwards with.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub end: Option<String>, | ||||
|         /// A token that can be used to paginate forwards with.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub end: Option<String>, | ||||
| 
 | ||||
|             /// 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<Raw<AnyTimelineEvent>>, | ||||
|         /// 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<Raw<AnyTimelineEvent>>, | ||||
| 
 | ||||
|             /// Details of the requested event.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub event: Option<Raw<AnyTimelineEvent>>, | ||||
|         /// Details of the requested event.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub event: Option<Raw<AnyTimelineEvent>>, | ||||
| 
 | ||||
|             /// 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<Raw<AnyTimelineEvent>>, | ||||
|         /// 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<Raw<AnyTimelineEvent>>, | ||||
| 
 | ||||
|             /// The state of the room at the last event returned.
 | ||||
|             #[serde(default, skip_serializing_if = "Vec::is_empty")] | ||||
|             pub state: Vec<Raw<AnyStateEvent>>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The state of the room at the last event returned.
 | ||||
|         #[serde(default, skip_serializing_if = "Vec::is_empty")] | ||||
|         pub state: Vec<Raw<AnyStateEvent>>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,38 +5,40 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#delete_matrixclientv3devicesdeviceid
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, DeviceId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, DeviceId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::uiaa::{AuthData, IncomingAuthData, UiaaResponse}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Delete a device for authenticated user.", | ||||
|             method: DELETE, | ||||
|             name: "delete_device", | ||||
|             r0_path: "/_matrix/client/r0/devices/:device_id", | ||||
|             stable_path: "/_matrix/client/v3/devices/:device_id", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Delete a device for authenticated user.", | ||||
|         method: DELETE, | ||||
|         name: "delete_device", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/devices/:device_id", | ||||
|             1.1 => "/_matrix/client/v3/devices/:device_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The device to delete.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub device_id: &'a DeviceId, | ||||
|     #[request(error = UiaaResponse)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The device to delete.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub device_id: &'a DeviceId, | ||||
| 
 | ||||
|             /// Additional authentication information for the user-interactive authentication API.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub auth: Option<AuthData<'a>>, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: UiaaResponse | ||||
|         /// Additional authentication information for the user-interactive authentication API.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub auth: Option<AuthData<'a>>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = UiaaResponse)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given device ID.
 | ||||
|         pub fn new(device_id: &'a DeviceId) -> Self { | ||||
|  | ||||
| @ -5,37 +5,39 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3delete_devices
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, OwnedDeviceId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, OwnedDeviceId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::uiaa::{AuthData, IncomingAuthData, UiaaResponse}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Delete specified devices.", | ||||
|             method: POST, | ||||
|             r0_path: "/_matrix/client/r0/delete_devices", | ||||
|             stable_path: "/_matrix/client/v3/delete_devices", | ||||
|             name: "delete_devices", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Delete specified devices.", | ||||
|         method: POST, | ||||
|         name: "delete_devices", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/delete_devices", | ||||
|             1.1 => "/_matrix/client/v3/delete_devices", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// List of devices to delete.
 | ||||
|             pub devices: &'a [OwnedDeviceId], | ||||
|     #[request(error = UiaaResponse)] | ||||
|     pub struct Request<'a> { | ||||
|         /// List of devices to delete.
 | ||||
|         pub devices: &'a [OwnedDeviceId], | ||||
| 
 | ||||
|             /// Additional authentication information for the user-interactive authentication API.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub auth: Option<AuthData<'a>>, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: UiaaResponse | ||||
|         /// Additional authentication information for the user-interactive authentication API.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub auth: Option<AuthData<'a>>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = UiaaResponse)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given device list.
 | ||||
|         pub fn new(devices: &'a [OwnedDeviceId]) -> Self { | ||||
|  | ||||
| @ -5,35 +5,37 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3devicesdeviceid
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, DeviceId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, DeviceId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::device::Device; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get a device for authenticated user.", | ||||
|             method: GET, | ||||
|             name: "get_device", | ||||
|             r0_path: "/_matrix/client/r0/devices/:device_id", | ||||
|             stable_path: "/_matrix/client/v3/devices/:device_id", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get a device for authenticated user.", | ||||
|         method: GET, | ||||
|         name: "get_device", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/devices/:device_id", | ||||
|             1.1 => "/_matrix/client/v3/devices/:device_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The device to retrieve.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub device_id: &'a DeviceId, | ||||
|         } | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The device to retrieve.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub device_id: &'a DeviceId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// Information about the device.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub device: Device, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// Information about the device.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub device: Device, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,31 +5,33 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3devices
 | ||||
| 
 | ||||
|     use ruma_common::api::ruma_api; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::device::Device; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get registered devices for authenticated user.", | ||||
|             method: GET, | ||||
|             name: "get_devices", | ||||
|             r0_path: "/_matrix/client/r0/devices", | ||||
|             stable_path: "/_matrix/client/v3/devices", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get registered devices for authenticated user.", | ||||
|         method: GET, | ||||
|         name: "get_devices", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/devices", | ||||
|             1.1 => "/_matrix/client/v3/devices", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         request: {} | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Request {} | ||||
| 
 | ||||
|         response: { | ||||
|             /// A list of all registered devices for this user
 | ||||
|             pub devices: Vec<Device>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A list of all registered devices for this user
 | ||||
|         pub devices: Vec<Device>, | ||||
|     } | ||||
| 
 | ||||
|     impl Request { | ||||
|  | ||||
| @ -5,38 +5,40 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#put_matrixclientv3devicesdeviceid
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, DeviceId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, DeviceId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Update metadata for a device.", | ||||
|             method: PUT, | ||||
|             name: "update_device", | ||||
|             r0_path: "/_matrix/client/r0/devices/:device_id", | ||||
|             stable_path: "/_matrix/client/v3/devices/:device_id", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Update metadata for a device.", | ||||
|         method: PUT, | ||||
|         name: "update_device", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/devices/:device_id", | ||||
|             1.1 => "/_matrix/client/v3/devices/:device_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The device to update.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub device_id: &'a DeviceId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The device to update.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub device_id: &'a DeviceId, | ||||
| 
 | ||||
|             /// The new display name for this device.
 | ||||
|             ///
 | ||||
|             /// If this is `None`, the display name won't be changed.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub display_name: Option<&'a str>, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The new display name for this device.
 | ||||
|         ///
 | ||||
|         /// If this is `None`, the display name won't be changed.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub display_name: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given device ID.
 | ||||
|         pub fn new(device_id: &'a DeviceId) -> Self { | ||||
|  | ||||
| @ -6,58 +6,61 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3publicrooms
 | ||||
| 
 | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::{api::ruma_api, directory::PublicRoomsChunk, ServerName}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         directory::PublicRoomsChunk, | ||||
|         metadata, ServerName, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get the list of rooms in this homeserver's public directory.", | ||||
|             method: GET, | ||||
|             name: "get_public_rooms", | ||||
|             r0_path: "/_matrix/client/r0/publicRooms", | ||||
|             stable_path: "/_matrix/client/v3/publicRooms", | ||||
|             rate_limited: false, | ||||
|             authentication: None, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get the list of rooms in this homeserver's public directory.", | ||||
|         method: GET, | ||||
|         name: "get_public_rooms", | ||||
|         rate_limited: false, | ||||
|         authentication: None, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/publicRooms", | ||||
|             1.1 => "/_matrix/client/v3/publicRooms", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         request: { | ||||
|             /// Limit for the number of results to return.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[ruma_api(query)] | ||||
|             pub limit: Option<UInt>, | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Limit for the number of results to return.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[ruma_api(query)] | ||||
|         pub limit: Option<UInt>, | ||||
| 
 | ||||
|             /// Pagination token from a previous request.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[ruma_api(query)] | ||||
|             pub since: Option<&'a str>, | ||||
|         /// Pagination token from a previous request.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[ruma_api(query)] | ||||
|         pub since: Option<&'a str>, | ||||
| 
 | ||||
|             /// The server to fetch the public room lists from.
 | ||||
|             ///
 | ||||
|             /// `None` means the server this request is sent to.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[ruma_api(query)] | ||||
|             pub server: Option<&'a ServerName>, | ||||
|         } | ||||
|         /// The server to fetch the public room lists from.
 | ||||
|         ///
 | ||||
|         /// `None` means the server this request is sent to.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[ruma_api(query)] | ||||
|         pub server: Option<&'a ServerName>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// A paginated chunk of public rooms.
 | ||||
|             pub chunk: Vec<PublicRoomsChunk>, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A paginated chunk of public rooms.
 | ||||
|         pub chunk: Vec<PublicRoomsChunk>, | ||||
| 
 | ||||
|             /// A pagination token for the response.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub next_batch: Option<String>, | ||||
|         /// A pagination token for the response.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub next_batch: Option<String>, | ||||
| 
 | ||||
|             /// A pagination token that allows fetching previous results.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub prev_batch: Option<String>, | ||||
|         /// A pagination token that allows fetching previous results.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub prev_batch: Option<String>, | ||||
| 
 | ||||
|             /// An estimate on the total number of public rooms, if the server has an estimate.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub total_room_count_estimate: Option<UInt>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// An estimate on the total number of public rooms, if the server has an estimate.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub total_room_count_estimate: Option<UInt>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -7,68 +7,67 @@ pub mod v3 { | ||||
| 
 | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::{ | ||||
|         api::ruma_api, | ||||
|         api::{request, response, Metadata}, | ||||
|         directory::{Filter, IncomingFilter, IncomingRoomNetwork, PublicRoomsChunk, RoomNetwork}, | ||||
|         ServerName, | ||||
|         metadata, ServerName, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get the list of rooms in this homeserver's public directory.", | ||||
|             method: POST, | ||||
|             name: "get_public_rooms_filtered", | ||||
|             r0_path: "/_matrix/client/r0/publicRooms", | ||||
|             stable_path: "/_matrix/client/v3/publicRooms", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get the list of rooms in this homeserver's public directory.", | ||||
|         method: POST, | ||||
|         name: "get_public_rooms_filtered", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/publicRooms", | ||||
|             1.1 => "/_matrix/client/v3/publicRooms", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         request: { | ||||
|             /// The server to fetch the public room lists from.
 | ||||
|             ///
 | ||||
|             /// `None` means the server this request is sent to.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[ruma_api(query)] | ||||
|             pub server: Option<&'a ServerName>, | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The server to fetch the public room lists from.
 | ||||
|         ///
 | ||||
|         /// `None` means the server this request is sent to.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[ruma_api(query)] | ||||
|         pub server: Option<&'a ServerName>, | ||||
| 
 | ||||
|             /// Limit for the number of results to return.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub limit: Option<UInt>, | ||||
|         /// Limit for the number of results to return.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub limit: Option<UInt>, | ||||
| 
 | ||||
|             /// Pagination token from a previous request.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub since: Option<&'a str>, | ||||
|         /// Pagination token from a previous request.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub since: Option<&'a str>, | ||||
| 
 | ||||
|             /// Filter to apply to the results.
 | ||||
|             #[serde(default, skip_serializing_if = "Filter::is_empty")] | ||||
|             pub filter: Filter<'a>, | ||||
|         /// Filter to apply to the results.
 | ||||
|         #[serde(default, skip_serializing_if = "Filter::is_empty")] | ||||
|         pub filter: Filter<'a>, | ||||
| 
 | ||||
|             /// Network to fetch the public room lists from.
 | ||||
|             #[serde(flatten, skip_serializing_if = "ruma_common::serde::is_default")] | ||||
|             pub room_network: RoomNetwork<'a>, | ||||
|         } | ||||
|         /// Network to fetch the public room lists from.
 | ||||
|         #[serde(flatten, skip_serializing_if = "ruma_common::serde::is_default")] | ||||
|         pub room_network: RoomNetwork<'a>, | ||||
|     } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: { | ||||
|             /// A paginated chunk of public rooms.
 | ||||
|             pub chunk: Vec<PublicRoomsChunk>, | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response { | ||||
|         /// A paginated chunk of public rooms.
 | ||||
|         pub chunk: Vec<PublicRoomsChunk>, | ||||
| 
 | ||||
|             /// A pagination token for the response.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub next_batch: Option<String>, | ||||
|         /// A pagination token for the response.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub next_batch: Option<String>, | ||||
| 
 | ||||
|             /// A pagination token that allows fetching previous results.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub prev_batch: Option<String>, | ||||
|         /// A pagination token that allows fetching previous results.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub prev_batch: Option<String>, | ||||
| 
 | ||||
|             /// An estimate on the total number of public rooms, if the server has an estimate.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub total_room_count_estimate: Option<UInt>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// An estimate on the total number of public rooms, if the server has an estimate.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub total_room_count_estimate: Option<UInt>, | ||||
|     } | ||||
| 
 | ||||
|     impl Request<'_> { | ||||
|  | ||||
| @ -5,34 +5,36 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3directorylistroomroomid
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, RoomId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, RoomId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::room::Visibility; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get the visibility of a public room on a directory.", | ||||
|             name: "get_room_visibility", | ||||
|             method: GET, | ||||
|             r0_path: "/_matrix/client/r0/directory/list/room/:room_id", | ||||
|             stable_path: "/_matrix/client/v3/directory/list/room/:room_id", | ||||
|             rate_limited: false, | ||||
|             authentication: None, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get the visibility of a public room on a directory.", | ||||
|         method: GET, | ||||
|         name: "get_room_visibility", | ||||
|         rate_limited: false, | ||||
|         authentication: None, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/directory/list/room/:room_id", | ||||
|             1.1 => "/_matrix/client/v3/directory/list/room/:room_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The ID of the room of which to request the visibility.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|         } | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The ID of the room of which to request the visibility.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// Visibility of the room.
 | ||||
|             pub visibility: Visibility, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// Visibility of the room.
 | ||||
|         pub visibility: Visibility, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,37 +5,39 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#put_matrixclientv3directorylistroomroomid
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, RoomId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, RoomId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::room::Visibility; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Set the visibility of a public room on a directory.", | ||||
|             name: "set_room_visibility", | ||||
|             method: PUT, | ||||
|             r0_path: "/_matrix/client/r0/directory/list/room/:room_id", | ||||
|             stable_path: "/_matrix/client/v3/directory/list/room/:room_id", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Set the visibility of a public room on a directory.", | ||||
|         method: PUT, | ||||
|         name: "set_room_visibility", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/directory/list/room/:room_id", | ||||
|             1.1 => "/_matrix/client/v3/directory/list/room/:room_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The ID of the room of which to set the visibility.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The ID of the room of which to set the visibility.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| 
 | ||||
|             /// New visibility setting for the room.
 | ||||
|             pub visibility: Visibility, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// New visibility setting for the room.
 | ||||
|         pub visibility: Visibility, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room ID and visibility.
 | ||||
|         pub fn new(room_id: &'a RoomId, visibility: Visibility) -> Self { | ||||
|  | ||||
| @ -2,52 +2,54 @@ | ||||
| //!
 | ||||
| //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#getwell-knownmatrixclient
 | ||||
| 
 | ||||
| use ruma_common::api::ruma_api; | ||||
| use ruma_common::{ | ||||
|     api::{request, response, Metadata}, | ||||
|     metadata, | ||||
| }; | ||||
| use serde::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata: { | ||||
|         description: "Get discovery information about the domain.", | ||||
|         method: GET, | ||||
|         name: "client_well_known", | ||||
|         stable_path: "/.well-known/matrix/client", | ||||
|         rate_limited: false, | ||||
|         authentication: None, | ||||
|         added: 1.0, | ||||
| const METADATA: Metadata = metadata! { | ||||
|     description: "Get discovery information about the domain.", | ||||
|     method: GET, | ||||
|     name: "client_well_known", | ||||
|     rate_limited: false, | ||||
|     authentication: None, | ||||
|     history: { | ||||
|         1.0 => "/.well-known/matrix/client", | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
|     #[derive(Default)] | ||||
|     request: {} | ||||
| #[request(error = crate::Error)] | ||||
| #[derive(Default)] | ||||
| pub struct Request {} | ||||
| 
 | ||||
|     response: { | ||||
|         /// Information about the homeserver to connect to.
 | ||||
|         #[serde(rename = "m.homeserver")] | ||||
|         pub homeserver: HomeserverInfo, | ||||
| #[response(error = crate::Error)] | ||||
| pub struct Response { | ||||
|     /// Information about the homeserver to connect to.
 | ||||
|     #[serde(rename = "m.homeserver")] | ||||
|     pub homeserver: HomeserverInfo, | ||||
| 
 | ||||
|         /// Information about the identity server to connect to.
 | ||||
|         #[serde(rename = "m.identity_server", skip_serializing_if = "Option::is_none")] | ||||
|         pub identity_server: Option<IdentityServerInfo>, | ||||
|     /// Information about the identity server to connect to.
 | ||||
|     #[serde(rename = "m.identity_server", skip_serializing_if = "Option::is_none")] | ||||
|     pub identity_server: Option<IdentityServerInfo>, | ||||
| 
 | ||||
|         /// Information about the tile server to use to display location data.
 | ||||
|         #[cfg(feature = "unstable-msc3488")] | ||||
|         #[serde(
 | ||||
|             rename = "org.matrix.msc3488.tile_server", | ||||
|             alias = "m.tile_server", | ||||
|             skip_serializing_if = "Option::is_none", | ||||
|         )] | ||||
|         pub tile_server: Option<TileServerInfo>, | ||||
|     /// Information about the tile server to use to display location data.
 | ||||
|     #[cfg(feature = "unstable-msc3488")] | ||||
|     #[serde(
 | ||||
|         rename = "org.matrix.msc3488.tile_server", | ||||
|         alias = "m.tile_server", | ||||
|         skip_serializing_if = "Option::is_none" | ||||
|     )] | ||||
|     pub tile_server: Option<TileServerInfo>, | ||||
| 
 | ||||
|         /// Information about the authentication server to connect to when using OpenID Connect.
 | ||||
|         #[cfg(feature = "unstable-msc2965")] | ||||
|         #[serde(
 | ||||
|             rename = "org.matrix.msc2965.authentication", | ||||
|             alias = "m.authentication", | ||||
|             skip_serializing_if = "Option::is_none" | ||||
|         )] | ||||
|         pub authentication: Option<AuthenticationServerInfo>, | ||||
|     } | ||||
| 
 | ||||
|     error: crate::Error | ||||
|     /// Information about the authentication server to connect to when using OpenID Connect.
 | ||||
|     #[cfg(feature = "unstable-msc2965")] | ||||
|     #[serde(
 | ||||
|         rename = "org.matrix.msc2965.authentication", | ||||
|         alias = "m.authentication", | ||||
|         skip_serializing_if = "Option::is_none" | ||||
|     )] | ||||
|     pub authentication: Option<AuthenticationServerInfo>, | ||||
| } | ||||
| 
 | ||||
| impl Request { | ||||
|  | ||||
| @ -2,31 +2,33 @@ | ||||
| //!
 | ||||
| //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3capabilities
 | ||||
| 
 | ||||
| use ruma_common::api::ruma_api; | ||||
| use ruma_common::{ | ||||
|     api::{request, response, Metadata}, | ||||
|     metadata, | ||||
| }; | ||||
| 
 | ||||
| use super::Capabilities; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata: { | ||||
|         description: "Gets information about the server's supported feature set and other relevant capabilities.", | ||||
|         method: GET, | ||||
|         name: "get_capabilities", | ||||
|         r0_path: "/_matrix/client/r0/capabilities", | ||||
|         stable_path: "/_matrix/client/v3/capabilities", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         added: 1.0, | ||||
| const METADATA: Metadata = metadata! { | ||||
|     description: "Gets information about the server's supported feature set and other relevant capabilities.", | ||||
|     method: GET, | ||||
|     name: "get_capabilities", | ||||
|     rate_limited: true, | ||||
|     authentication: AccessToken, | ||||
|     history: { | ||||
|         1.0 => "/_matrix/client/r0/capabilities", | ||||
|         1.1 => "/_matrix/client/v3/capabilities", | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
|     #[derive(Default)] | ||||
|     request: {} | ||||
| #[request(error = crate::Error)] | ||||
| #[derive(Default)] | ||||
| pub struct Request {} | ||||
| 
 | ||||
|     response: { | ||||
|         /// The capabilities the server supports
 | ||||
|         pub capabilities: Capabilities, | ||||
|     } | ||||
| 
 | ||||
|     error: crate::Error | ||||
| #[response(error = crate::Error)] | ||||
| pub struct Response { | ||||
|     /// The capabilities the server supports
 | ||||
|     pub capabilities: Capabilities, | ||||
| } | ||||
| 
 | ||||
| impl Request { | ||||
|  | ||||
| @ -4,32 +4,34 @@ | ||||
| 
 | ||||
| use std::collections::BTreeMap; | ||||
| 
 | ||||
| use ruma_common::api::{ruma_api, MatrixVersion}; | ||||
| use ruma_common::{ | ||||
|     api::{request, response, MatrixVersion, Metadata}, | ||||
|     metadata, | ||||
| }; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata: { | ||||
|         description: "Get the versions of the client-server API supported by this homeserver.", | ||||
|         method: GET, | ||||
|         name: "api_versions", | ||||
|         stable_path: "/_matrix/client/versions", | ||||
|         rate_limited: false, | ||||
|         authentication: None, | ||||
|         added: 1.0, | ||||
| const METADATA: Metadata = metadata! { | ||||
|     description: "Get the versions of the client-server API supported by this homeserver.", | ||||
|     method: GET, | ||||
|     name: "api_versions", | ||||
|     rate_limited: false, | ||||
|     authentication: None, | ||||
|     history: { | ||||
|         1.0 => "/_matrix/client/versions", | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
|     #[derive(Default)] | ||||
|     request: {} | ||||
| #[request(error = crate::Error)] | ||||
| #[derive(Default)] | ||||
| pub struct Request {} | ||||
| 
 | ||||
|     response: { | ||||
|         /// A list of Matrix client API protocol versions supported by the homeserver.
 | ||||
|         pub versions: Vec<String>, | ||||
| #[response(error = crate::Error)] | ||||
| pub struct Response { | ||||
|     /// A list of Matrix client API protocol versions supported by the homeserver.
 | ||||
|     pub versions: Vec<String>, | ||||
| 
 | ||||
|         /// Experimental features supported by the server.
 | ||||
|         #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] | ||||
|         pub unstable_features: BTreeMap<String, bool>, | ||||
|     } | ||||
| 
 | ||||
|     error: crate::Error | ||||
|     /// Experimental features supported by the server.
 | ||||
|     #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] | ||||
|     pub unstable_features: BTreeMap<String, bool>, | ||||
| } | ||||
| 
 | ||||
| impl Request { | ||||
|  | ||||
| @ -5,40 +5,42 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3useruseridfilter
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, UserId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, UserId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::filter::{FilterDefinition, IncomingFilterDefinition}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Create a new filter for event retrieval.", | ||||
|             method: POST, | ||||
|             name: "create_filter", | ||||
|             r0_path: "/_matrix/client/r0/user/:user_id/filter", | ||||
|             stable_path: "/_matrix/client/v3/user/:user_id/filter", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Create a new filter for event retrieval.", | ||||
|         method: POST, | ||||
|         name: "create_filter", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/user/:user_id/filter", | ||||
|             1.1 => "/_matrix/client/v3/user/:user_id/filter", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// 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: &'a UserId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// 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: &'a UserId, | ||||
| 
 | ||||
|             /// The filter definition.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub filter: FilterDefinition<'a>, | ||||
|         } | ||||
|         /// The filter definition.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub filter: FilterDefinition<'a>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// The ID of the filter that was created.
 | ||||
|             pub filter_id: String, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The ID of the filter that was created.
 | ||||
|         pub filter_id: String, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,39 +5,41 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3useruseridfilterfilterid
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, UserId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, UserId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::filter::IncomingFilterDefinition; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Retrieve a previously created filter.", | ||||
|             method: GET, | ||||
|             name: "get_filter", | ||||
|             r0_path: "/_matrix/client/r0/user/:user_id/filter/:filter_id", | ||||
|             stable_path: "/_matrix/client/v3/user/:user_id/filter/:filter_id", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Retrieve a previously created filter.", | ||||
|         method: GET, | ||||
|         name: "get_filter", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/user/:user_id/filter/:filter_id", | ||||
|             1.1 => "/_matrix/client/v3/user/:user_id/filter/:filter_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The user ID to download a filter for.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: &'a UserId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The user ID to download a filter for.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
| 
 | ||||
|             /// The ID of the filter to download.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub filter_id: &'a str, | ||||
|         } | ||||
|         /// The ID of the filter to download.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub filter_id: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// The filter definition.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub filter: IncomingFilterDefinition, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The filter definition.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub filter: IncomingFilterDefinition, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -8,47 +8,49 @@ pub mod v3 { | ||||
|     use std::{collections::BTreeMap, time::Duration}; | ||||
| 
 | ||||
|     use ruma_common::{ | ||||
|         api::ruma_api, encryption::OneTimeKey, serde::Raw, DeviceKeyAlgorithm, OwnedDeviceId, | ||||
|         OwnedDeviceKeyId, OwnedUserId, | ||||
|         api::{request, response, Metadata}, | ||||
|         encryption::OneTimeKey, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|         DeviceKeyAlgorithm, OwnedDeviceId, OwnedDeviceKeyId, OwnedUserId, | ||||
|     }; | ||||
|     use serde_json::Value as JsonValue; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Claims one-time keys for use in pre-key messages.", | ||||
|             method: POST, | ||||
|             name: "claim_keys", | ||||
|             r0_path: "/_matrix/client/r0/keys/claim", | ||||
|             stable_path: "/_matrix/client/v3/keys/claim", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Claims one-time keys for use in pre-key messages.", | ||||
|         method: POST, | ||||
|         name: "claim_keys", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/keys/claim", | ||||
|             1.1 => "/_matrix/client/v3/keys/claim", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The time (in milliseconds) to wait when downloading keys from remote servers.
 | ||||
|             /// 10 seconds is the recommended default.
 | ||||
|             #[serde(
 | ||||
|                 with = "ruma_common::serde::duration::opt_ms", | ||||
|                 default, | ||||
|                 skip_serializing_if = "Option::is_none", | ||||
|             )] | ||||
|             pub timeout: Option<Duration>, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request { | ||||
|         /// The time (in milliseconds) to wait when downloading keys from remote servers.
 | ||||
|         /// 10 seconds is the recommended default.
 | ||||
|         #[serde(
 | ||||
|             with = "ruma_common::serde::duration::opt_ms", | ||||
|             default, | ||||
|             skip_serializing_if = "Option::is_none" | ||||
|         )] | ||||
|         pub timeout: Option<Duration>, | ||||
| 
 | ||||
|             /// The keys to be claimed.
 | ||||
|             pub one_time_keys: BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, DeviceKeyAlgorithm>>, | ||||
|         } | ||||
|         /// The keys to be claimed.
 | ||||
|         pub one_time_keys: BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, DeviceKeyAlgorithm>>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// If any remote homeservers could not be reached, they are recorded here.
 | ||||
|             /// The names of the properties are the names of the unreachable servers.
 | ||||
|             pub failures: BTreeMap<String, JsonValue>, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// If any remote homeservers could not be reached, they are recorded here.
 | ||||
|         /// The names of the properties are the names of the unreachable servers.
 | ||||
|         pub failures: BTreeMap<String, JsonValue>, | ||||
| 
 | ||||
|             /// One-time keys for the queried devices.
 | ||||
|             pub one_time_keys: BTreeMap<OwnedUserId, OneTimeKeys>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// One-time keys for the queried devices.
 | ||||
|         pub one_time_keys: BTreeMap<OwnedUserId, OneTimeKeys>, | ||||
|     } | ||||
| 
 | ||||
|     impl Request { | ||||
|  | ||||
| @ -5,45 +5,47 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3keyschanges
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, OwnedUserId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, OwnedUserId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Gets a list of users who have updated their device identity keys since a previous sync token.", | ||||
|             method: GET, | ||||
|             name: "get_key_changes", | ||||
|             r0_path: "/_matrix/client/r0/keys/changes", | ||||
|             stable_path: "/_matrix/client/v3/keys/changes", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Gets a list of users who have updated their device identity keys since a previous sync token.", | ||||
|         method: GET, | ||||
|         name: "get_key_changes", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/keys/changes", | ||||
|             1.1 => "/_matrix/client/v3/keys/changes", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The desired start point of the list.
 | ||||
|             ///
 | ||||
|             /// Should be the next_batch field from a response to an earlier call to /sync.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub from: &'a str, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The desired start point of the list.
 | ||||
|         ///
 | ||||
|         /// Should be the next_batch field from a response to an earlier call to /sync.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub from: &'a str, | ||||
| 
 | ||||
|             /// The desired end point of the list.
 | ||||
|             ///
 | ||||
|             /// Should be the next_batch field from a recent call to /sync - typically the most recent
 | ||||
|             /// such call.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub to: &'a str, | ||||
|         } | ||||
|         /// The desired end point of the list.
 | ||||
|         ///
 | ||||
|         /// Should be the next_batch field from a recent call to /sync - typically the most recent
 | ||||
|         /// such call.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub to: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// The Matrix User IDs of all users who updated their device identity keys.
 | ||||
|             pub changed: Vec<OwnedUserId>, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The Matrix User IDs of all users who updated their device identity keys.
 | ||||
|         pub changed: Vec<OwnedUserId>, | ||||
| 
 | ||||
|             /// The Matrix User IDs of all users who may have left all the end-to-end
 | ||||
|             /// encrypted rooms they previously shared with the user.
 | ||||
|             pub left: Vec<OwnedUserId>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The Matrix User IDs of all users who may have left all the end-to-end
 | ||||
|         /// encrypted rooms they previously shared with the user.
 | ||||
|         pub left: Vec<OwnedUserId>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -8,77 +8,78 @@ pub mod v3 { | ||||
|     use std::{collections::BTreeMap, time::Duration}; | ||||
| 
 | ||||
|     use ruma_common::{ | ||||
|         api::ruma_api, | ||||
|         api::{request, response, Metadata}, | ||||
|         encryption::{CrossSigningKey, DeviceKeys}, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|         OwnedDeviceId, OwnedUserId, | ||||
|     }; | ||||
|     use serde_json::Value as JsonValue; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Returns the current devices and identity keys for the given users.", | ||||
|             method: POST, | ||||
|             name: "get_keys", | ||||
|             r0_path: "/_matrix/client/r0/keys/query", | ||||
|             stable_path: "/_matrix/client/v3/keys/query", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Returns the current devices and identity keys for the given users.", | ||||
|         method: POST, | ||||
|         name: "get_keys", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/keys/query", | ||||
|             1.1 => "/_matrix/client/v3/keys/query", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         request: { | ||||
|             /// The time (in milliseconds) to wait when downloading keys from remote servers.
 | ||||
|             ///
 | ||||
|             /// 10 seconds is the recommended default.
 | ||||
|             #[serde(
 | ||||
|                 with = "ruma_common::serde::duration::opt_ms", | ||||
|                 default, | ||||
|                 skip_serializing_if = "Option::is_none", | ||||
|             )] | ||||
|             pub timeout: Option<Duration>, | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The time (in milliseconds) to wait when downloading keys from remote servers.
 | ||||
|         ///
 | ||||
|         /// 10 seconds is the recommended default.
 | ||||
|         #[serde(
 | ||||
|             with = "ruma_common::serde::duration::opt_ms", | ||||
|             default, | ||||
|             skip_serializing_if = "Option::is_none" | ||||
|         )] | ||||
|         pub timeout: Option<Duration>, | ||||
| 
 | ||||
|             /// The keys to be downloaded.
 | ||||
|             ///
 | ||||
|             /// An empty list indicates all devices for the corresponding user.
 | ||||
|             pub device_keys: BTreeMap<OwnedUserId, Vec<OwnedDeviceId>>, | ||||
|         /// The keys to be downloaded.
 | ||||
|         ///
 | ||||
|         /// An empty list indicates all devices for the corresponding user.
 | ||||
|         pub device_keys: BTreeMap<OwnedUserId, Vec<OwnedDeviceId>>, | ||||
| 
 | ||||
|             /// If the client is fetching keys as a result of a device update received in a sync
 | ||||
|             /// request, this should be the 'since' token of that sync request, or any later sync token.
 | ||||
|             ///
 | ||||
|             /// This allows the server to ensure its response contains the keys advertised by the
 | ||||
|             /// notification in that sync.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub token: Option<&'a str>, | ||||
|         } | ||||
|         /// If the client is fetching keys as a result of a device update received in a sync
 | ||||
|         /// request, this should be the 'since' token of that sync request, or any later sync
 | ||||
|         /// token.
 | ||||
|         ///
 | ||||
|         /// This allows the server to ensure its response contains the keys advertised by the
 | ||||
|         /// notification in that sync.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub token: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: { | ||||
|             /// If any remote homeservers could not be reached, they are recorded here.
 | ||||
|             ///
 | ||||
|             /// The names of the properties are the names of the unreachable servers.
 | ||||
|             #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] | ||||
|             pub failures: BTreeMap<String, JsonValue>, | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response { | ||||
|         /// If any remote homeservers could not be reached, they are recorded here.
 | ||||
|         ///
 | ||||
|         /// The names of the properties are the names of the unreachable servers.
 | ||||
|         #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] | ||||
|         pub failures: BTreeMap<String, JsonValue>, | ||||
| 
 | ||||
|             /// Information on the queried devices.
 | ||||
|             #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] | ||||
|             pub device_keys: BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, Raw<DeviceKeys>>>, | ||||
|         /// Information on the queried devices.
 | ||||
|         #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] | ||||
|         pub device_keys: BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, Raw<DeviceKeys>>>, | ||||
| 
 | ||||
|             /// Information on the master cross-signing keys of the queried users.
 | ||||
|             #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] | ||||
|             pub master_keys: BTreeMap<OwnedUserId, Raw<CrossSigningKey>>, | ||||
|         /// Information on the master cross-signing keys of the queried users.
 | ||||
|         #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] | ||||
|         pub master_keys: BTreeMap<OwnedUserId, Raw<CrossSigningKey>>, | ||||
| 
 | ||||
|             /// Information on the self-signing keys of the queried users.
 | ||||
|             #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] | ||||
|             pub self_signing_keys: BTreeMap<OwnedUserId, Raw<CrossSigningKey>>, | ||||
|         /// Information on the self-signing keys of the queried users.
 | ||||
|         #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] | ||||
|         pub self_signing_keys: BTreeMap<OwnedUserId, Raw<CrossSigningKey>>, | ||||
| 
 | ||||
|             /// Information on the user-signing keys of the queried users.
 | ||||
|             #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] | ||||
|             pub user_signing_keys: BTreeMap<OwnedUserId, Raw<CrossSigningKey>>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// Information on the user-signing keys of the queried users.
 | ||||
|         #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] | ||||
|         pub user_signing_keys: BTreeMap<OwnedUserId, Raw<CrossSigningKey>>, | ||||
|     } | ||||
| 
 | ||||
|     impl Request<'_> { | ||||
|  | ||||
| @ -9,48 +9,48 @@ pub mod v3 { | ||||
| 
 | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::{ | ||||
|         api::ruma_api, | ||||
|         api::{request, response, Metadata}, | ||||
|         encryption::{DeviceKeys, OneTimeKey}, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|         DeviceKeyAlgorithm, OwnedDeviceKeyId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Publishes end-to-end encryption keys for the device.", | ||||
|             method: POST, | ||||
|             name: "upload_keys", | ||||
|             r0_path: "/_matrix/client/r0/keys/upload", | ||||
|             stable_path: "/_matrix/client/v3/keys/upload", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Publishes end-to-end encryption keys for the device.", | ||||
|         method: POST, | ||||
|         name: "upload_keys", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/keys/upload", | ||||
|             1.1 => "/_matrix/client/v3/keys/upload", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         request: { | ||||
|             /// Identity keys for the device.
 | ||||
|             ///
 | ||||
|             /// May be absent if no new identity keys are required.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub device_keys: Option<Raw<DeviceKeys>>, | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Request { | ||||
|         /// Identity keys for the device.
 | ||||
|         ///
 | ||||
|         /// May be absent if no new identity keys are required.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub device_keys: Option<Raw<DeviceKeys>>, | ||||
| 
 | ||||
|             /// One-time public keys for "pre-key" messages.
 | ||||
|             #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] | ||||
|             pub one_time_keys: BTreeMap<OwnedDeviceKeyId, Raw<OneTimeKey>>, | ||||
|         /// One-time public keys for "pre-key" messages.
 | ||||
|         #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] | ||||
|         pub one_time_keys: BTreeMap<OwnedDeviceKeyId, Raw<OneTimeKey>>, | ||||
| 
 | ||||
|             /// Fallback public keys for "pre-key" messages.
 | ||||
|             #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] | ||||
|             pub fallback_keys: BTreeMap<OwnedDeviceKeyId, Raw<OneTimeKey>>, | ||||
|         } | ||||
|         /// Fallback public keys for "pre-key" messages.
 | ||||
|         #[serde(default, skip_serializing_if = "BTreeMap::is_empty")] | ||||
|         pub fallback_keys: BTreeMap<OwnedDeviceKeyId, Raw<OneTimeKey>>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// For each key algorithm, the number of unclaimed one-time keys of that
 | ||||
|             /// type currently held on the server for this device.
 | ||||
|             pub one_time_key_counts: BTreeMap<DeviceKeyAlgorithm, UInt>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// For each key algorithm, the number of unclaimed one-time keys of that
 | ||||
|         /// type currently held on the server for this device.
 | ||||
|         pub one_time_key_counts: BTreeMap<DeviceKeyAlgorithm, UInt>, | ||||
|     } | ||||
| 
 | ||||
|     impl Request { | ||||
|  | ||||
| @ -8,8 +8,9 @@ pub mod v3 { | ||||
|     use std::collections::BTreeMap; | ||||
| 
 | ||||
|     use ruma_common::{ | ||||
|         api::ruma_api, | ||||
|         api::{request, response, Metadata}, | ||||
|         encryption::{CrossSigningKey, DeviceKeys}, | ||||
|         metadata, | ||||
|         serde::{Raw, StringEnum}, | ||||
|         OwnedDeviceId, OwnedUserId, | ||||
|     }; | ||||
| @ -20,31 +21,30 @@ pub mod v3 { | ||||
| 
 | ||||
|     pub use super::iter::SignedKeysIter; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Publishes cross-signing signatures for the user.", | ||||
|             method: POST, | ||||
|             name: "upload_signatures", | ||||
|             unstable_path: "/_matrix/client/unstable/keys/signatures/upload", | ||||
|             stable_path: "/_matrix/client/v3/keys/signatures/upload", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.1, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Publishes cross-signing signatures for the user.", | ||||
|         method: POST, | ||||
|         name: "upload_signatures", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/keys/signatures/upload", | ||||
|             1.1 => "/_matrix/client/v3/keys/signatures/upload", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// Signed keys.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub signed_keys: BTreeMap<OwnedUserId, SignedKeys>, | ||||
|         } | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request { | ||||
|         /// Signed keys.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub signed_keys: BTreeMap<OwnedUserId, SignedKeys>, | ||||
|     } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: { | ||||
|             /// Signature processing failures.
 | ||||
|             pub failures: BTreeMap<OwnedUserId, BTreeMap<String, Failure>>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response { | ||||
|         /// Signature processing failures.
 | ||||
|         pub failures: BTreeMap<OwnedUserId, BTreeMap<String, Failure>>, | ||||
|     } | ||||
| 
 | ||||
|     impl Request { | ||||
|  | ||||
| @ -5,53 +5,57 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3keysdevice_signingupload
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, encryption::CrossSigningKey, serde::Raw}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         encryption::CrossSigningKey, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::uiaa::{AuthData, IncomingAuthData, UiaaResponse}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Publishes cross signing keys for the user.", | ||||
|             method: POST, | ||||
|             name: "upload_signing_keys", | ||||
|             unstable_path: "/_matrix/client/unstable/keys/device_signing/upload", | ||||
|             stable_path: "/_matrix/client/v3/keys/device_signing/upload", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.1, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Publishes cross signing keys for the user.", | ||||
|         method: POST, | ||||
|         name: "upload_signing_keys", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/keys/device_signing/upload", | ||||
|             1.1 => "/_matrix/client/v3/keys/device_signing/upload", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         request: { | ||||
|             /// Additional authentication information for the user-interactive authentication API.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub auth: Option<AuthData<'a>>, | ||||
|     #[request(error = UiaaResponse)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Additional authentication information for the user-interactive authentication API.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub auth: Option<AuthData<'a>>, | ||||
| 
 | ||||
|             /// The user's master key.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub master_key: Option<Raw<CrossSigningKey>>, | ||||
|         /// The user's master key.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub master_key: Option<Raw<CrossSigningKey>>, | ||||
| 
 | ||||
|             /// The user's self-signing key.
 | ||||
|             ///
 | ||||
|             /// Must be signed with the accompanied master, or by the user's most recently uploaded
 | ||||
|             /// master key if no master key is included in the request.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub self_signing_key: Option<Raw<CrossSigningKey>>, | ||||
|         /// The user's self-signing key.
 | ||||
|         ///
 | ||||
|         /// Must be signed with the accompanied master, or by the user's most recently uploaded
 | ||||
|         /// master key if no master key is included in the request.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub self_signing_key: Option<Raw<CrossSigningKey>>, | ||||
| 
 | ||||
|             /// The user's user-signing key.
 | ||||
|             ///
 | ||||
|             /// Must be signed with the accompanied master, or by the user's most recently uploaded
 | ||||
|             /// master key if no master key is included in the request.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub user_signing_key: Option<Raw<CrossSigningKey>>, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: UiaaResponse | ||||
|         /// The user's user-signing key.
 | ||||
|         ///
 | ||||
|         /// Must be signed with the accompanied master, or by the user's most recently uploaded
 | ||||
|         /// master key if no master key is included in the request.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub user_signing_key: Option<Raw<CrossSigningKey>>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = UiaaResponse)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl Request<'_> { | ||||
|         /// Creates an empty `Request`.
 | ||||
|         pub fn new() -> Self { | ||||
|  | ||||
| @ -5,41 +5,45 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3knockroomidoralias
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, OwnedRoomId, OwnedServerName, RoomOrAliasId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, OwnedRoomId, OwnedServerName, RoomOrAliasId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Knock on a room.", | ||||
|             method: POST, | ||||
|             name: "knock_room", | ||||
|             unstable_path: "/_matrix/client/unstable/xyz.amorgan.knock/knock/:room_id_or_alias", | ||||
|             stable_path: "/_matrix/client/v3/knock/:room_id_or_alias", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.1, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Knock on a room.", | ||||
|         method: POST, | ||||
|         name: "knock_room", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/xyz.amorgan.knock/knock/:room_id_or_alias", | ||||
|             1.1 => "/_matrix/client/v3/knock/:room_id_or_alias", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The room the user should knock on.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id_or_alias: &'a RoomOrAliasId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room the user should knock on.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id_or_alias: &'a RoomOrAliasId, | ||||
| 
 | ||||
|             /// The reason for joining a room.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub reason: Option<&'a str>, | ||||
|         /// The reason for joining a room.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub reason: Option<&'a str>, | ||||
| 
 | ||||
|             /// The servers to attempt to knock on the room through.
 | ||||
|             ///
 | ||||
|             /// One of the servers must be participating in the room.
 | ||||
|             #[ruma_api(query)] | ||||
|             #[serde(default, skip_serializing_if = "<[_]>::is_empty")] | ||||
|             pub server_name: &'a [OwnedServerName], | ||||
|         } | ||||
|         /// The servers to attempt to knock on the room through.
 | ||||
|         ///
 | ||||
|         /// One of the servers must be participating in the room.
 | ||||
|         #[ruma_api(query)] | ||||
|         #[serde(default, skip_serializing_if = "<[_]>::is_empty")] | ||||
|         pub server_name: &'a [OwnedServerName], | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// The room that the user knocked on.
 | ||||
|             pub room_id: OwnedRoomId, | ||||
|         } | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The room that the user knocked on.
 | ||||
|         pub room_id: OwnedRoomId, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -7,7 +7,7 @@ | ||||
| 
 | ||||
| #![cfg(any(feature = "client", feature = "server"))] | ||||
| #![cfg_attr(docsrs, feature(doc_auto_cfg))] | ||||
| #![warn(missing_docs)] | ||||
| // #![warn(missing_docs)] FIXME
 | ||||
| 
 | ||||
| pub mod account; | ||||
| pub mod alias; | ||||
|  | ||||
| @ -6,66 +6,68 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixmediav3upload
 | ||||
| 
 | ||||
|     use http::header::CONTENT_TYPE; | ||||
|     use ruma_common::{api::ruma_api, OwnedMxcUri}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, OwnedMxcUri, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Upload content to the media store.", | ||||
|             method: POST, | ||||
|             name: "create_media_content", | ||||
|             r0_path: "/_matrix/media/r0/upload", | ||||
|             stable_path: "/_matrix/media/v3/upload", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Upload content to the media store.", | ||||
|         method: POST, | ||||
|         name: "create_media_content", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/media/r0/upload", | ||||
|             1.1 => "/_matrix/media/v3/upload", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The file contents to upload.
 | ||||
|             #[ruma_api(raw_body)] | ||||
|             pub file: &'a [u8], | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The file contents to upload.
 | ||||
|         #[ruma_api(raw_body)] | ||||
|         pub file: &'a [u8], | ||||
| 
 | ||||
|             /// The name of the file being uploaded.
 | ||||
|             #[ruma_api(query)] | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub filename: Option<&'a str>, | ||||
|         /// The name of the file being uploaded.
 | ||||
|         #[ruma_api(query)] | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub filename: Option<&'a str>, | ||||
| 
 | ||||
|             /// The content type of the file being uploaded.
 | ||||
|             #[ruma_api(header = CONTENT_TYPE)] | ||||
|             pub content_type: Option<&'a str>, | ||||
|         /// The content type of the file being uploaded.
 | ||||
|         #[ruma_api(header = CONTENT_TYPE)] | ||||
|         pub content_type: Option<&'a str>, | ||||
| 
 | ||||
|             /// Should the server return a blurhash or not.
 | ||||
|             ///
 | ||||
|             /// This uses the unstable prefix in
 | ||||
|             /// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448).
 | ||||
|             #[ruma_api(query)] | ||||
|             #[cfg(feature = "unstable-msc2448")] | ||||
|             #[serde(
 | ||||
|                 default, | ||||
|                 skip_serializing_if = "ruma_common::serde::is_default", | ||||
|                 rename = "xyz.amorgan.generate_blurhash", | ||||
|             )] | ||||
|             pub generate_blurhash: bool, | ||||
|         } | ||||
|         /// Should the server return a blurhash or not.
 | ||||
|         ///
 | ||||
|         /// This uses the unstable prefix in
 | ||||
|         /// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448).
 | ||||
|         #[ruma_api(query)] | ||||
|         #[cfg(feature = "unstable-msc2448")] | ||||
|         #[serde(
 | ||||
|             default, | ||||
|             skip_serializing_if = "ruma_common::serde::is_default", | ||||
|             rename = "xyz.amorgan.generate_blurhash" | ||||
|         )] | ||||
|         pub generate_blurhash: bool, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// The MXC URI for the uploaded content.
 | ||||
|             pub content_uri: OwnedMxcUri, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The MXC URI for the uploaded content.
 | ||||
|         pub content_uri: OwnedMxcUri, | ||||
| 
 | ||||
|             /// The [BlurHash](https://blurha.sh) for the uploaded content.
 | ||||
|             ///
 | ||||
|             /// This uses the unstable prefix in
 | ||||
|             /// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448).
 | ||||
|             #[cfg(feature = "unstable-msc2448")] | ||||
|             #[serde(
 | ||||
|                 rename = "xyz.amorgan.blurhash", | ||||
|                 alias = "blurhash", | ||||
|                 skip_serializing_if = "Option::is_none" | ||||
|             )] | ||||
|             pub blurhash: Option<String>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The [BlurHash](https://blurha.sh) for the uploaded content.
 | ||||
|         ///
 | ||||
|         /// This uses the unstable prefix in
 | ||||
|         /// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448).
 | ||||
|         #[cfg(feature = "unstable-msc2448")] | ||||
|         #[serde(
 | ||||
|             rename = "xyz.amorgan.blurhash", | ||||
|             alias = "blurhash", | ||||
|             skip_serializing_if = "Option::is_none" | ||||
|         )] | ||||
|         pub blurhash: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -6,43 +6,45 @@ pub mod unstable { | ||||
|     //! [spec]: https://github.com/tulir/matrix-doc/blob/asynchronous_uploads/proposals/2246-asynchronous-uploads.md
 | ||||
| 
 | ||||
|     use http::header::CONTENT_TYPE; | ||||
|     use ruma_common::{api::ruma_api, IdParseError, MxcUri, ServerName}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, IdParseError, MxcUri, ServerName, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Upload media to an MXC URI that was created with create_mxc_uri.", | ||||
|             method: PUT, | ||||
|             name: "create_content_async", | ||||
|             unstable_path: "/_matrix/media/unstable/fi.mau.msc2246/upload/:server_name/:media_id", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Upload media to an MXC URI that was created with create_mxc_uri.", | ||||
|         method: PUT, | ||||
|         name: "create_content_async", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/media/unstable/fi.mau.msc2246/upload/:server_name/:media_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The server name from the mxc:// URI (the authoritory component).
 | ||||
|             #[ruma_api(path)] | ||||
|             pub server_name: &'a ServerName, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The server name from the mxc:// URI (the authoritory component).
 | ||||
|         #[ruma_api(path)] | ||||
|         pub server_name: &'a ServerName, | ||||
| 
 | ||||
|             /// The media ID from the mxc:// URI (the path component).
 | ||||
|             #[ruma_api(path)] | ||||
|             pub media_id: &'a str, | ||||
|         /// The media ID from the mxc:// URI (the path component).
 | ||||
|         #[ruma_api(path)] | ||||
|         pub media_id: &'a str, | ||||
| 
 | ||||
|             /// The file contents to upload.
 | ||||
|             #[ruma_api(raw_body)] | ||||
|             pub file: &'a [u8], | ||||
|         /// The file contents to upload.
 | ||||
|         #[ruma_api(raw_body)] | ||||
|         pub file: &'a [u8], | ||||
| 
 | ||||
|             /// The content type of the file being uploaded.
 | ||||
|             #[ruma_api(header = CONTENT_TYPE)] | ||||
|             pub content_type: Option<&'a str>, | ||||
| 
 | ||||
|             // TODO: How does this and msc2448 (blurhash) interact?
 | ||||
|         } | ||||
| 
 | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The content type of the file being uploaded.
 | ||||
|         #[ruma_api(header = CONTENT_TYPE)] | ||||
|         pub content_type: Option<&'a str>, | ||||
|         // TODO: How does this and msc2448 (blurhash) interact?
 | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given file contents.
 | ||||
|         pub fn new(media_id: &'a str, server_name: &'a ServerName, file: &'a [u8]) -> Self { | ||||
|  | ||||
| @ -6,29 +6,33 @@ pub mod unstable { | ||||
|     //! [spec]: https://github.com/tulir/matrix-doc/blob/asynchronous_uploads/proposals/2246-asynchronous-uploads.md
 | ||||
| 
 | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::{api::ruma_api, OwnedMxcUri}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, OwnedMxcUri, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Create an MXC URI without content.", | ||||
|             method: POST, | ||||
|             name: "create_mxc_uri", | ||||
|             unstable_path: "/_matrix/media/unstable/fi.mau.msc2246/create", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Create an MXC URI without content.", | ||||
|         method: POST, | ||||
|         name: "create_mxc_uri", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/media/unstable/fi.mau.msc2246/create", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: {} | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Request {} | ||||
| 
 | ||||
|         response: { | ||||
|             /// The MXC URI for the about to be uploaded content.
 | ||||
|             pub content_uri: OwnedMxcUri, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The MXC URI for the about to be uploaded content.
 | ||||
|         pub content_uri: OwnedMxcUri, | ||||
| 
 | ||||
|             /// The time at which the URI will expire if an upload has not been started.
 | ||||
|             pub unused_expires_at: UInt, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The time at which the URI will expire if an upload has not been started.
 | ||||
|         pub unused_expires_at: UInt, | ||||
|     } | ||||
| 
 | ||||
|     impl Response { | ||||
|  | ||||
| @ -8,81 +8,85 @@ pub mod v3 { | ||||
|     use http::header::{CONTENT_DISPOSITION, CONTENT_TYPE}; | ||||
|     #[cfg(feature = "unstable-msc2246")] | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::{api::ruma_api, IdParseError, MxcUri, ServerName}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, IdParseError, MxcUri, ServerName, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::http_headers::CROSS_ORIGIN_RESOURCE_POLICY; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Retrieve content from the media store.", | ||||
|             method: GET, | ||||
|             name: "get_media_content", | ||||
|             r0_path: "/_matrix/media/r0/download/:server_name/:media_id", | ||||
|             stable_path: "/_matrix/media/v3/download/:server_name/:media_id", | ||||
|             rate_limited: false, | ||||
|             authentication: None, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Retrieve content from the media store.", | ||||
|         method: GET, | ||||
|         name: "get_media_content", | ||||
|         rate_limited: false, | ||||
|         authentication: None, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/media/r0/download/:server_name/:media_id", | ||||
|             1.1 => "/_matrix/media/v3/download/:server_name/:media_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The server name from the mxc:// URI (the authoritory component).
 | ||||
|             #[ruma_api(path)] | ||||
|             pub server_name: &'a ServerName, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The server name from the mxc:// URI (the authoritory component).
 | ||||
|         #[ruma_api(path)] | ||||
|         pub server_name: &'a ServerName, | ||||
| 
 | ||||
|             /// The media ID from the mxc:// URI (the path component).
 | ||||
|             #[ruma_api(path)] | ||||
|             pub media_id: &'a str, | ||||
|         /// The media ID from the mxc:// URI (the path component).
 | ||||
|         #[ruma_api(path)] | ||||
|         pub media_id: &'a str, | ||||
| 
 | ||||
|             /// Whether to fetch media deemed remote.
 | ||||
|             ///
 | ||||
|             /// Used to prevent routing loops. Defaults to `true`.
 | ||||
|             #[ruma_api(query)] | ||||
|             #[serde(default = "ruma_common::serde::default_true", skip_serializing_if = "ruma_common::serde::is_true")] | ||||
|             pub allow_remote: bool, | ||||
|         /// Whether to fetch media deemed remote.
 | ||||
|         ///
 | ||||
|         /// Used to prevent routing loops. Defaults to `true`.
 | ||||
|         #[ruma_api(query)] | ||||
|         #[serde(
 | ||||
|             default = "ruma_common::serde::default_true", | ||||
|             skip_serializing_if = "ruma_common::serde::is_true" | ||||
|         )] | ||||
|         pub allow_remote: bool, | ||||
| 
 | ||||
|         /// How long to wait for the media to be uploaded
 | ||||
|         ///
 | ||||
|         /// This uses the unstable prefix in
 | ||||
|         /// [MSC2246](https://github.com/matrix-org/matrix-spec-proposals/pull/2246)
 | ||||
|         #[ruma_api(query)] | ||||
|         #[cfg(feature = "unstable-msc2246")] | ||||
|         #[serde(
 | ||||
|             default, | ||||
|             skip_serializing_if = "ruma_common::serde::is_default", | ||||
|             rename = "fi.mau.msc2246.max_stall_ms" | ||||
|         )] | ||||
|         pub max_stall_ms: Option<UInt>, | ||||
|     } | ||||
| 
 | ||||
|             /// How long to wait for the media to be uploaded
 | ||||
|             ///
 | ||||
|             /// This uses the unstable prefix in
 | ||||
|             /// [MSC2246](https://github.com/matrix-org/matrix-spec-proposals/pull/2246)
 | ||||
|             #[ruma_api(query)] | ||||
|             #[cfg(feature = "unstable-msc2246")] | ||||
|             #[serde(
 | ||||
|                 default, | ||||
|                 skip_serializing_if = "ruma_common::serde::is_default", | ||||
|                 rename = "fi.mau.msc2246.max_stall_ms", | ||||
|             )] | ||||
|             pub max_stall_ms: Option<UInt>, | ||||
|         } | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The content that was previously uploaded.
 | ||||
|         #[ruma_api(raw_body)] | ||||
|         pub file: Vec<u8>, | ||||
| 
 | ||||
|         response: { | ||||
|             /// The content that was previously uploaded.
 | ||||
|             #[ruma_api(raw_body)] | ||||
|             pub file: Vec<u8>, | ||||
|         /// The content type of the file that was previously uploaded.
 | ||||
|         #[ruma_api(header = CONTENT_TYPE)] | ||||
|         pub content_type: Option<String>, | ||||
| 
 | ||||
|             /// The content type of the file that was previously uploaded.
 | ||||
|             #[ruma_api(header = CONTENT_TYPE)] | ||||
|             pub content_type: Option<String>, | ||||
|         /// The value of the `Content-Disposition` HTTP header, possibly containing the name of the
 | ||||
|         /// file that was previously uploaded.
 | ||||
|         ///
 | ||||
|         /// See [MDN] for the syntax.
 | ||||
|         ///
 | ||||
|         /// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#Syntax
 | ||||
|         #[ruma_api(header = CONTENT_DISPOSITION)] | ||||
|         pub content_disposition: Option<String>, | ||||
| 
 | ||||
|             /// The value of the `Content-Disposition` HTTP header, possibly containing the name of the
 | ||||
|             /// file that was previously uploaded.
 | ||||
|             ///
 | ||||
|             /// See [MDN] for the syntax.
 | ||||
|             ///
 | ||||
|             /// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#Syntax
 | ||||
|             #[ruma_api(header = CONTENT_DISPOSITION)] | ||||
|             pub content_disposition: Option<String>, | ||||
| 
 | ||||
|             /// The value of the `Cross-Origin-Resource-Policy` HTTP header.
 | ||||
|             ///
 | ||||
|             /// See [MDN] for the syntax.
 | ||||
|             ///
 | ||||
|             /// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Resource-Policy#syntax
 | ||||
|             #[ruma_api(header = CROSS_ORIGIN_RESOURCE_POLICY)] | ||||
|             pub cross_origin_resource_policy: Option<String>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The value of the `Cross-Origin-Resource-Policy` HTTP header.
 | ||||
|         ///
 | ||||
|         /// See [MDN] for the syntax.
 | ||||
|         ///
 | ||||
|         /// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Resource-Policy#syntax
 | ||||
|         #[ruma_api(header = CROSS_ORIGIN_RESOURCE_POLICY)] | ||||
|         pub cross_origin_resource_policy: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -6,71 +6,76 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixmediav3downloadservernamemediaidfilename
 | ||||
| 
 | ||||
|     use http::header::{CONTENT_DISPOSITION, CONTENT_TYPE}; | ||||
|     use ruma_common::{api::ruma_api, IdParseError, MxcUri, ServerName}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, IdParseError, MxcUri, ServerName, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::http_headers::CROSS_ORIGIN_RESOURCE_POLICY; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Retrieve content from the media store, specifying a filename to return.", | ||||
|             method: GET, | ||||
|             name: "get_media_content_as_filename", | ||||
|             r0_path: "/_matrix/media/r0/download/:server_name/:media_id/:filename", | ||||
|             stable_path: "/_matrix/media/v3/download/:server_name/:media_id/:filename", | ||||
|             rate_limited: false, | ||||
|             authentication: None, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Retrieve content from the media store, specifying a filename to return.", | ||||
|         method: GET, | ||||
|         name: "get_media_content_as_filename", | ||||
|         rate_limited: false, | ||||
|         authentication: None, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/media/r0/download/:server_name/:media_id/:filename", | ||||
|             1.1 => "/_matrix/media/v3/download/:server_name/:media_id/:filename", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The server name from the mxc:// URI (the authoritory component).
 | ||||
|             #[ruma_api(path)] | ||||
|             pub server_name: &'a ServerName, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The server name from the mxc:// URI (the authoritory component).
 | ||||
|         #[ruma_api(path)] | ||||
|         pub server_name: &'a ServerName, | ||||
| 
 | ||||
|             /// The media ID from the mxc:// URI (the path component).
 | ||||
|             #[ruma_api(path)] | ||||
|             pub media_id: &'a str, | ||||
|         /// The media ID from the mxc:// URI (the path component).
 | ||||
|         #[ruma_api(path)] | ||||
|         pub media_id: &'a str, | ||||
| 
 | ||||
|             /// The filename to return in the `Content-Disposition` header.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub filename: &'a str, | ||||
|         /// The filename to return in the `Content-Disposition` header.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub filename: &'a str, | ||||
| 
 | ||||
|             /// Whether to fetch media deemed remote.
 | ||||
|             ///
 | ||||
|             /// Used to prevent routing loops. Defaults to `true`.
 | ||||
|             #[ruma_api(query)] | ||||
|             #[serde(default = "ruma_common::serde::default_true", skip_serializing_if = "ruma_common::serde::is_true")] | ||||
|             pub allow_remote: bool, | ||||
|         } | ||||
|         /// Whether to fetch media deemed remote.
 | ||||
|         ///
 | ||||
|         /// Used to prevent routing loops. Defaults to `true`.
 | ||||
|         #[ruma_api(query)] | ||||
|         #[serde(
 | ||||
|             default = "ruma_common::serde::default_true", | ||||
|             skip_serializing_if = "ruma_common::serde::is_true" | ||||
|         )] | ||||
|         pub allow_remote: bool, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// The content that was previously uploaded.
 | ||||
|             #[ruma_api(raw_body)] | ||||
|             pub file: Vec<u8>, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The content that was previously uploaded.
 | ||||
|         #[ruma_api(raw_body)] | ||||
|         pub file: Vec<u8>, | ||||
| 
 | ||||
|             /// The content type of the file that was previously uploaded.
 | ||||
|             #[ruma_api(header = CONTENT_TYPE)] | ||||
|             pub content_type: Option<String>, | ||||
|         /// The content type of the file that was previously uploaded.
 | ||||
|         #[ruma_api(header = CONTENT_TYPE)] | ||||
|         pub content_type: Option<String>, | ||||
| 
 | ||||
|             /// The value of the `Content-Disposition` HTTP header, possibly containing the name of the
 | ||||
|             /// file that was previously uploaded.
 | ||||
|             ///
 | ||||
|             /// See [MDN] for the syntax.
 | ||||
|             ///
 | ||||
|             /// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#Syntax
 | ||||
|             #[ruma_api(header = CONTENT_DISPOSITION)] | ||||
|             pub content_disposition: Option<String>, | ||||
|         /// The value of the `Content-Disposition` HTTP header, possibly containing the name of the
 | ||||
|         /// file that was previously uploaded.
 | ||||
|         ///
 | ||||
|         /// See [MDN] for the syntax.
 | ||||
|         ///
 | ||||
|         /// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#Syntax
 | ||||
|         #[ruma_api(header = CONTENT_DISPOSITION)] | ||||
|         pub content_disposition: Option<String>, | ||||
| 
 | ||||
|             /// The value of the `Cross-Origin-Resource-Policy` HTTP header.
 | ||||
|             ///
 | ||||
|             /// See [MDN] for the syntax.
 | ||||
|             ///
 | ||||
|             /// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Resource-Policy#syntax
 | ||||
|             #[ruma_api(header = CROSS_ORIGIN_RESOURCE_POLICY)] | ||||
|             pub cross_origin_resource_policy: Option<String>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The value of the `Cross-Origin-Resource-Policy` HTTP header.
 | ||||
|         ///
 | ||||
|         /// See [MDN] for the syntax.
 | ||||
|         ///
 | ||||
|         /// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Resource-Policy#syntax
 | ||||
|         #[ruma_api(header = CROSS_ORIGIN_RESOURCE_POLICY)] | ||||
|         pub cross_origin_resource_policy: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -7,88 +7,95 @@ pub mod v3 { | ||||
| 
 | ||||
|     use http::header::CONTENT_TYPE; | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::{api::ruma_api, serde::StringEnum, IdParseError, MxcUri, ServerName}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         serde::StringEnum, | ||||
|         IdParseError, MxcUri, ServerName, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::{http_headers::CROSS_ORIGIN_RESOURCE_POLICY, PrivOwnedStr}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get a thumbnail of content from the media store.", | ||||
|             method: GET, | ||||
|             name: "get_content_thumbnail", | ||||
|             r0_path: "/_matrix/media/r0/thumbnail/:server_name/:media_id", | ||||
|             stable_path: "/_matrix/media/v3/thumbnail/:server_name/:media_id", | ||||
|             rate_limited: true, | ||||
|             authentication: None, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get a thumbnail of content from the media store.", | ||||
|         method: GET, | ||||
|         name: "get_content_thumbnail", | ||||
|         rate_limited: true, | ||||
|         authentication: None, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/media/r0/thumbnail/:server_name/:media_id", | ||||
|             1.1 => "/_matrix/media/v3/thumbnail/:server_name/:media_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The server name from the mxc:// URI (the authoritory component).
 | ||||
|             #[ruma_api(path)] | ||||
|             pub server_name: &'a ServerName, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The server name from the mxc:// URI (the authoritory component).
 | ||||
|         #[ruma_api(path)] | ||||
|         pub server_name: &'a ServerName, | ||||
| 
 | ||||
|             /// The media ID from the mxc:// URI (the path component).
 | ||||
|             #[ruma_api(path)] | ||||
|             pub media_id: &'a str, | ||||
|         /// The media ID from the mxc:// URI (the path component).
 | ||||
|         #[ruma_api(path)] | ||||
|         pub media_id: &'a str, | ||||
| 
 | ||||
|             /// The desired resizing method.
 | ||||
|             #[ruma_api(query)] | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub method: Option<Method>, | ||||
|         /// The desired resizing method.
 | ||||
|         #[ruma_api(query)] | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub method: Option<Method>, | ||||
| 
 | ||||
|             /// The *desired* width of the thumbnail.
 | ||||
|             ///
 | ||||
|             /// The actual thumbnail may not match the size specified.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub width: UInt, | ||||
|         /// The *desired* width of the thumbnail.
 | ||||
|         ///
 | ||||
|         /// The actual thumbnail may not match the size specified.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub width: UInt, | ||||
| 
 | ||||
|             /// The *desired* height of the thumbnail.
 | ||||
|             ///
 | ||||
|             /// The actual thumbnail may not match the size specified.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub height: UInt, | ||||
|         /// The *desired* height of the thumbnail.
 | ||||
|         ///
 | ||||
|         /// The actual thumbnail may not match the size specified.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub height: UInt, | ||||
| 
 | ||||
|             /// Whether to fetch media deemed remote.
 | ||||
|             ///
 | ||||
|             /// Used to prevent routing loops. Defaults to `true`.
 | ||||
|             #[ruma_api(query)] | ||||
|             #[serde(default = "ruma_common::serde::default_true", skip_serializing_if = "ruma_common::serde::is_true")] | ||||
|             pub allow_remote: bool, | ||||
|         /// Whether to fetch media deemed remote.
 | ||||
|         ///
 | ||||
|         /// Used to prevent routing loops. Defaults to `true`.
 | ||||
|         #[ruma_api(query)] | ||||
|         #[serde(
 | ||||
|             default = "ruma_common::serde::default_true", | ||||
|             skip_serializing_if = "ruma_common::serde::is_true" | ||||
|         )] | ||||
|         pub allow_remote: bool, | ||||
| 
 | ||||
|             /// How long to wait for the media to be uploaded
 | ||||
|             ///
 | ||||
|             /// This uses the unstable prefix in
 | ||||
|             /// [MSC2246](https://github.com/matrix-org/matrix-spec-proposals/pull/2246)
 | ||||
|             #[ruma_api(query)] | ||||
|             #[cfg(feature = "unstable-msc2246")] | ||||
|             #[serde(
 | ||||
|                 default, | ||||
|                 skip_serializing_if = "ruma_common::serde::is_default", | ||||
|                 rename = "fi.mau.msc2246.max_stall_ms", | ||||
|             )] | ||||
|             pub max_stall_ms: Option<UInt>, | ||||
|         } | ||||
|         /// How long to wait for the media to be uploaded
 | ||||
|         ///
 | ||||
|         /// This uses the unstable prefix in
 | ||||
|         /// [MSC2246](https://github.com/matrix-org/matrix-spec-proposals/pull/2246)
 | ||||
|         #[ruma_api(query)] | ||||
|         #[cfg(feature = "unstable-msc2246")] | ||||
|         #[serde(
 | ||||
|             default, | ||||
|             skip_serializing_if = "ruma_common::serde::is_default", | ||||
|             rename = "fi.mau.msc2246.max_stall_ms" | ||||
|         )] | ||||
|         pub max_stall_ms: Option<UInt>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// A thumbnail of the requested content.
 | ||||
|             #[ruma_api(raw_body)] | ||||
|             pub file: Vec<u8>, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A thumbnail of the requested content.
 | ||||
|         #[ruma_api(raw_body)] | ||||
|         pub file: Vec<u8>, | ||||
| 
 | ||||
|             /// The content type of the thumbnail.
 | ||||
|             #[ruma_api(header = CONTENT_TYPE)] | ||||
|             pub content_type: Option<String>, | ||||
|         /// The content type of the thumbnail.
 | ||||
|         #[ruma_api(header = CONTENT_TYPE)] | ||||
|         pub content_type: Option<String>, | ||||
| 
 | ||||
|             /// The value of the `Cross-Origin-Resource-Policy` HTTP header.
 | ||||
|             ///
 | ||||
|             /// See [MDN] for the syntax.
 | ||||
|             ///
 | ||||
|             /// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Resource-Policy#syntax
 | ||||
|             #[ruma_api(header = CROSS_ORIGIN_RESOURCE_POLICY)] | ||||
|             pub cross_origin_resource_policy: Option<String>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The value of the `Cross-Origin-Resource-Policy` HTTP header.
 | ||||
|         ///
 | ||||
|         /// See [MDN] for the syntax.
 | ||||
|         ///
 | ||||
|         /// [MDN]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Resource-Policy#syntax
 | ||||
|         #[ruma_api(header = CROSS_ORIGIN_RESOURCE_POLICY)] | ||||
|         pub cross_origin_resource_policy: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -6,30 +6,32 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixmediav3config
 | ||||
| 
 | ||||
|     use js_int::UInt; | ||||
|     use ruma_common::api::ruma_api; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Gets the config for the media repository.", | ||||
|             method: GET, | ||||
|             r0_path: "/_matrix/media/r0/config", | ||||
|             stable_path: "/_matrix/media/v3/config", | ||||
|             name: "get_media_config", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Gets the config for the media repository.", | ||||
|         method: GET, | ||||
|         name: "get_media_config", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/media/r0/config", | ||||
|             1.1 => "/_matrix/media/v3/config", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         request: {} | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Request {} | ||||
| 
 | ||||
|         response: { | ||||
|             /// Maximum size of upload in bytes.
 | ||||
|             #[serde(rename = "m.upload.size")] | ||||
|             pub upload_size: UInt, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// Maximum size of upload in bytes.
 | ||||
|         #[serde(rename = "m.upload.size")] | ||||
|         pub upload_size: UInt, | ||||
|     } | ||||
| 
 | ||||
|     impl Request { | ||||
|  | ||||
| @ -5,43 +5,45 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixmediav3preview_url
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, MilliSecondsSinceUnixEpoch}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, MilliSecondsSinceUnixEpoch, | ||||
|     }; | ||||
|     use serde::Serialize; | ||||
|     use serde_json::value::{to_raw_value as to_raw_json_value, RawValue as RawJsonValue}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get a preview for a URL.", | ||||
|             name: "get_media_preview", | ||||
|             method: GET, | ||||
|             r0_path: "/_matrix/media/r0/preview_url", | ||||
|             stable_path: "/_matrix/media/v3/preview_url", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get a preview for a URL.", | ||||
|         method: GET, | ||||
|         name: "get_media_preview", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/media/r0/preview_url", | ||||
|             1.1 => "/_matrix/media/v3/preview_url", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// URL to get a preview of.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub url: &'a str, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// URL to get a preview of.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub url: &'a str, | ||||
| 
 | ||||
|             /// Preferred point in time (in milliseconds) to return a preview for.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub ts: MilliSecondsSinceUnixEpoch, | ||||
|         } | ||||
|         /// Preferred point in time (in milliseconds) to return a preview for.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub ts: MilliSecondsSinceUnixEpoch, | ||||
|     } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: { | ||||
|             /// OpenGraph-like data for the URL.
 | ||||
|             ///
 | ||||
|             /// Differences from OpenGraph: the image size in bytes is added to the `matrix:image:size`
 | ||||
|             /// field, and `og:image` returns the MXC URI to the image, if any.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub data: Option<Box<RawJsonValue>>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response { | ||||
|         /// OpenGraph-like data for the URL.
 | ||||
|         ///
 | ||||
|         /// Differences from OpenGraph: the image size in bytes is added to the `matrix:image:size`
 | ||||
|         /// field, and `og:image` returns the MXC URI to the image, if any.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub data: Option<Box<RawJsonValue>>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,39 +5,41 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3roomsroomidban
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, RoomId, UserId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, RoomId, UserId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Ban a user from a room.", | ||||
|             method: POST, | ||||
|             name: "ban_user", | ||||
|             r0_path: "/_matrix/client/r0/rooms/:room_id/ban", | ||||
|             stable_path: "/_matrix/client/v3/rooms/:room_id/ban", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Ban a user from a room.", | ||||
|         method: POST, | ||||
|         name: "ban_user", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/ban", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/ban", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The room to kick the user from.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room to kick the user from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| 
 | ||||
|             /// The user to ban.
 | ||||
|             pub user_id: &'a UserId, | ||||
|         /// The user to ban.
 | ||||
|         pub user_id: &'a UserId, | ||||
| 
 | ||||
|             /// The reason for banning the user.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub reason: Option<&'a str>, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The reason for banning the user.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub reason: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room id and room id.
 | ||||
|         pub fn new(room_id: &'a RoomId, user_id: &'a UserId) -> Self { | ||||
|  | ||||
| @ -5,32 +5,34 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3roomsroomidforget
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, RoomId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, RoomId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Forget a room.", | ||||
|             method: POST, | ||||
|             name: "forget_room", | ||||
|             r0_path: "/_matrix/client/r0/rooms/:room_id/forget", | ||||
|             stable_path: "/_matrix/client/v3/rooms/:room_id/forget", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Forget a room.", | ||||
|         method: POST, | ||||
|         name: "forget_room", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/forget", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/forget", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The room to forget.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room to forget.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room id.
 | ||||
|         pub fn new(room_id: &'a RoomId) -> Self { | ||||
|  | ||||
| @ -6,62 +6,62 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3roomsroomidmembers
 | ||||
| 
 | ||||
|     use ruma_common::{ | ||||
|         api::ruma_api, | ||||
|         api::{request, response, Metadata}, | ||||
|         events::room::member::RoomMemberEvent, | ||||
|         metadata, | ||||
|         serde::{Raw, StringEnum}, | ||||
|         RoomId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::PrivOwnedStr; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get membership events for a room.", | ||||
|             method: GET, | ||||
|             name: "get_member_events", | ||||
|             r0_path: "/_matrix/client/r0/rooms/:room_id/members", | ||||
|             stable_path: "/_matrix/client/v3/rooms/:room_id/members", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get membership events for a room.", | ||||
|         method: GET, | ||||
|         name: "get_member_events", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/members", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/members", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The room to get the member events for.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room to get the member events for.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| 
 | ||||
|             /// The point in time (pagination token) to return members for in the room.
 | ||||
|             ///
 | ||||
|             /// This token can be obtained from a prev_batch token returned for each room by the sync
 | ||||
|             /// API.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[ruma_api(query)] | ||||
|             pub at: Option<&'a str>, | ||||
|         /// The point in time (pagination token) to return members for in the room.
 | ||||
|         ///
 | ||||
|         /// This token can be obtained from a prev_batch token returned for each room by the sync
 | ||||
|         /// API.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[ruma_api(query)] | ||||
|         pub at: Option<&'a str>, | ||||
| 
 | ||||
|             /// The kind of memberships to filter for.
 | ||||
|             ///
 | ||||
|             /// Defaults to no filtering if unspecified. When specified alongside not_membership, the
 | ||||
|             /// two parameters create an 'or' condition: either the membership is the same as membership
 | ||||
|             /// or is not the same as not_membership.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[ruma_api(query)] | ||||
|             pub membership: Option<MembershipEventFilter>, | ||||
|         /// The kind of memberships to filter for.
 | ||||
|         ///
 | ||||
|         /// Defaults to no filtering if unspecified. When specified alongside not_membership, the
 | ||||
|         /// two parameters create an 'or' condition: either the membership is the same as
 | ||||
|         /// membership or is not the same as not_membership.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[ruma_api(query)] | ||||
|         pub membership: Option<MembershipEventFilter>, | ||||
| 
 | ||||
|             /// The kind of memberships to *exclude* from the results.
 | ||||
|             ///
 | ||||
|             /// Defaults to no filtering if unspecified.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[ruma_api(query)] | ||||
|             pub not_membership: Option<MembershipEventFilter>, | ||||
|         } | ||||
|         /// The kind of memberships to *exclude* from the results.
 | ||||
|         ///
 | ||||
|         /// Defaults to no filtering if unspecified.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[ruma_api(query)] | ||||
|         pub not_membership: Option<MembershipEventFilter>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// A list of member events.
 | ||||
|             pub chunk: Vec<Raw<RoomMemberEvent>>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A list of member events.
 | ||||
|         pub chunk: Vec<Raw<RoomMemberEvent>>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -10,43 +10,47 @@ pub mod v3 { | ||||
|     //! [spec-mxid]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3roomsroomidinvite
 | ||||
|     //! [spec-3pid]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3roomsroomidinvite-1
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, serde::Incoming, RoomId, UserId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         serde::Incoming, | ||||
|         RoomId, UserId, | ||||
|     }; | ||||
|     use serde::Serialize; | ||||
| 
 | ||||
|     use crate::membership::{IncomingInvite3pid, Invite3pid}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Invite a user to a room.", | ||||
|             method: POST, | ||||
|             name: "invite_user", | ||||
|             r0_path: "/_matrix/client/r0/rooms/:room_id/invite", | ||||
|             stable_path: "/_matrix/client/v3/rooms/:room_id/invite", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Invite a user to a room.", | ||||
|         method: POST, | ||||
|         name: "invite_user", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/invite", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/invite", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The room where the user should be invited.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room where the user should be invited.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| 
 | ||||
|             /// The user to invite.
 | ||||
|             #[serde(flatten)] | ||||
|             pub recipient: InvitationRecipient<'a>, | ||||
|         /// The user to invite.
 | ||||
|         #[serde(flatten)] | ||||
|         pub recipient: InvitationRecipient<'a>, | ||||
| 
 | ||||
|             /// Optional reason for inviting the user.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub reason: Option<&'a str>, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// Optional reason for inviting the user.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub reason: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room ID and invitation recipient.
 | ||||
|         pub fn new(room_id: &'a RoomId, recipient: InvitationRecipient<'a>) -> Self { | ||||
|  | ||||
| @ -5,43 +5,45 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3roomsroomidjoin
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, OwnedRoomId, RoomId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, OwnedRoomId, RoomId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::membership::{IncomingThirdPartySigned, ThirdPartySigned}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Join a room using its ID.", | ||||
|             method: POST, | ||||
|             name: "join_room_by_id", | ||||
|             r0_path: "/_matrix/client/r0/rooms/:room_id/join", | ||||
|             stable_path: "/_matrix/client/v3/rooms/:room_id/join", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Join a room using its ID.", | ||||
|         method: POST, | ||||
|         name: "join_room_by_id", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/join", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/join", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The room where the user should be invited.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room where the user should be invited.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a 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")] | ||||
|             pub third_party_signed: Option<ThirdPartySigned<'a>>, | ||||
|         /// 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")] | ||||
|         pub third_party_signed: Option<ThirdPartySigned<'a>>, | ||||
| 
 | ||||
|             /// Optional reason for joining the room.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub reason: Option<&'a str>, | ||||
|         } | ||||
|         /// Optional reason for joining the room.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub reason: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// The room that the user joined.
 | ||||
|             pub room_id: OwnedRoomId, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The room that the user joined.
 | ||||
|         pub room_id: OwnedRoomId, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,50 +5,52 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3joinroomidoralias
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, OwnedRoomId, OwnedServerName, RoomOrAliasId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, OwnedRoomId, OwnedServerName, RoomOrAliasId, | ||||
|     }; | ||||
| 
 | ||||
|     use crate::membership::{IncomingThirdPartySigned, ThirdPartySigned}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Join a room using its ID or one of its aliases.", | ||||
|             method: POST, | ||||
|             name: "join_room_by_id_or_alias", | ||||
|             r0_path: "/_matrix/client/r0/join/:room_id_or_alias", | ||||
|             stable_path: "/_matrix/client/v3/join/:room_id_or_alias", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Join a room using its ID or one of its aliases.", | ||||
|         method: POST, | ||||
|         name: "join_room_by_id_or_alias", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/join/:room_id_or_alias", | ||||
|             1.1 => "/_matrix/client/v3/join/:room_id_or_alias", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The room where the user should be invited.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id_or_alias: &'a RoomOrAliasId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room where the user should be invited.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id_or_alias: &'a RoomOrAliasId, | ||||
| 
 | ||||
|             /// The servers to attempt to join the room through.
 | ||||
|             ///
 | ||||
|             /// One of the servers  must be participating in the room.
 | ||||
|             #[ruma_api(query)] | ||||
|             #[serde(default, skip_serializing_if = "<[_]>::is_empty")] | ||||
|             pub server_name: &'a [OwnedServerName], | ||||
|         /// The servers to attempt to join the room through.
 | ||||
|         ///
 | ||||
|         /// One of the servers  must be participating in the room.
 | ||||
|         #[ruma_api(query)] | ||||
|         #[serde(default, skip_serializing_if = "<[_]>::is_empty")] | ||||
|         pub server_name: &'a [OwnedServerName], | ||||
| 
 | ||||
|             /// 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")] | ||||
|             pub third_party_signed: Option<ThirdPartySigned<'a>>, | ||||
|         /// 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")] | ||||
|         pub third_party_signed: Option<ThirdPartySigned<'a>>, | ||||
| 
 | ||||
|             /// Optional reason for joining the room.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub reason: Option<&'a str>, | ||||
|         } | ||||
|         /// Optional reason for joining the room.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub reason: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// The room that the user joined.
 | ||||
|             pub room_id: OwnedRoomId, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The room that the user joined.
 | ||||
|         pub room_id: OwnedRoomId, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -7,34 +7,36 @@ pub mod v3 { | ||||
| 
 | ||||
|     use std::collections::BTreeMap; | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, OwnedMxcUri, OwnedUserId, RoomId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, OwnedMxcUri, OwnedUserId, RoomId, | ||||
|     }; | ||||
|     use serde::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get a map of user ids to member info objects for members of the room. Primarily for use in Application Services.", | ||||
|             method: GET, | ||||
|             name: "joined_members", | ||||
|             r0_path: "/_matrix/client/r0/rooms/:room_id/joined_members", | ||||
|             stable_path: "/_matrix/client/v3/rooms/:room_id/joined_members", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get a map of user ids to member info objects for members of the room. Primarily for use in Application Services.", | ||||
|         method: GET, | ||||
|         name: "joined_members", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/joined_members", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/joined_members", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The room to get the members of.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|         } | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room to get the members of.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// 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: BTreeMap<OwnedUserId, RoomMember>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// 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: BTreeMap<OwnedUserId, RoomMember>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,30 +5,32 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3joined_rooms
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, OwnedRoomId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, OwnedRoomId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get a list of the user's current rooms.", | ||||
|             method: GET, | ||||
|             name: "joined_rooms", | ||||
|             r0_path: "/_matrix/client/r0/joined_rooms", | ||||
|             stable_path: "/_matrix/client/v3/joined_rooms", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get a list of the user's current rooms.", | ||||
|         method: GET, | ||||
|         name: "joined_rooms", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/joined_rooms", | ||||
|             1.1 => "/_matrix/client/v3/joined_rooms", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         request: {} | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct 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.
 | ||||
|             pub joined_rooms: Vec<OwnedRoomId>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// 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<OwnedRoomId>, | ||||
|     } | ||||
| 
 | ||||
|     impl Request { | ||||
|  | ||||
| @ -5,39 +5,41 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3roomsroomidkick
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, RoomId, UserId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, RoomId, UserId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Kick a user from a room.", | ||||
|             method: POST, | ||||
|             name: "kick_user", | ||||
|             r0_path: "/_matrix/client/r0/rooms/:room_id/kick", | ||||
|             stable_path: "/_matrix/client/v3/rooms/:room_id/kick", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Kick a user from a room.", | ||||
|         method: POST, | ||||
|         name: "kick_user", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/kick", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/kick", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The room to kick the user from.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room to kick the user from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| 
 | ||||
|             /// The user to kick.
 | ||||
|             pub user_id: &'a UserId, | ||||
|         /// The user to kick.
 | ||||
|         pub user_id: &'a UserId, | ||||
| 
 | ||||
|             /// The reason for kicking the user.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub reason: Option<&'a str>, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The reason for kicking the user.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub reason: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room id and room id.
 | ||||
|         pub fn new(room_id: &'a RoomId, user_id: &'a UserId) -> Self { | ||||
|  | ||||
| @ -5,36 +5,38 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3roomsroomidleave
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, RoomId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, RoomId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Leave a room.", | ||||
|             method: POST, | ||||
|             name: "leave_room", | ||||
|             r0_path: "/_matrix/client/r0/rooms/:room_id/leave", | ||||
|             stable_path: "/_matrix/client/v3/rooms/:room_id/leave", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Leave a room.", | ||||
|         method: POST, | ||||
|         name: "leave_room", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/leave", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/leave", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The room to leave.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room to leave.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| 
 | ||||
|             /// Optional reason to be included as the `reason` on the subsequent membership event.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub reason: Option<&'a str>, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// Optional reason to be included as the `reason` on the subsequent membership event.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub reason: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room id.
 | ||||
|         pub fn new(room_id: &'a RoomId) -> Self { | ||||
|  | ||||
| @ -5,30 +5,33 @@ pub mod unstable { | ||||
|     //!
 | ||||
|     //! [spec]: https://github.com/matrix-org/matrix-spec-proposals/blob/hs/shared-rooms/proposals/2666-get-rooms-in-common.md
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, OwnedRoomId, UserId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, OwnedRoomId, UserId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get mutual rooms with another user.", | ||||
|             method: GET, | ||||
|             name: "mutual_rooms", | ||||
|             unstable_path: "/_matrix/client/unstable/uk.half-shot.msc2666/user/mutual_rooms/:user_id", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get mutual rooms with another user.", | ||||
|         method: GET, | ||||
|         name: "mutual_rooms", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/uk.half-shot.msc2666/user/mutual_rooms/:user_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The user to search mutual rooms for.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: &'a UserId, | ||||
|         } | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The user to search mutual rooms for.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// A list of rooms the user is in together with the authenticated user.
 | ||||
|             pub joined: Vec<OwnedRoomId>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A list of rooms the user is in together with the authenticated user.
 | ||||
|         pub joined: Vec<OwnedRoomId>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,39 +5,41 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#post_matrixclientv3roomsroomidunban
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, RoomId, UserId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, RoomId, UserId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Unban a user from a room.", | ||||
|             method: POST, | ||||
|             name: "unban_user", | ||||
|             r0_path: "/_matrix/client/r0/rooms/:room_id/unban", | ||||
|             stable_path: "/_matrix/client/v3/rooms/:room_id/unban", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Unban a user from a room.", | ||||
|         method: POST, | ||||
|         name: "unban_user", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/unban", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/unban", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The room to unban the user from.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room to unban the user from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| 
 | ||||
|             /// The user to unban.
 | ||||
|             pub user_id: &'a UserId, | ||||
|         /// The user to unban.
 | ||||
|         pub user_id: &'a UserId, | ||||
| 
 | ||||
|             /// Optional reason for unbanning the user.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub reason: Option<&'a str>, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// Optional reason for unbanning the user.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub reason: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room id and room id.
 | ||||
|         pub fn new(room_id: &'a RoomId, user_id: &'a UserId) -> Self { | ||||
|  | ||||
| @ -7,8 +7,9 @@ pub mod v3 { | ||||
| 
 | ||||
|     use js_int::{uint, UInt}; | ||||
|     use ruma_common::{ | ||||
|         api::ruma_api, | ||||
|         api::{request, response, Metadata}, | ||||
|         events::{AnyStateEvent, AnyTimelineEvent}, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|         RoomId, | ||||
|     }; | ||||
| @ -18,83 +19,82 @@ pub mod v3 { | ||||
|         Direction, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get message events for a room.", | ||||
|             method: GET, | ||||
|             name: "get_message_events", | ||||
|             r0_path: "/_matrix/client/r0/rooms/:room_id/messages", | ||||
|             stable_path: "/_matrix/client/v3/rooms/:room_id/messages", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get message events for a room.", | ||||
|         method: GET, | ||||
|         name: "get_message_events", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/messages", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/messages", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The room to get events from.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room to get events from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| 
 | ||||
|             /// The token to start returning events from.
 | ||||
|             ///
 | ||||
|             /// This token can be obtained from a `prev_batch` token returned for each room by the
 | ||||
|             /// sync endpoint, or from a `start` or `end` token returned by a previous request to
 | ||||
|             /// this endpoint.
 | ||||
|             ///
 | ||||
|             /// If this is `None`, the server will return messages from the start or end of the
 | ||||
|             /// history visible to the user, depending on the value of [`dir`][Self::dir].
 | ||||
|             #[ruma_api(query)] | ||||
|             pub from: Option<&'a str>, | ||||
|         /// The token to start returning events from.
 | ||||
|         ///
 | ||||
|         /// This token can be obtained from a `prev_batch` token returned for each room by the
 | ||||
|         /// sync endpoint, or from a `start` or `end` token returned by a previous request to
 | ||||
|         /// this endpoint.
 | ||||
|         ///
 | ||||
|         /// If this is `None`, the server will return messages from the start or end of the
 | ||||
|         /// history visible to the user, depending on the value of [`dir`][Self::dir].
 | ||||
|         #[ruma_api(query)] | ||||
|         pub from: Option<&'a str>, | ||||
| 
 | ||||
|             /// The token to stop returning events at.
 | ||||
|             ///
 | ||||
|             /// This token can be obtained from a `prev_batch` token returned for each room by the
 | ||||
|             /// sync endpoint, or from a `start` or `end` token returned by a previous request to
 | ||||
|             /// this endpoint.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[ruma_api(query)] | ||||
|             pub to: Option<&'a str>, | ||||
|         /// The token to stop returning events at.
 | ||||
|         ///
 | ||||
|         /// This token can be obtained from a `prev_batch` token returned for each room by the
 | ||||
|         /// sync endpoint, or from a `start` or `end` token returned by a previous request to
 | ||||
|         /// this endpoint.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[ruma_api(query)] | ||||
|         pub to: Option<&'a str>, | ||||
| 
 | ||||
|             /// The direction to return events from.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub dir: Direction, | ||||
|         /// The direction to return events from.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub dir: Direction, | ||||
| 
 | ||||
|             /// The maximum number of events to return.
 | ||||
|             ///
 | ||||
|             /// Default: `10`.
 | ||||
|             #[ruma_api(query)] | ||||
|             #[serde(default = "default_limit", skip_serializing_if = "is_default_limit")] | ||||
|             pub limit: UInt, | ||||
|         /// The maximum number of events to return.
 | ||||
|         ///
 | ||||
|         /// Default: `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(
 | ||||
|                 with = "ruma_common::serde::json_string", | ||||
|                 default, | ||||
|                 skip_serializing_if = "RoomEventFilter::is_empty" | ||||
|             )] | ||||
|             pub filter: RoomEventFilter<'a>, | ||||
|         } | ||||
|         /// A [`RoomEventFilter`] to filter returned events with.
 | ||||
|         #[ruma_api(query)] | ||||
|         #[serde(
 | ||||
|             with = "ruma_common::serde::json_string", | ||||
|             default, | ||||
|             skip_serializing_if = "RoomEventFilter::is_empty" | ||||
|         )] | ||||
|         pub filter: RoomEventFilter<'a>, | ||||
|     } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: { | ||||
|             /// The token the pagination starts from.
 | ||||
|             pub start: String, | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response { | ||||
|         /// The token the pagination starts from.
 | ||||
|         pub start: String, | ||||
| 
 | ||||
|             /// The token the pagination ends at.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub end: Option<String>, | ||||
|         /// The token the pagination ends at.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub end: Option<String>, | ||||
| 
 | ||||
|             /// A list of room events.
 | ||||
|             #[serde(default)] | ||||
|             pub chunk: Vec<Raw<AnyTimelineEvent>>, | ||||
|         /// A list of room events.
 | ||||
|         #[serde(default)] | ||||
|         pub chunk: Vec<Raw<AnyTimelineEvent>>, | ||||
| 
 | ||||
|             /// A list of state events relevant to showing the `chunk`.
 | ||||
|             #[serde(default, skip_serializing_if = "Vec::is_empty")] | ||||
|             pub state: Vec<Raw<AnyStateEvent>>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// A list of state events relevant to showing the `chunk`.
 | ||||
|         #[serde(default, skip_serializing_if = "Vec::is_empty")] | ||||
|         pub state: Vec<Raw<AnyStateEvent>>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -6,68 +6,68 @@ pub mod v3 { | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#put_matrixclientv3roomsroomidsendeventtypetxnid
 | ||||
| 
 | ||||
|     use ruma_common::{ | ||||
|         api::ruma_api, | ||||
|         api::{request, response, Metadata}, | ||||
|         events::{AnyMessageLikeEventContent, MessageLikeEventContent, MessageLikeEventType}, | ||||
|         metadata, | ||||
|         serde::Raw, | ||||
|         MilliSecondsSinceUnixEpoch, OwnedEventId, RoomId, TransactionId, | ||||
|     }; | ||||
|     use serde_json::value::to_raw_value as to_raw_json_value; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Send a message event to a room.", | ||||
|             method: PUT, | ||||
|             name: "create_message_event", | ||||
|             r0_path: "/_matrix/client/r0/rooms/:room_id/send/:event_type/:txn_id", | ||||
|             stable_path: "/_matrix/client/v3/rooms/:room_id/send/:event_type/:txn_id", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Send a message event to a room.", | ||||
|         method: PUT, | ||||
|         name: "create_message_event", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/send/:event_type/:txn_id", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/send/:event_type/:txn_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The room to send the event to.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: &'a RoomId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room to send the event to.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| 
 | ||||
|             /// The type of event to send.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub event_type: MessageLikeEventType, | ||||
|         /// The type of event to send.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub event_type: MessageLikeEventType, | ||||
| 
 | ||||
|             /// The transaction ID for this event.
 | ||||
|             ///
 | ||||
|             /// Clients should generate a unique ID across requests within the
 | ||||
|             /// same session. A session is identified by an access token, and
 | ||||
|             /// persists when the [access token is refreshed].
 | ||||
|             ///
 | ||||
|             /// It will be used by the server to ensure idempotency of requests.
 | ||||
|             ///
 | ||||
|             /// [access token is refreshed]: https://spec.matrix.org/v1.4/client-server-api/#refreshing-access-tokens
 | ||||
|             #[ruma_api(path)] | ||||
|             pub txn_id: &'a TransactionId, | ||||
|         /// The transaction ID for this event.
 | ||||
|         ///
 | ||||
|         /// Clients should generate a unique ID across requests within the
 | ||||
|         /// same session. A session is identified by an access token, and
 | ||||
|         /// persists when the [access token is refreshed].
 | ||||
|         ///
 | ||||
|         /// It will be used by the server to ensure idempotency of requests.
 | ||||
|         ///
 | ||||
|         /// [access token is refreshed]: https://spec.matrix.org/v1.4/client-server-api/#refreshing-access-tokens
 | ||||
|         #[ruma_api(path)] | ||||
|         pub txn_id: &'a TransactionId, | ||||
| 
 | ||||
|             /// The event content to send.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub body: Raw<AnyMessageLikeEventContent>, | ||||
|         /// The event content to send.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub body: Raw<AnyMessageLikeEventContent>, | ||||
| 
 | ||||
|             /// Timestamp to use for the `origin_server_ts` of the event.
 | ||||
|             ///
 | ||||
|             /// This is called [timestamp massaging] and can only be used by Appservices.
 | ||||
|             ///
 | ||||
|             /// Note that this does not change the position of the event in the timeline.
 | ||||
|             ///
 | ||||
|             /// [timestamp massaging]: https://spec.matrix.org/v1.4/application-service-api/#timestamp-massaging
 | ||||
|             #[ruma_api(query)] | ||||
|             #[serde(skip_serializing_if = "Option::is_none", rename = "ts")] | ||||
|             pub timestamp: Option<MilliSecondsSinceUnixEpoch>, | ||||
|         } | ||||
|         /// Timestamp to use for the `origin_server_ts` of the event.
 | ||||
|         ///
 | ||||
|         /// This is called [timestamp massaging] and can only be used by Appservices.
 | ||||
|         ///
 | ||||
|         /// Note that this does not change the position of the event in the timeline.
 | ||||
|         ///
 | ||||
|         /// [timestamp massaging]: https://spec.matrix.org/v1.4/application-service-api/#timestamp-massaging
 | ||||
|         #[ruma_api(query)] | ||||
|         #[serde(skip_serializing_if = "Option::is_none", rename = "ts")] | ||||
|         pub timestamp: Option<MilliSecondsSinceUnixEpoch>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// A unique identifier for the event.
 | ||||
|             pub event_id: OwnedEventId, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A unique identifier for the event.
 | ||||
|         pub event_id: OwnedEventId, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -7,48 +7,52 @@ pub mod v3 { | ||||
| 
 | ||||
|     use std::time::Duration; | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, presence::PresenceState, UserId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         presence::PresenceState, | ||||
|         UserId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get presence status for this user.", | ||||
|             method: GET, | ||||
|             name: "get_presence", | ||||
|             r0_path: "/_matrix/client/r0/presence/:user_id/status", | ||||
|             stable_path: "/_matrix/client/v3/presence/:user_id/status", | ||||
|             rate_limited: false, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get presence status for this user.", | ||||
|         method: GET, | ||||
|         name: "get_presence", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/presence/:user_id/status", | ||||
|             1.1 => "/_matrix/client/v3/presence/:user_id/status", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The user whose presence state will be retrieved.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: &'a UserId, | ||||
|         } | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The user whose presence state will be retrieved.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|             /// The state message for this user if one was set.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub status_msg: Option<String>, | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The state message for this user if one was set.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub status_msg: Option<String>, | ||||
| 
 | ||||
|             /// Whether or not the user is currently active.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub currently_active: Option<bool>, | ||||
|         /// Whether or not the user is currently active.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub currently_active: Option<bool>, | ||||
| 
 | ||||
|             /// The length of time in milliseconds since an action was performed by the user.
 | ||||
|             #[serde(
 | ||||
|                 with = "ruma_common::serde::duration::opt_ms", | ||||
|                 default, | ||||
|                 skip_serializing_if = "Option::is_none", | ||||
|             )] | ||||
|             pub last_active_ago: Option<Duration>, | ||||
|         /// The length of time in milliseconds since an action was performed by the user.
 | ||||
|         #[serde(
 | ||||
|             with = "ruma_common::serde::duration::opt_ms", | ||||
|             default, | ||||
|             skip_serializing_if = "Option::is_none" | ||||
|         )] | ||||
|         pub last_active_ago: Option<Duration>, | ||||
| 
 | ||||
|             /// The user's presence state.
 | ||||
|             pub presence: PresenceState, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The user's presence state.
 | ||||
|         pub presence: PresenceState, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,39 +5,43 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#put_matrixclientv3presenceuseridstatus
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, presence::PresenceState, UserId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, | ||||
|         presence::PresenceState, | ||||
|         UserId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Set presence status for this user.", | ||||
|             method: PUT, | ||||
|             name: "set_presence", | ||||
|             r0_path: "/_matrix/client/r0/presence/:user_id/status", | ||||
|             stable_path: "/_matrix/client/v3/presence/:user_id/status", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Set presence status for this user.", | ||||
|         method: PUT, | ||||
|         name: "set_presence", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/presence/:user_id/status", | ||||
|             1.1 => "/_matrix/client/v3/presence/:user_id/status", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The user whose presence state will be updated.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: &'a UserId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The user whose presence state will be updated.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
| 
 | ||||
|             /// The new presence state.
 | ||||
|             pub presence: PresenceState, | ||||
|         /// 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<&'a str>, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The status message to attach to this state.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub status_msg: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given user ID and presence state.
 | ||||
|         pub fn new(user_id: &'a UserId, presence: PresenceState) -> Self { | ||||
|  | ||||
| @ -5,49 +5,51 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3profileuseridavatar_url
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, OwnedMxcUri, UserId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, OwnedMxcUri, UserId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get the avatar URL of a user.", | ||||
|             method: GET, | ||||
|             name: "get_avatar_url", | ||||
|             r0_path: "/_matrix/client/r0/profile/:user_id/avatar_url", | ||||
|             stable_path: "/_matrix/client/v3/profile/:user_id/avatar_url", | ||||
|             rate_limited: false, | ||||
|             authentication: None, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get the avatar URL of a user.", | ||||
|         method: GET, | ||||
|         name: "get_avatar_url", | ||||
|         rate_limited: false, | ||||
|         authentication: None, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/profile/:user_id/avatar_url", | ||||
|             1.1 => "/_matrix/client/v3/profile/:user_id/avatar_url", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The user whose avatar URL will be retrieved.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: &'a UserId, | ||||
|         } | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The user whose avatar URL will be retrieved.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
|     } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: { | ||||
|             /// The user's avatar URL, if set.
 | ||||
|             ///
 | ||||
|             /// If you activate the `compat` feature, this field being an empty string in JSON will result
 | ||||
|             /// in `None` here during deserialization.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[cfg_attr(
 | ||||
|                 feature = "compat", | ||||
|                 serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") | ||||
|             )] | ||||
|             pub avatar_url: Option<OwnedMxcUri>, | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response { | ||||
|         /// The user's avatar URL, if set.
 | ||||
|         ///
 | ||||
|         /// If you activate the `compat` feature, this field being an empty string in JSON will
 | ||||
|         /// result in `None` here during deserialization.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[cfg_attr(
 | ||||
|             feature = "compat", | ||||
|             serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") | ||||
|         )] | ||||
|         pub avatar_url: Option<OwnedMxcUri>, | ||||
| 
 | ||||
|             /// The [BlurHash](https://blurha.sh) for the avatar pointed to by `avatar_url`.
 | ||||
|             ///
 | ||||
|             /// This uses the unstable prefix in
 | ||||
|             /// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448).
 | ||||
|             #[cfg(feature = "unstable-msc2448")] | ||||
|             #[serde(rename = "xyz.amorgan.blurhash", skip_serializing_if = "Option::is_none")] | ||||
|             pub blurhash: Option<String>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The [BlurHash](https://blurha.sh) for the avatar pointed to by `avatar_url`.
 | ||||
|         ///
 | ||||
|         /// This uses the unstable prefix in
 | ||||
|         /// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448).
 | ||||
|         #[cfg(feature = "unstable-msc2448")] | ||||
|         #[serde(rename = "xyz.amorgan.blurhash", skip_serializing_if = "Option::is_none")] | ||||
|         pub blurhash: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,34 +5,36 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3profileuseriddisplayname
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, UserId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, UserId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get the display name of a user.", | ||||
|             method: GET, | ||||
|             name: "get_display_name", | ||||
|             r0_path: "/_matrix/client/r0/profile/:user_id/displayname", | ||||
|             stable_path: "/_matrix/client/v3/profile/:user_id/displayname", | ||||
|             rate_limited: false, | ||||
|             authentication: None, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get the display name of a user.", | ||||
|         method: GET, | ||||
|         name: "get_display_name", | ||||
|         rate_limited: false, | ||||
|         authentication: None, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/profile/:user_id/displayname", | ||||
|             1.1 => "/_matrix/client/v3/profile/:user_id/displayname", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The user whose display name will be retrieved.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: &'a UserId, | ||||
|         } | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The user whose display name will be retrieved.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
|     } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: { | ||||
|             /// The user's display name, if set.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub displayname: Option<String>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response { | ||||
|         /// The user's display name, if set.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub displayname: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,53 +5,55 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#get_matrixclientv3profileuserid
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, OwnedMxcUri, UserId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, OwnedMxcUri, UserId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Get all profile information of an user.", | ||||
|             method: GET, | ||||
|             name: "get_profile", | ||||
|             r0_path: "/_matrix/client/r0/profile/:user_id", | ||||
|             stable_path: "/_matrix/client/v3/profile/:user_id", | ||||
|             rate_limited: false, | ||||
|             authentication: None, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Get all profile information of an user.", | ||||
|         method: GET, | ||||
|         name: "get_profile", | ||||
|         rate_limited: false, | ||||
|         authentication: None, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/profile/:user_id", | ||||
|             1.1 => "/_matrix/client/v3/profile/:user_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The user whose profile will be retrieved.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: &'a UserId, | ||||
|         } | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The user whose profile will be retrieved.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
|     } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: { | ||||
|             /// The user's avatar URL, if set.
 | ||||
|             ///
 | ||||
|             /// If you activate the `compat` feature, this field being an empty string in JSON will result
 | ||||
|             /// in `None` here during deserialization.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[cfg_attr(
 | ||||
|                 feature = "compat", | ||||
|                 serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") | ||||
|             )] | ||||
|             pub avatar_url: Option<OwnedMxcUri>, | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response { | ||||
|         /// The user's avatar URL, if set.
 | ||||
|         ///
 | ||||
|         /// If you activate the `compat` feature, this field being an empty string in JSON will
 | ||||
|         /// result in `None` here during deserialization.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[cfg_attr(
 | ||||
|             feature = "compat", | ||||
|             serde(default, deserialize_with = "ruma_common::serde::empty_string_as_none") | ||||
|         )] | ||||
|         pub avatar_url: Option<OwnedMxcUri>, | ||||
| 
 | ||||
|             /// The user's display name, if set.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub displayname: Option<String>, | ||||
|         /// The user's display name, if set.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub displayname: Option<String>, | ||||
| 
 | ||||
|             /// The [BlurHash](https://blurha.sh) for the avatar pointed to by `avatar_url`.
 | ||||
|             ///
 | ||||
|             /// This uses the unstable prefix in
 | ||||
|             /// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448).
 | ||||
|             #[cfg(feature = "unstable-msc2448")] | ||||
|             #[serde(rename = "xyz.amorgan.blurhash", skip_serializing_if = "Option::is_none")] | ||||
|             pub blurhash: Option<String>, | ||||
|         } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The [BlurHash](https://blurha.sh) for the avatar pointed to by `avatar_url`.
 | ||||
|         ///
 | ||||
|         /// This uses the unstable prefix in
 | ||||
|         /// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448).
 | ||||
|         #[cfg(feature = "unstable-msc2448")] | ||||
|         #[serde(rename = "xyz.amorgan.blurhash", skip_serializing_if = "Option::is_none")] | ||||
|         pub blurhash: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|  | ||||
| @ -5,60 +5,59 @@ pub mod v3 { | ||||
|     //!
 | ||||
|     //! [spec]: https://spec.matrix.org/v1.4/client-server-api/#put_matrixclientv3profileuseridavatar_url
 | ||||
| 
 | ||||
|     use ruma_common::{api::ruma_api, MxcUri, UserId}; | ||||
|     use ruma_common::{ | ||||
|         api::{request, response, Metadata}, | ||||
|         metadata, MxcUri, UserId, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|             description: "Set the avatar URL of the user.", | ||||
|             method: PUT, | ||||
|             name: "set_avatar_url", | ||||
|             r0_path: "/_matrix/client/r0/profile/:user_id/avatar_url", | ||||
|             stable_path: "/_matrix/client/v3/profile/:user_id/avatar_url", | ||||
|             rate_limited: true, | ||||
|             authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|     const METADATA: Metadata = metadata! { | ||||
|         description: "Set the avatar URL of the user.", | ||||
|         method: PUT, | ||||
|         name: "set_avatar_url", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/profile/:user_id/avatar_url", | ||||
|             1.1 => "/_matrix/client/v3/profile/:user_id/avatar_url", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|             /// The user whose avatar URL will be set.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: &'a UserId, | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The user whose avatar URL will be set.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
| 
 | ||||
|             /// The new avatar URL for the user.
 | ||||
|             ///
 | ||||
|             /// `None` is used to unset the avatar.
 | ||||
|             ///
 | ||||
|             /// If you activate the `compat` feature, this field being an empty string in JSON will result
 | ||||
|             /// in `None` here during deserialization.
 | ||||
|             #[cfg_attr(
 | ||||
|                 feature = "compat", | ||||
|                 serde( | ||||
|                     default, | ||||
|                     deserialize_with = "ruma_common::serde::empty_string_as_none", | ||||
|                     serialize_with = "ruma_common::serde::none_as_empty_string" | ||||
|                 ) | ||||
|             )] | ||||
|             #[cfg_attr(
 | ||||
|                 not(feature = "compat"), | ||||
|                 serde(skip_serializing_if = "Option::is_none") | ||||
|             )] | ||||
|             pub avatar_url: Option<&'a MxcUri>, | ||||
|         /// The new avatar URL for the user.
 | ||||
|         ///
 | ||||
|         /// `None` is used to unset the avatar.
 | ||||
|         ///
 | ||||
|         /// If you activate the `compat` feature, this field being an empty string in JSON will
 | ||||
|         /// result in `None` here during deserialization.
 | ||||
|         #[cfg_attr(
 | ||||
|             feature = "compat", | ||||
|             serde( | ||||
|                 default, | ||||
|                 deserialize_with = "ruma_common::serde::empty_string_as_none", | ||||
|                 serialize_with = "ruma_common::serde::none_as_empty_string" | ||||
|             ) | ||||
|         )] | ||||
|         #[cfg_attr(not(feature = "compat"), serde(skip_serializing_if = "Option::is_none"))] | ||||
|         pub avatar_url: Option<&'a MxcUri>, | ||||
| 
 | ||||
|             /// The [BlurHash](https://blurha.sh) for the avatar pointed to by `avatar_url`.
 | ||||
|             ///
 | ||||
|             /// This uses the unstable prefix in
 | ||||
|             /// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448).
 | ||||
|             #[cfg(feature = "unstable-msc2448")] | ||||
|             #[serde(rename = "xyz.amorgan.blurhash", skip_serializing_if = "Option::is_none")] | ||||
|             pub blurhash: Option<&'a str>, | ||||
|         } | ||||
| 
 | ||||
|         #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|         /// The [BlurHash](https://blurha.sh) for the avatar pointed to by `avatar_url`.
 | ||||
|         ///
 | ||||
|         /// This uses the unstable prefix in
 | ||||
|         /// [MSC2448](https://github.com/matrix-org/matrix-spec-proposals/pull/2448).
 | ||||
|         #[cfg(feature = "unstable-msc2448")] | ||||
|         #[serde(rename = "xyz.amorgan.blurhash", skip_serializing_if = "Option::is_none")] | ||||
|         pub blurhash: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given user ID and avatar URL.
 | ||||
|         pub fn new(user_id: &'a UserId, avatar_url: Option<&'a MxcUri>) -> Self { | ||||
|  | ||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user