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,18 +37,19 @@ pub mod v1 { | ||||
|     #[cfg(feature = "unstable-msc2409")] | ||||
|     use serde_json::{value::RawValue as RawJsonValue, Value as JsonValue}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|     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", | ||||
|             stable_path: "/_matrix/app/v1/transactions/:txn_id", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/app/v1/transactions/:txn_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[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.
 | ||||
| @ -63,23 +68,27 @@ pub mod v1 { | ||||
|         )] | ||||
|         pub device_lists: DeviceLists, | ||||
| 
 | ||||
|             /// The number of unclaimed one-time keys currently held on the server for this device, for each algorithm.
 | ||||
|         /// 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>>>, | ||||
|         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.
 | ||||
|         /// 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>>>, | ||||
|         pub device_unused_fallback_key_types: | ||||
|             BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, Vec<DeviceKeyAlgorithm>>>, | ||||
| 
 | ||||
|         /// A list of EDUs.
 | ||||
|         #[cfg(feature = "unstable-msc2409")] | ||||
| @ -97,12 +106,12 @@ pub mod v1 { | ||||
|             skip_serializing_if = "<[_]>::is_empty", | ||||
|             rename = "de.sorunome.msc2409.to_device" | ||||
|         )] | ||||
|             pub to_device: &'a [Raw<AnyToDeviceEvent>] | ||||
|         pub to_device: &'a [Raw<AnyToDeviceEvent>], | ||||
|     } | ||||
| 
 | ||||
|     #[response] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given transaction ID and list of events.
 | ||||
|  | ||||
| @ -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,28 +7,32 @@ 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: { | ||||
|     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", | ||||
|             stable_path: "/_matrix/app/v1/rooms/:room_alias", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/app/v1/rooms/:room_alias", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room alias being queried.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_alias: &'a RoomAliasId, | ||||
|     } | ||||
| 
 | ||||
|     #[response] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room alias.
 | ||||
|  | ||||
| @ -7,28 +7,32 @@ 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: { | ||||
|     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", | ||||
|             stable_path: "/_matrix/app/v1/users/:user_id", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/app/v1/users/:user_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request] | ||||
|     pub struct Request<'a> { | ||||
|         /// The user ID being queried.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
|     } | ||||
| 
 | ||||
|     #[response] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given user id.
 | ||||
|  | ||||
| @ -10,20 +10,25 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/app/v1/thirdparty/location/:protocol", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request] | ||||
|     pub struct Request<'a> { | ||||
|         /// The protocol used to communicate to the third party network.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub protocol: &'a str, | ||||
| @ -34,12 +39,12 @@ pub mod v1 { | ||||
|         pub fields: BTreeMap<String, String>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response] | ||||
|     pub struct Response { | ||||
|         /// List of matched third party locations.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub locations: Vec<Location>, | ||||
|     } | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given protocol.
 | ||||
|  | ||||
| @ -7,31 +7,37 @@ 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: { | ||||
|     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", | ||||
|             stable_path: "/_matrix/app/v1/thirdparty/location", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/app/v1/thirdparty/location", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request] | ||||
|     pub struct Request<'a> { | ||||
|         /// The Matrix room alias to look up.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub alias: &'a RoomAliasId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response] | ||||
|     pub struct Response { | ||||
|         /// List of matched third party locations.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub locations: Vec<Location>, | ||||
|     } | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room alias id.
 | ||||
|  | ||||
| @ -8,31 +8,36 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/app/v1/thirdparty/protocol/:protocol", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request] | ||||
|     pub struct Request<'a> { | ||||
|         /// The name of the protocol.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub protocol: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response] | ||||
|     pub struct Response { | ||||
|         /// Metadata about the protocol.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub protocol: Protocol, | ||||
|     } | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given protocol name.
 | ||||
|  | ||||
| @ -10,20 +10,25 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/app/v1/thirdparty/user/:protocol", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request] | ||||
|     pub struct Request<'a> { | ||||
|         /// The protocol used to communicate to the third party network.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub protocol: &'a str, | ||||
| @ -34,12 +39,12 @@ pub mod v1 { | ||||
|         pub fields: BTreeMap<String, String>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response] | ||||
|     pub struct Response { | ||||
|         /// List of matched third party users.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub users: Vec<User>, | ||||
|     } | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given protocol name.
 | ||||
|  | ||||
| @ -7,31 +7,37 @@ 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: { | ||||
|     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", | ||||
|             stable_path: "/_matrix/app/v1/thirdparty/user", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/app/v1/thirdparty/user", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request] | ||||
|     pub struct Request<'a> { | ||||
|         /// The Matrix User ID to look up.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub userid: &'a UserId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response] | ||||
|     pub struct Response { | ||||
|         /// List of matched third party users.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub users: Vec<User>, | ||||
|     } | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given user id.
 | ||||
|  | ||||
| @ -5,23 +5,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/3pid/add", | ||||
|             1.1 => "/_matrix/client/v3/account/3pid/add", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[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>>, | ||||
| @ -33,11 +37,9 @@ pub mod v3 { | ||||
|         pub sid: &'a SessionId, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = UiaaResponse)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: UiaaResponse | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given client secret and session identifier.
 | ||||
|  | ||||
| @ -5,23 +5,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/3pid/bind", | ||||
|             1.1 => "/_matrix/client/v3/account/3pid/bind", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Client-generated secret string used to protect this session.
 | ||||
|         pub client_secret: &'a ClientSecret, | ||||
| 
 | ||||
| @ -34,11 +38,9 @@ pub mod v3 { | ||||
|         pub sid: &'a SessionId, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given client secret, identity server information and
 | ||||
|  | ||||
| @ -5,23 +5,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/password", | ||||
|             1.1 => "/_matrix/client/v3/account/password", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = UiaaResponse)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The new password for the account.
 | ||||
|         pub new_password: &'a str, | ||||
| 
 | ||||
| @ -30,9 +34,12 @@ pub mod v3 { | ||||
|         ///
 | ||||
|         /// 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")] | ||||
|         /// 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.
 | ||||
| @ -40,11 +47,9 @@ pub mod v3 { | ||||
|         pub auth: Option<AuthData<'a>>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = UiaaResponse)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: UiaaResponse | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given password.
 | ||||
|  | ||||
| @ -5,34 +5,36 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         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: { | ||||
|     #[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: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A flag to indicate that the registration token is valid.
 | ||||
|         pub valid: bool, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given registration token.
 | ||||
|         pub fn new(registration_token: &'a str) -> Self { | ||||
|  | ||||
| @ -5,27 +5,31 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/deactivate", | ||||
|             1.1 => "/_matrix/client/v3/account/deactivate", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     #[request(error = UiaaResponse)] | ||||
|     #[derive(Default)] | ||||
|         request: { | ||||
|     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>>, | ||||
| @ -36,14 +40,12 @@ pub mod v3 { | ||||
|         pub id_server: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = UiaaResponse)] | ||||
|     pub struct Response { | ||||
|         /// Result of unbind operation.
 | ||||
|         pub id_server_unbind_result: ThirdPartyIdRemovalStatus, | ||||
|     } | ||||
| 
 | ||||
|         error: UiaaResponse | ||||
|     } | ||||
| 
 | ||||
|     impl Request<'_> { | ||||
|         /// Creates an empty `Request`.
 | ||||
|         pub fn new() -> Self { | ||||
|  | ||||
| @ -5,23 +5,28 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/3pid/delete", | ||||
|             1.1 => "/_matrix/client/v3/account/3pid/delete", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[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>, | ||||
| @ -33,14 +38,12 @@ pub mod v3 { | ||||
|         pub address: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// Result of unbind operation.
 | ||||
|         pub id_server_unbind_result: ThirdPartyIdRemovalStatus, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given medium and address.
 | ||||
|         pub fn new(medium: Medium, address: &'a str) -> Self { | ||||
|  | ||||
| @ -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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/3pid", | ||||
|             1.1 => "/_matrix/client/v3/account/3pid", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         request: {} | ||||
|     pub struct Request {} | ||||
| 
 | ||||
|         response: { | ||||
|             /// A list of third party identifiers the homeserver has associated with the user's account.
 | ||||
|     #[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>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     impl Request { | ||||
|         /// Creates an empty `Request`.
 | ||||
|         pub fn new() -> Self { | ||||
|  | ||||
| @ -5,35 +5,37 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/register/available", | ||||
|             1.1 => "/_matrix/client/v3/register/available", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The username to check the availability of.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub username: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[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, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given username.
 | ||||
|         pub fn new(username: &'a str) -> Self { | ||||
|  | ||||
| @ -9,25 +9,29 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/register", | ||||
|             1.1 => "/_matrix/client/v3/register", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     #[request(error = UiaaResponse)] | ||||
|     #[derive(Default)] | ||||
|         request: { | ||||
|     pub struct Request<'a> { | ||||
|         /// The desired password for the account.
 | ||||
|         ///
 | ||||
|         /// May be empty for accounts that should not be able to log in again
 | ||||
| @ -91,7 +95,8 @@ pub mod v3 { | ||||
|         pub refresh_token: bool, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = UiaaResponse)] | ||||
|     pub struct Response { | ||||
|         /// An access token for the account.
 | ||||
|         ///
 | ||||
|         /// This access token can then be used to authorize other requests.
 | ||||
| @ -135,14 +140,11 @@ pub mod v3 { | ||||
|             with = "ruma_common::serde::duration::opt_ms", | ||||
|             default, | ||||
|             skip_serializing_if = "Option::is_none", | ||||
|                 rename = "expires_in_ms", | ||||
|             rename = "expires_in_ms" | ||||
|         )] | ||||
|         pub expires_in: Option<Duration>, | ||||
|     } | ||||
| 
 | ||||
|         error: UiaaResponse | ||||
|     } | ||||
| 
 | ||||
|     impl Request<'_> { | ||||
|         /// Creates a new `Request` with all parameters defaulted.
 | ||||
|         pub fn new() -> Self { | ||||
|  | ||||
| @ -6,23 +6,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/3pid/email/requestToken", | ||||
|             1.1 => "/_matrix/client/v3/account/3pid/email/requestToken", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Client-generated secret string used to protect this session.
 | ||||
|         pub client_secret: &'a ClientSecret, | ||||
| 
 | ||||
| @ -43,7 +47,8 @@ pub mod v3 { | ||||
|         pub identity_server_info: Option<IdentityServerInfo<'a>>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The session identifier given by the identity server.
 | ||||
|         pub sid: OwnedSessionId, | ||||
| 
 | ||||
| @ -61,9 +66,6 @@ pub mod v3 { | ||||
|         pub submit_url: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the client secret, email and send-attempt counter.
 | ||||
|         pub fn new(client_secret: &'a ClientSecret, email: &'a str, send_attempt: UInt) -> Self { | ||||
|  | ||||
| @ -6,23 +6,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/3pid/msisdn/requestToken", | ||||
|             1.1 => "/_matrix/client/v3/account/3pid/msisdn/requestToken", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Client-generated secret string used to protect this session.
 | ||||
|         pub client_secret: &'a ClientSecret, | ||||
| 
 | ||||
| @ -46,7 +50,8 @@ pub mod v3 { | ||||
|         pub identity_server_info: Option<IdentityServerInfo<'a>>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The session identifier given by the identity server.
 | ||||
|         pub sid: OwnedSessionId, | ||||
| 
 | ||||
| @ -64,8 +69,6 @@ pub mod v3 { | ||||
|         pub submit_url: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given client secret, country code, phone number and
 | ||||
|         /// send-attempt counter.
 | ||||
|  | ||||
| @ -7,27 +7,33 @@ 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: { | ||||
|     const METADATA: Metadata = 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", | ||||
|         name: "request_openid_token", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/user/:user_id/openid/request_token", | ||||
|             1.1 => "/_matrix/client/v3/user/:user_id/openid/request_token", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// User ID of authenticated user.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// Access token for verifying user's identity.
 | ||||
|         pub access_token: String, | ||||
| 
 | ||||
| @ -42,9 +48,6 @@ pub mod v3 { | ||||
|         pub expires_in: Duration, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given user ID.
 | ||||
|         pub fn new(user_id: &'a UserId) -> Self { | ||||
|  | ||||
| @ -6,23 +6,27 @@ 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: { | ||||
|     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", | ||||
|             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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/password/email/requestToken", | ||||
|             1.1 => "/_matrix/client/v3/account/password/email/requestToken", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Client-generated secret string used to protect this session.
 | ||||
|         pub client_secret: &'a ClientSecret, | ||||
| 
 | ||||
| @ -43,7 +47,8 @@ pub mod v3 { | ||||
|         pub identity_server_info: Option<IdentityServerInfo<'a>>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The session identifier given by the identity server.
 | ||||
|         pub sid: OwnedSessionId, | ||||
| 
 | ||||
| @ -51,8 +56,8 @@ pub mod v3 { | ||||
|         ///
 | ||||
|         /// 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.
 | ||||
|         /// 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", | ||||
| @ -61,9 +66,6 @@ pub mod v3 { | ||||
|         pub submit_url: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given client secret, email address and send-attempt
 | ||||
|         /// counter.
 | ||||
|  | ||||
| @ -6,21 +6,25 @@ 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: { | ||||
|     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", | ||||
|             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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/password/msisdn/requestToken", | ||||
|             1.1 => "/_matrix/client/v3/account/password/msisdn/requestToken", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Client-generated secret string used to protect this session.
 | ||||
|         pub client_secret: &'a ClientSecret, | ||||
| 
 | ||||
| @ -38,7 +42,8 @@ pub mod v3 { | ||||
|         pub next_link: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The session identifier given by the identity server.
 | ||||
|         pub sid: OwnedSessionId, | ||||
| 
 | ||||
| @ -46,8 +51,8 @@ pub mod v3 { | ||||
|         ///
 | ||||
|         /// 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.
 | ||||
|         /// 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", | ||||
| @ -56,9 +61,6 @@ pub mod v3 { | ||||
|         pub submit_url: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given client secret, country code, phone number and
 | ||||
|         /// send-attempt counter.
 | ||||
|  | ||||
| @ -6,23 +6,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/register/email/requestToken", | ||||
|             1.1 => "/_matrix/client/v3/register/email/requestToken", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Client-generated secret string used to protect this session.
 | ||||
|         pub client_secret: &'a ClientSecret, | ||||
| 
 | ||||
| @ -43,7 +47,8 @@ pub mod v3 { | ||||
|         pub identity_server_info: Option<IdentityServerInfo<'a>>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The session identifier given by the identity server.
 | ||||
|         pub sid: OwnedSessionId, | ||||
| 
 | ||||
| @ -51,8 +56,8 @@ pub mod v3 { | ||||
|         ///
 | ||||
|         /// 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.
 | ||||
|         /// 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", | ||||
| @ -61,9 +66,6 @@ pub mod v3 { | ||||
|         pub submit_url: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given client secret, email address and send-attempt
 | ||||
|         /// counter.
 | ||||
|  | ||||
| @ -6,23 +6,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/register/msisdn/requestToken", | ||||
|             1.1 => "/_matrix/client/v3/register/msisdn/requestToken", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// Client-generated secret string used to protect this session.
 | ||||
|         pub client_secret: &'a ClientSecret, | ||||
| 
 | ||||
| @ -46,7 +50,8 @@ pub mod v3 { | ||||
|         pub identity_server_info: Option<IdentityServerInfo<'a>>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The session identifier given by the identity server.
 | ||||
|         pub sid: OwnedSessionId, | ||||
| 
 | ||||
| @ -54,8 +59,8 @@ pub mod v3 { | ||||
|         ///
 | ||||
|         /// 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.
 | ||||
|         /// 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", | ||||
| @ -64,9 +69,6 @@ pub mod v3 { | ||||
|         pub submit_url: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given client secret, country code, phone number and
 | ||||
|         /// send-attempt counter.
 | ||||
|  | ||||
| @ -5,23 +5,28 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/3pid/unbind", | ||||
|             1.1 => "/_matrix/client/v3/account/3pid/unbind", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[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>, | ||||
| @ -33,14 +38,12 @@ pub mod v3 { | ||||
|         pub address: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// Result of unbind operation.
 | ||||
|         pub id_server_unbind_result: ThirdPartyIdRemovalStatus, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given medium and third-party address.
 | ||||
|         pub fn new(medium: Medium, address: &'a str) -> Self { | ||||
|  | ||||
| @ -5,24 +5,29 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/account/whoami", | ||||
|             1.1 => "/_matrix/client/v3/account/whoami", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         request: {} | ||||
|     pub struct Request {} | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The id of the user that owns the access token.
 | ||||
|         pub user_id: OwnedUserId, | ||||
| 
 | ||||
| @ -35,9 +40,6 @@ pub mod v3 { | ||||
|         pub is_guest: bool, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl Request { | ||||
|         /// Creates an empty `Request`.
 | ||||
|         pub fn new() -> Self { | ||||
|  | ||||
| @ -5,21 +5,25 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/directory/room/:room_alias", | ||||
|             1.1 => "/_matrix/client/v3/directory/room/:room_alias", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room alias to set.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_alias: &'a RoomAliasId, | ||||
| @ -28,11 +32,9 @@ pub mod v3 { | ||||
|         pub room_id: &'a RoomId, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room alias and room id.
 | ||||
|  | ||||
| @ -5,31 +5,33 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/directory/room/:room_alias", | ||||
|             1.1 => "/_matrix/client/v3/directory/room/:room_alias", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[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)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room alias.
 | ||||
|  | ||||
| @ -5,27 +5,32 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/directory/room/:room_alias", | ||||
|             1.1 => "/_matrix/client/v3/directory/room/:room_alias", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room alias.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_alias: &'a RoomAliasId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The room ID for this room alias.
 | ||||
|         pub room_id: OwnedRoomId, | ||||
| 
 | ||||
| @ -33,9 +38,6 @@ pub mod v3 { | ||||
|         pub servers: Vec<OwnedServerName>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room alias id.
 | ||||
|         pub fn new(room_alias: &'a RoomAliasId) -> Self { | ||||
|  | ||||
| @ -5,23 +5,27 @@ 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: { | ||||
|     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", | ||||
|             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, | ||||
|         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: { | ||||
|     #[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, | ||||
| @ -34,11 +38,9 @@ pub mod v3 { | ||||
|         pub visibility: Visibility, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given network ID, room ID and visibility.
 | ||||
|  | ||||
| @ -8,23 +8,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/room_keys/keys", | ||||
|             1.1 => "/_matrix/client/v3/room_keys/keys", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version to add keys to.
 | ||||
|         ///
 | ||||
|         /// Must be the current backup.
 | ||||
| @ -35,7 +39,8 @@ pub mod v3 { | ||||
|         pub rooms: BTreeMap<OwnedRoomId, RoomKeyBackup>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[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
 | ||||
| @ -46,9 +51,6 @@ pub mod v3 { | ||||
|         pub count: UInt, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given version and room key backups.
 | ||||
|         pub fn new(version: &'a str, rooms: BTreeMap<OwnedRoomId, RoomKeyBackup>) -> Self { | ||||
|  | ||||
| @ -8,24 +8,30 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         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: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version to add keys to.
 | ||||
|         ///
 | ||||
|         /// Must be the current backup.
 | ||||
| @ -40,7 +46,8 @@ pub mod v3 { | ||||
|         pub sessions: BTreeMap<String, Raw<KeyBackupData>>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[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
 | ||||
| @ -51,9 +58,6 @@ pub mod v3 { | ||||
|         pub count: UInt, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given version, room_id and sessions.
 | ||||
|         pub fn new( | ||||
|  | ||||
| @ -6,24 +6,30 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         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: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version to add keys to.
 | ||||
|         ///
 | ||||
|         /// Must be the current backup.
 | ||||
| @ -43,7 +49,8 @@ pub mod v3 { | ||||
|         pub session_data: Raw<KeyBackupData>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[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
 | ||||
| @ -54,9 +61,6 @@ pub mod v3 { | ||||
|         pub count: UInt, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given version, room_id, session_id and session_data.
 | ||||
|         pub fn new( | ||||
|  | ||||
| @ -5,36 +5,39 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/room_keys/version", | ||||
|             1.1 => "/_matrix/client/v3/room_keys/version", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request { | ||||
|         /// The algorithm used for storing backups.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub algorithm: Raw<BackupAlgorithm>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The backup version.
 | ||||
|         pub version: String, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl Request { | ||||
|         /// Creates a new `Request` with the given backup algorithm.
 | ||||
|         pub fn new(algorithm: Raw<BackupAlgorithm>) -> Self { | ||||
|  | ||||
| @ -8,28 +8,33 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         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: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version from which to delete keys.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub version: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[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
 | ||||
| @ -40,9 +45,6 @@ pub mod v3 { | ||||
|         pub count: UInt, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given version.
 | ||||
|         pub fn new(version: &'a str) -> Self { | ||||
|  | ||||
| @ -6,22 +6,26 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         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: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version from which to delete keys.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub version: &'a str, | ||||
| @ -31,7 +35,8 @@ pub mod v3 { | ||||
|         pub room_id: &'a RoomId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[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
 | ||||
| @ -42,9 +47,6 @@ pub mod v3 { | ||||
|         pub count: UInt, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given version and room_id.
 | ||||
| 
 | ||||
|  | ||||
| @ -6,22 +6,26 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         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: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version from which to delete keys.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub version: &'a str, | ||||
| @ -35,7 +39,8 @@ pub mod v3 { | ||||
|         pub session_id: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[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
 | ||||
| @ -46,9 +51,6 @@ pub mod v3 { | ||||
|         pub count: UInt, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given version, room_id and session_id.
 | ||||
|         pub fn new(version: &'a str, room_id: &'a RoomId, session_id: &'a str) -> Self { | ||||
|  | ||||
| @ -7,32 +7,34 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         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: { | ||||
|     #[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)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given version, room_id and sessions.
 | ||||
|  | ||||
| @ -8,32 +8,38 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/room_keys/version/:version", | ||||
|             1.1 => "/_matrix/client/v3/room_keys/version/:version", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version to retrieve info from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub version: &'a str, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[ruma_api(manual_body_serde)] | ||||
|         response: { | ||||
|     pub struct Response { | ||||
|         /// The algorithm used for storing backups.
 | ||||
|         pub algorithm: Raw<BackupAlgorithm>, | ||||
| 
 | ||||
| @ -50,9 +56,6 @@ pub mod v3 { | ||||
|         pub version: String, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given version.
 | ||||
|         pub fn new(version: &'a str) -> Self { | ||||
|  | ||||
| @ -9,37 +9,39 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         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: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version to retrieve keys from.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub version: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A map from room IDs to session IDs to key data.
 | ||||
|         pub rooms: BTreeMap<OwnedRoomId, RoomKeyBackup>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given version.
 | ||||
|         pub fn new(version: &'a str) -> Self { | ||||
|  | ||||
| @ -7,24 +7,30 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         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: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version to retrieve keys from.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub version: &'a str, | ||||
| @ -34,14 +40,12 @@ pub mod v3 { | ||||
|         pub room_id: &'a RoomId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A map of session IDs to key data.
 | ||||
|         pub sessions: BTreeMap<String, Raw<KeyBackupData>>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given version and room_id.
 | ||||
|         pub fn new(version: &'a str, room_id: &'a RoomId) -> Self { | ||||
|  | ||||
| @ -5,24 +5,30 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         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: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version to retrieve keys from.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub version: &'a str, | ||||
| @ -36,15 +42,13 @@ pub mod v3 { | ||||
|         pub session_id: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// Information about the requested backup key.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub key_data: Raw<KeyBackupData>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given version, room_id and session_id.
 | ||||
|         pub fn new(version: &'a str, room_id: &'a RoomId, session_id: &'a str) -> Self { | ||||
|  | ||||
| @ -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,24 +19,26 @@ pub mod v3 { | ||||
|         BackupAlgorithm, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/room_keys/version", | ||||
|             1.0 => "/_matrix/client/r0/room_keys/version", | ||||
|             1.1 => "/_matrix/client/v3/room_keys/version", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         request: {} | ||||
|     pub struct Request {} | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[ruma_api(manual_body_serde)] | ||||
|         response: { | ||||
|     pub struct Response { | ||||
|         /// The algorithm used for storing backups.
 | ||||
|         pub algorithm: Raw<BackupAlgorithm>, | ||||
| 
 | ||||
| @ -49,9 +55,6 @@ pub mod v3 { | ||||
|         pub version: String, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl Request { | ||||
|         /// Creates an empty `Request`.
 | ||||
|         pub fn new() -> Self { | ||||
|  | ||||
| @ -5,23 +5,28 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/room_keys/version/:version", | ||||
|             1.1 => "/_matrix/client/v3/room_keys/version/:version", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The backup version.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub version: &'a str, | ||||
| @ -31,11 +36,9 @@ pub mod v3 { | ||||
|         pub algorithm: Raw<BackupAlgorithm>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given backup version and algorithm.
 | ||||
|  | ||||
| @ -6,22 +6,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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", | ||||
|         name: "get_global_account_data", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|         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: { | ||||
|     #[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, | ||||
| @ -31,7 +36,8 @@ pub mod v3 { | ||||
|         pub event_type: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// Account data content for the given type.
 | ||||
|         ///
 | ||||
|         /// Use [`Raw::deserialize_content`] for deserialization.
 | ||||
| @ -39,9 +45,6 @@ pub mod v3 { | ||||
|         pub account_data: Raw<AnyGlobalAccountDataEventContent>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given user ID and event type.
 | ||||
|         pub fn new(user_id: &'a UserId, event_type: &'a str) -> Self { | ||||
|  | ||||
| @ -6,22 +6,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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", | ||||
|         name: "get_room_account_data", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|         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: { | ||||
|     #[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, | ||||
| @ -35,7 +40,8 @@ pub mod v3 { | ||||
|         pub event_type: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// Account data content for the given type.
 | ||||
|         ///
 | ||||
|         /// Use [`Raw::deserialize_content`] for deserialization.
 | ||||
| @ -43,9 +49,6 @@ pub mod v3 { | ||||
|         pub account_data: Raw<AnyRoomAccountDataEventContent>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given user ID, room ID and event type.
 | ||||
|         pub fn new(user_id: &'a UserId, room_id: &'a RoomId, event_type: &'a str) -> Self { | ||||
|  | ||||
| @ -6,29 +6,31 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         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: { | ||||
|     #[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.
 | ||||
| @ -48,11 +50,9 @@ pub mod v3 { | ||||
|         pub data: Raw<AnyGlobalAccountDataEventContent>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given data, event type and user ID.
 | ||||
|  | ||||
| @ -6,28 +6,30 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         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: { | ||||
|     #[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.
 | ||||
| @ -51,11 +53,9 @@ pub mod v3 { | ||||
|         pub data: Raw<AnyRoomAccountDataEventContent>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given data, event type, room ID and user ID.
 | ||||
|  | ||||
| @ -7,27 +7,29 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/context/:event_id", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/context/:event_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room to get events from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| @ -53,8 +55,9 @@ pub mod v3 { | ||||
|         pub filter: RoomEventFilter<'a>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: { | ||||
|     pub struct Response { | ||||
|         /// A token that can be used to paginate backwards with.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub start: Option<String>, | ||||
| @ -82,9 +85,6 @@ pub mod v3 { | ||||
|         pub state: Vec<Raw<AnyStateEvent>>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room id and event id.
 | ||||
|         pub fn new(room_id: &'a RoomId, event_id: &'a EventId) -> Self { | ||||
|  | ||||
| @ -5,23 +5,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/devices/:device_id", | ||||
|             1.1 => "/_matrix/client/v3/devices/:device_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = UiaaResponse)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The device to delete.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub device_id: &'a DeviceId, | ||||
| @ -31,11 +35,9 @@ pub mod v3 { | ||||
|         pub auth: Option<AuthData<'a>>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = UiaaResponse)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: UiaaResponse | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given device ID.
 | ||||
|  | ||||
| @ -5,23 +5,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/delete_devices", | ||||
|             1.1 => "/_matrix/client/v3/delete_devices", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = UiaaResponse)] | ||||
|     pub struct Request<'a> { | ||||
|         /// List of devices to delete.
 | ||||
|         pub devices: &'a [OwnedDeviceId], | ||||
| 
 | ||||
| @ -30,11 +34,9 @@ pub mod v3 { | ||||
|         pub auth: Option<AuthData<'a>>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = UiaaResponse)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: UiaaResponse | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given device list.
 | ||||
|  | ||||
| @ -5,37 +5,39 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/devices/:device_id", | ||||
|             1.1 => "/_matrix/client/v3/devices/:device_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The device to retrieve.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub device_id: &'a DeviceId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// Information about the device.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub device: Device, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given device ID.
 | ||||
|         pub fn new(device_id: &'a DeviceId) -> Self { | ||||
|  | ||||
| @ -5,33 +5,35 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/devices", | ||||
|             1.1 => "/_matrix/client/v3/devices", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         request: {} | ||||
|     pub struct Request {} | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A list of all registered devices for this user
 | ||||
|         pub devices: Vec<Device>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl Request { | ||||
|         /// Creates an empty `Request`.
 | ||||
|         pub fn new() -> Self { | ||||
|  | ||||
| @ -5,21 +5,25 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/devices/:device_id", | ||||
|             1.1 => "/_matrix/client/v3/devices/:device_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The device to update.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub device_id: &'a DeviceId, | ||||
| @ -31,11 +35,9 @@ pub mod v3 { | ||||
|         pub display_name: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given device ID.
 | ||||
|  | ||||
| @ -6,22 +6,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/publicRooms", | ||||
|             1.1 => "/_matrix/client/v3/publicRooms", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         request: { | ||||
|     pub struct Request<'a> { | ||||
|         /// Limit for the number of results to return.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[ruma_api(query)] | ||||
| @ -40,7 +45,8 @@ pub mod v3 { | ||||
|         pub server: Option<&'a ServerName>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A paginated chunk of public rooms.
 | ||||
|         pub chunk: Vec<PublicRoomsChunk>, | ||||
| 
 | ||||
| @ -57,9 +63,6 @@ pub mod v3 { | ||||
|         pub total_room_count_estimate: Option<UInt>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates an empty `Request`.
 | ||||
|         pub fn new() -> Self { | ||||
|  | ||||
| @ -7,25 +7,26 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/publicRooms", | ||||
|             1.1 => "/_matrix/client/v3/publicRooms", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         request: { | ||||
|     pub struct Request<'a> { | ||||
|         /// The server to fetch the public room lists from.
 | ||||
|         ///
 | ||||
|         /// `None` means the server this request is sent to.
 | ||||
| @ -50,8 +51,9 @@ pub mod v3 { | ||||
|         pub room_network: RoomNetwork<'a>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: { | ||||
|     pub struct Response { | ||||
|         /// A paginated chunk of public rooms.
 | ||||
|         pub chunk: Vec<PublicRoomsChunk>, | ||||
| 
 | ||||
| @ -68,9 +70,6 @@ pub mod v3 { | ||||
|         pub total_room_count_estimate: Option<UInt>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl Request<'_> { | ||||
|         /// Creates an empty `Request`.
 | ||||
|         pub fn new() -> Self { | ||||
|  | ||||
| @ -5,36 +5,38 @@ 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: { | ||||
|     const METADATA: Metadata = 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", | ||||
|         name: "get_room_visibility", | ||||
|         rate_limited: false, | ||||
|         authentication: None, | ||||
|             added: 1.0, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/directory/list/room/:room_id", | ||||
|             1.1 => "/_matrix/client/v3/directory/list/room/:room_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[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: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// Visibility of the room.
 | ||||
|         pub visibility: Visibility, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room ID.
 | ||||
|         pub fn new(room_id: &'a RoomId) -> Self { | ||||
|  | ||||
| @ -5,23 +5,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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", | ||||
|         name: "set_room_visibility", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/directory/list/room/:room_id", | ||||
|             1.1 => "/_matrix/client/v3/directory/list/room/:room_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[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, | ||||
| @ -30,11 +34,9 @@ pub mod v3 { | ||||
|         pub visibility: Visibility, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room ID and visibility.
 | ||||
|  | ||||
| @ -2,24 +2,29 @@ | ||||
| //!
 | ||||
| //! [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: { | ||||
| const METADATA: Metadata = 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, | ||||
|     history: { | ||||
|         1.0 => "/.well-known/matrix/client", | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
| #[request(error = crate::Error)] | ||||
| #[derive(Default)] | ||||
|     request: {} | ||||
| pub struct Request {} | ||||
| 
 | ||||
|     response: { | ||||
| #[response(error = crate::Error)] | ||||
| pub struct Response { | ||||
|     /// Information about the homeserver to connect to.
 | ||||
|     #[serde(rename = "m.homeserver")] | ||||
|     pub homeserver: HomeserverInfo, | ||||
| @ -33,7 +38,7 @@ ruma_api! { | ||||
|     #[serde(
 | ||||
|         rename = "org.matrix.msc3488.tile_server", | ||||
|         alias = "m.tile_server", | ||||
|             skip_serializing_if = "Option::is_none", | ||||
|         skip_serializing_if = "Option::is_none" | ||||
|     )] | ||||
|     pub tile_server: Option<TileServerInfo>, | ||||
| 
 | ||||
| @ -47,9 +52,6 @@ ruma_api! { | ||||
|     pub authentication: Option<AuthenticationServerInfo>, | ||||
| } | ||||
| 
 | ||||
|     error: crate::Error | ||||
| } | ||||
| 
 | ||||
| impl Request { | ||||
|     /// Creates an empty `Request`.
 | ||||
|     pub fn new() -> Self { | ||||
|  | ||||
| @ -2,33 +2,35 @@ | ||||
| //!
 | ||||
| //! [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: { | ||||
| const METADATA: Metadata = 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, | ||||
|     history: { | ||||
|         1.0 => "/_matrix/client/r0/capabilities", | ||||
|         1.1 => "/_matrix/client/v3/capabilities", | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
| #[request(error = crate::Error)] | ||||
| #[derive(Default)] | ||||
|     request: {} | ||||
| pub struct Request {} | ||||
| 
 | ||||
|     response: { | ||||
| #[response(error = crate::Error)] | ||||
| pub struct Response { | ||||
|     /// The capabilities the server supports
 | ||||
|     pub capabilities: Capabilities, | ||||
| } | ||||
| 
 | ||||
|     error: crate::Error | ||||
| } | ||||
| 
 | ||||
| impl Request { | ||||
|     /// Creates an empty `Request`.
 | ||||
|     pub fn new() -> Self { | ||||
|  | ||||
| @ -4,23 +4,28 @@ | ||||
| 
 | ||||
| use std::collections::BTreeMap; | ||||
| 
 | ||||
| use ruma_common::api::{ruma_api, MatrixVersion}; | ||||
| use ruma_common::{ | ||||
|     api::{request, response, MatrixVersion, Metadata}, | ||||
|     metadata, | ||||
| }; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata: { | ||||
| const METADATA: Metadata = 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, | ||||
|     history: { | ||||
|         1.0 => "/_matrix/client/versions", | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
| #[request(error = crate::Error)] | ||||
| #[derive(Default)] | ||||
|     request: {} | ||||
| pub struct Request {} | ||||
| 
 | ||||
|     response: { | ||||
| #[response(error = crate::Error)] | ||||
| pub struct Response { | ||||
|     /// A list of Matrix client API protocol versions supported by the homeserver.
 | ||||
|     pub versions: Vec<String>, | ||||
| 
 | ||||
| @ -29,9 +34,6 @@ ruma_api! { | ||||
|     pub unstable_features: BTreeMap<String, bool>, | ||||
| } | ||||
| 
 | ||||
|     error: crate::Error | ||||
| } | ||||
| 
 | ||||
| impl Request { | ||||
|     /// Creates an empty `Request`.
 | ||||
|     pub fn new() -> Self { | ||||
|  | ||||
| @ -5,23 +5,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/user/:user_id/filter", | ||||
|             1.1 => "/_matrix/client/v3/user/:user_id/filter", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[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.
 | ||||
| @ -33,14 +37,12 @@ pub mod v3 { | ||||
|         pub filter: FilterDefinition<'a>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The ID of the filter that was created.
 | ||||
|         pub filter_id: String, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given user ID and filter definition.
 | ||||
|         pub fn new(user_id: &'a UserId, filter: FilterDefinition<'a>) -> Self { | ||||
|  | ||||
| @ -5,23 +5,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/user/:user_id/filter/:filter_id", | ||||
|             1.1 => "/_matrix/client/v3/user/:user_id/filter/:filter_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The user ID to download a filter for.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
| @ -31,15 +35,13 @@ pub mod v3 { | ||||
|         pub filter_id: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The filter definition.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub filter: IncomingFilterDefinition, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given user ID and filter ID.
 | ||||
|         pub fn new(user_id: &'a UserId, filter_id: &'a str) -> Self { | ||||
|  | ||||
| @ -8,30 +8,34 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/keys/claim", | ||||
|             1.1 => "/_matrix/client/v3/keys/claim", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[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", | ||||
|             skip_serializing_if = "Option::is_none" | ||||
|         )] | ||||
|         pub timeout: Option<Duration>, | ||||
| 
 | ||||
| @ -39,7 +43,8 @@ pub mod v3 { | ||||
|         pub one_time_keys: BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, DeviceKeyAlgorithm>>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[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>, | ||||
| @ -48,9 +53,6 @@ pub mod v3 { | ||||
|         pub one_time_keys: BTreeMap<OwnedUserId, OneTimeKeys>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl Request { | ||||
|         /// Creates a new `Request` with the given key claims and the recommended 10 second timeout.
 | ||||
|         pub fn new( | ||||
|  | ||||
| @ -5,21 +5,25 @@ 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: { | ||||
|     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", | ||||
|             r0_path: "/_matrix/client/r0/keys/changes", | ||||
|             stable_path: "/_matrix/client/v3/keys/changes", | ||||
|         rate_limited: false, | ||||
|         authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/keys/changes", | ||||
|             1.1 => "/_matrix/client/v3/keys/changes", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[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.
 | ||||
| @ -34,7 +38,8 @@ pub mod v3 { | ||||
|         pub to: &'a str, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The Matrix User IDs of all users who updated their device identity keys.
 | ||||
|         pub changed: Vec<OwnedUserId>, | ||||
| 
 | ||||
| @ -43,9 +48,6 @@ pub mod v3 { | ||||
|         pub left: Vec<OwnedUserId>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given start and end points.
 | ||||
|         pub fn new(from: &'a str, to: &'a str) -> Self { | ||||
|  | ||||
| @ -8,34 +8,36 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/keys/query", | ||||
|             1.1 => "/_matrix/client/v3/keys/query", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         request: { | ||||
|     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", | ||||
|             skip_serializing_if = "Option::is_none" | ||||
|         )] | ||||
|         pub timeout: Option<Duration>, | ||||
| 
 | ||||
| @ -45,7 +47,8 @@ pub mod v3 { | ||||
|         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.
 | ||||
|         /// 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.
 | ||||
| @ -53,8 +56,9 @@ pub mod v3 { | ||||
|         pub token: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: { | ||||
|     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.
 | ||||
| @ -78,9 +82,6 @@ pub mod v3 { | ||||
|         pub user_signing_keys: BTreeMap<OwnedUserId, Raw<CrossSigningKey>>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl Request<'_> { | ||||
|         /// Creates an empty `Request`.
 | ||||
|         pub fn new() -> Self { | ||||
|  | ||||
| @ -9,26 +9,28 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/keys/upload", | ||||
|             1.1 => "/_matrix/client/v3/keys/upload", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         request: { | ||||
|     pub struct Request { | ||||
|         /// Identity keys for the device.
 | ||||
|         ///
 | ||||
|         /// May be absent if no new identity keys are required.
 | ||||
| @ -44,15 +46,13 @@ pub mod v3 { | ||||
|         pub fallback_keys: BTreeMap<OwnedDeviceKeyId, Raw<OneTimeKey>>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[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>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl Request { | ||||
|         /// Creates an empty `Request`.
 | ||||
|         pub fn new() -> Self { | ||||
|  | ||||
| @ -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,33 +21,32 @@ pub mod v3 { | ||||
| 
 | ||||
|     pub use super::iter::SignedKeysIter; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/keys/signatures/upload", | ||||
|             1.1 => "/_matrix/client/v3/keys/signatures/upload", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request { | ||||
|         /// Signed keys.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub signed_keys: BTreeMap<OwnedUserId, SignedKeys>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: { | ||||
|     pub struct Response { | ||||
|         /// Signature processing failures.
 | ||||
|         pub failures: BTreeMap<OwnedUserId, BTreeMap<String, Failure>>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl Request { | ||||
|         /// Creates a new `Request` with the given signed keys.
 | ||||
|         pub fn new(signed_keys: BTreeMap<OwnedUserId, SignedKeys>) -> Self { | ||||
|  | ||||
| @ -5,24 +5,30 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/keys/device_signing/upload", | ||||
|             1.1 => "/_matrix/client/v3/keys/device_signing/upload", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     #[request(error = UiaaResponse)] | ||||
|     #[derive(Default)] | ||||
|         request: { | ||||
|     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>>, | ||||
| @ -46,11 +52,9 @@ pub mod v3 { | ||||
|         pub user_signing_key: Option<Raw<CrossSigningKey>>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = UiaaResponse)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: UiaaResponse | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl Request<'_> { | ||||
|         /// Creates an empty `Request`.
 | ||||
|  | ||||
| @ -5,21 +5,25 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/xyz.amorgan.knock/knock/:room_id_or_alias", | ||||
|             1.1 => "/_matrix/client/v3/knock/:room_id_or_alias", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[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, | ||||
| @ -36,11 +40,11 @@ pub mod v3 { | ||||
|         pub server_name: &'a [OwnedServerName], | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The room that the user knocked on.
 | ||||
|         pub room_id: OwnedRoomId, | ||||
|     } | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room ID or alias.
 | ||||
|  | ||||
| @ -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,21 +6,25 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/media/r0/upload", | ||||
|             1.1 => "/_matrix/media/v3/upload", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The file contents to upload.
 | ||||
|         #[ruma_api(raw_body)] | ||||
|         pub file: &'a [u8], | ||||
| @ -43,12 +47,13 @@ pub mod v3 { | ||||
|         #[serde(
 | ||||
|             default, | ||||
|             skip_serializing_if = "ruma_common::serde::is_default", | ||||
|                 rename = "xyz.amorgan.generate_blurhash", | ||||
|             rename = "xyz.amorgan.generate_blurhash" | ||||
|         )] | ||||
|         pub generate_blurhash: bool, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The MXC URI for the uploaded content.
 | ||||
|         pub content_uri: OwnedMxcUri, | ||||
| 
 | ||||
| @ -65,9 +70,6 @@ pub mod v3 { | ||||
|         pub blurhash: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given file contents.
 | ||||
|         pub fn new(file: &'a [u8]) -> Self { | ||||
|  | ||||
| @ -6,19 +6,24 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             unstable => "/_matrix/media/unstable/fi.mau.msc2246/upload/:server_name/:media_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[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, | ||||
| @ -34,14 +39,11 @@ pub mod unstable { | ||||
|         /// 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 | ||||
|     } | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given file contents.
 | ||||
|  | ||||
| @ -6,21 +6,28 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             unstable => "/_matrix/media/unstable/fi.mau.msc2246/create", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: {} | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|     pub struct Request {} | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The MXC URI for the about to be uploaded content.
 | ||||
|         pub content_uri: OwnedMxcUri, | ||||
| 
 | ||||
| @ -28,9 +35,6 @@ pub mod unstable { | ||||
|         pub unused_expires_at: UInt, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl Response { | ||||
|         /// Creates a new `Response` with the given MXC URI which expires at a given point in time.
 | ||||
|         pub fn new(content_uri: OwnedMxcUri, unused_expires_at: UInt) -> Self { | ||||
|  | ||||
| @ -8,23 +8,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/media/r0/download/:server_name/:media_id", | ||||
|             1.1 => "/_matrix/media/v3/download/:server_name/:media_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[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, | ||||
| @ -37,10 +41,12 @@ pub mod v3 { | ||||
|         ///
 | ||||
|         /// 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")] | ||||
|         #[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
 | ||||
| @ -50,12 +56,13 @@ pub mod v3 { | ||||
|         #[serde(
 | ||||
|             default, | ||||
|             skip_serializing_if = "ruma_common::serde::is_default", | ||||
|                 rename = "fi.mau.msc2246.max_stall_ms", | ||||
|             rename = "fi.mau.msc2246.max_stall_ms" | ||||
|         )] | ||||
|         pub max_stall_ms: Option<UInt>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The content that was previously uploaded.
 | ||||
|         #[ruma_api(raw_body)] | ||||
|         pub file: Vec<u8>, | ||||
| @ -82,9 +89,6 @@ pub mod v3 { | ||||
|         pub cross_origin_resource_policy: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given media ID and server name.
 | ||||
|         pub fn new(media_id: &'a str, server_name: &'a ServerName) -> Self { | ||||
|  | ||||
| @ -6,23 +6,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/media/r0/download/:server_name/:media_id/:filename", | ||||
|             1.1 => "/_matrix/media/v3/download/:server_name/:media_id/:filename", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[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, | ||||
| @ -39,11 +43,15 @@ pub mod v3 { | ||||
|         ///
 | ||||
|         /// 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")] | ||||
|         #[serde(
 | ||||
|             default = "ruma_common::serde::default_true", | ||||
|             skip_serializing_if = "ruma_common::serde::is_true" | ||||
|         )] | ||||
|         pub allow_remote: bool, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The content that was previously uploaded.
 | ||||
|         #[ruma_api(raw_body)] | ||||
|         pub file: Vec<u8>, | ||||
| @ -70,9 +78,6 @@ pub mod v3 { | ||||
|         pub cross_origin_resource_policy: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given media ID, server name and filename.
 | ||||
|         pub fn new(media_id: &'a str, server_name: &'a ServerName, filename: &'a str) -> Self { | ||||
|  | ||||
| @ -7,23 +7,29 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/media/r0/thumbnail/:server_name/:media_id", | ||||
|             1.1 => "/_matrix/media/v3/thumbnail/:server_name/:media_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[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, | ||||
| @ -53,7 +59,10 @@ pub mod v3 { | ||||
|         ///
 | ||||
|         /// 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")] | ||||
|         #[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
 | ||||
| @ -65,12 +74,13 @@ pub mod v3 { | ||||
|         #[serde(
 | ||||
|             default, | ||||
|             skip_serializing_if = "ruma_common::serde::is_default", | ||||
|                 rename = "fi.mau.msc2246.max_stall_ms", | ||||
|             rename = "fi.mau.msc2246.max_stall_ms" | ||||
|         )] | ||||
|         pub max_stall_ms: Option<UInt>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A thumbnail of the requested content.
 | ||||
|         #[ruma_api(raw_body)] | ||||
|         pub file: Vec<u8>, | ||||
| @ -88,9 +98,6 @@ pub mod v3 { | ||||
|         pub cross_origin_resource_policy: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given media ID, server name, desired thumbnail width
 | ||||
|         /// and desired thumbnail height.
 | ||||
|  | ||||
| @ -6,32 +6,34 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/media/r0/config", | ||||
|             1.1 => "/_matrix/media/v3/config", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         request: {} | ||||
|     pub struct Request {} | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// Maximum size of upload in bytes.
 | ||||
|         #[serde(rename = "m.upload.size")] | ||||
|         pub upload_size: UInt, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl Request { | ||||
|         /// Creates an empty `Request`.
 | ||||
|         pub fn new() -> Self { | ||||
|  | ||||
| @ -5,23 +5,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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", | ||||
|         name: "get_media_preview", | ||||
|         rate_limited: true, | ||||
|         authentication: AccessToken, | ||||
|             added: 1.0, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/media/r0/preview_url", | ||||
|             1.1 => "/_matrix/media/v3/preview_url", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// URL to get a preview of.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub url: &'a str, | ||||
| @ -31,8 +35,9 @@ pub mod v3 { | ||||
|         pub ts: MilliSecondsSinceUnixEpoch, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: { | ||||
|     pub struct Response { | ||||
|         /// OpenGraph-like data for the URL.
 | ||||
|         ///
 | ||||
|         /// Differences from OpenGraph: the image size in bytes is added to the `matrix:image:size`
 | ||||
| @ -41,9 +46,6 @@ pub mod v3 { | ||||
|         pub data: Option<Box<RawJsonValue>>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given url and timestamp.
 | ||||
|         pub fn new(url: &'a str, ts: MilliSecondsSinceUnixEpoch) -> Self { | ||||
|  | ||||
| @ -5,21 +5,25 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/ban", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/ban", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room to kick the user from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| @ -32,11 +36,9 @@ pub mod v3 { | ||||
|         pub reason: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room id and room id.
 | ||||
|  | ||||
| @ -5,31 +5,33 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/forget", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/forget", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[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)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room id.
 | ||||
|  | ||||
| @ -6,27 +6,29 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/members", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/members", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room to get the member events for.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| @ -42,8 +44,8 @@ pub mod v3 { | ||||
|         /// 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.
 | ||||
|         /// 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>, | ||||
| @ -56,14 +58,12 @@ pub mod v3 { | ||||
|         pub not_membership: Option<MembershipEventFilter>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A list of member events.
 | ||||
|         pub chunk: Vec<Raw<RoomMemberEvent>>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room ID.
 | ||||
|         pub fn new(room_id: &'a RoomId) -> Self { | ||||
|  | ||||
| @ -10,24 +10,30 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/invite", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/invite", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room where the user should be invited.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| @ -41,11 +47,9 @@ pub mod v3 { | ||||
|         pub reason: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room ID and invitation recipient.
 | ||||
|  | ||||
| @ -5,23 +5,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/join", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/join", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room where the user should be invited.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| @ -36,14 +40,12 @@ pub mod v3 { | ||||
|         pub reason: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The room that the user joined.
 | ||||
|         pub room_id: OwnedRoomId, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room id.
 | ||||
|         pub fn new(room_id: &'a RoomId) -> Self { | ||||
|  | ||||
| @ -5,23 +5,27 @@ 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: { | ||||
|     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", | ||||
|             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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/join/:room_id_or_alias", | ||||
|             1.1 => "/_matrix/client/v3/join/:room_id_or_alias", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[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, | ||||
| @ -43,14 +47,12 @@ pub mod v3 { | ||||
|         pub reason: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// The room that the user joined.
 | ||||
|         pub room_id: OwnedRoomId, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room ID or alias ID.
 | ||||
|         pub fn new(room_id_or_alias: &'a RoomOrAliasId) -> Self { | ||||
|  | ||||
| @ -7,36 +7,38 @@ 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: { | ||||
|     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", | ||||
|             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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/joined_members", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/joined_members", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room to get the members of.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[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>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room ID.
 | ||||
|         pub fn new(room_id: &'a RoomId) -> Self { | ||||
|  | ||||
| @ -5,32 +5,34 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/joined_rooms", | ||||
|             1.1 => "/_matrix/client/v3/joined_rooms", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     #[request(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         request: {} | ||||
|     pub struct Request {} | ||||
| 
 | ||||
|         response: { | ||||
|     #[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>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl Request { | ||||
|         /// Creates an empty `Request`.
 | ||||
|         pub fn new() -> Self { | ||||
|  | ||||
| @ -5,21 +5,25 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/kick", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/kick", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room to kick the user from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| @ -32,11 +36,9 @@ pub mod v3 { | ||||
|         pub reason: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room id and room id.
 | ||||
|  | ||||
| @ -5,21 +5,25 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/leave", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/leave", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room to leave.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| @ -29,11 +33,9 @@ pub mod v3 { | ||||
|         pub reason: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room id.
 | ||||
|  | ||||
| @ -5,32 +5,35 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             unstable => "/_matrix/client/unstable/uk.half-shot.msc2666/user/mutual_rooms/:user_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The user to search mutual rooms for.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A list of rooms the user is in together with the authenticated user.
 | ||||
|         pub joined: Vec<OwnedRoomId>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given user id.
 | ||||
|         pub fn new(user_id: &'a UserId) -> Self { | ||||
|  | ||||
| @ -5,21 +5,25 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/unban", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/unban", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room to unban the user from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| @ -32,11 +36,9 @@ pub mod v3 { | ||||
|         pub reason: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room id and room id.
 | ||||
|  | ||||
| @ -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,19 +19,20 @@ pub mod v3 { | ||||
|         Direction, | ||||
|     }; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/rooms/:room_id/messages", | ||||
|             1.1 => "/_matrix/client/v3/rooms/:room_id/messages", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room to get events from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| @ -76,8 +78,9 @@ pub mod v3 { | ||||
|         pub filter: RoomEventFilter<'a>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: { | ||||
|     pub struct Response { | ||||
|         /// The token the pagination starts from.
 | ||||
|         pub start: String, | ||||
| 
 | ||||
| @ -94,9 +97,6 @@ pub mod v3 { | ||||
|         pub state: Vec<Raw<AnyStateEvent>>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room ID and direction.
 | ||||
|         ///
 | ||||
|  | ||||
| @ -6,26 +6,28 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         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: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The room to send the event to.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: &'a RoomId, | ||||
| @ -62,14 +64,12 @@ pub mod v3 { | ||||
|         pub timestamp: Option<MilliSecondsSinceUnixEpoch>, | ||||
|     } | ||||
| 
 | ||||
|         response: { | ||||
|     #[response(error = crate::Error)] | ||||
|     pub struct Response { | ||||
|         /// A unique identifier for the event.
 | ||||
|         pub event_id: OwnedEventId, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given room id, transaction id and event content.
 | ||||
|         ///
 | ||||
|  | ||||
| @ -7,27 +7,34 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/presence/:user_id/status", | ||||
|             1.1 => "/_matrix/client/v3/presence/:user_id/status", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[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: { | ||||
|     #[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>, | ||||
| @ -40,7 +47,7 @@ pub mod v3 { | ||||
|         #[serde(
 | ||||
|             with = "ruma_common::serde::duration::opt_ms", | ||||
|             default, | ||||
|                 skip_serializing_if = "Option::is_none", | ||||
|             skip_serializing_if = "Option::is_none" | ||||
|         )] | ||||
|         pub last_active_ago: Option<Duration>, | ||||
| 
 | ||||
| @ -48,9 +55,6 @@ pub mod v3 { | ||||
|         pub presence: PresenceState, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given user ID.
 | ||||
|         pub fn new(user_id: &'a UserId) -> Self { | ||||
|  | ||||
| @ -5,21 +5,27 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/presence/:user_id/status", | ||||
|             1.1 => "/_matrix/client/v3/presence/:user_id/status", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The user whose presence state will be updated.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
| @ -32,11 +38,9 @@ pub mod v3 { | ||||
|         pub status_msg: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given user ID and presence state.
 | ||||
|  | ||||
| @ -5,32 +5,37 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/profile/:user_id/avatar_url", | ||||
|             1.1 => "/_matrix/client/v3/profile/:user_id/avatar_url", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The user whose avatar URL will be retrieved.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: { | ||||
|     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.
 | ||||
|         /// 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", | ||||
| @ -47,9 +52,6 @@ pub mod v3 { | ||||
|         pub blurhash: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given user ID.
 | ||||
|         pub fn new(user_id: &'a UserId) -> Self { | ||||
|  | ||||
| @ -5,36 +5,38 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/profile/:user_id/displayname", | ||||
|             1.1 => "/_matrix/client/v3/profile/:user_id/displayname", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The user whose display name will be retrieved.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: { | ||||
|     pub struct Response { | ||||
|         /// The user's display name, if set.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub displayname: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given user ID.
 | ||||
|         pub fn new(user_id: &'a UserId) -> Self { | ||||
|  | ||||
| @ -5,32 +5,37 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/profile/:user_id", | ||||
|             1.1 => "/_matrix/client/v3/profile/:user_id", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The user whose profile will be retrieved.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: { | ||||
|     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.
 | ||||
|         /// 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", | ||||
| @ -51,9 +56,6 @@ pub mod v3 { | ||||
|         pub blurhash: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given user ID.
 | ||||
|         pub fn new(user_id: &'a UserId) -> Self { | ||||
|  | ||||
| @ -5,21 +5,25 @@ 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: { | ||||
|     const METADATA: Metadata = 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, | ||||
|         history: { | ||||
|             1.0 => "/_matrix/client/r0/profile/:user_id/avatar_url", | ||||
|             1.1 => "/_matrix/client/v3/profile/:user_id/avatar_url", | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|         request: { | ||||
|     #[request(error = crate::Error)] | ||||
|     pub struct Request<'a> { | ||||
|         /// The user whose avatar URL will be set.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: &'a UserId, | ||||
| @ -28,8 +32,8 @@ pub mod v3 { | ||||
|         ///
 | ||||
|         /// `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.
 | ||||
|         /// 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( | ||||
| @ -38,10 +42,7 @@ pub mod v3 { | ||||
|                 serialize_with = "ruma_common::serde::none_as_empty_string" | ||||
|             ) | ||||
|         )] | ||||
|             #[cfg_attr(
 | ||||
|                 not(feature = "compat"), | ||||
|                 serde(skip_serializing_if = "Option::is_none") | ||||
|             )] | ||||
|         #[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`.
 | ||||
| @ -53,11 +54,9 @@ pub mod v3 { | ||||
|         pub blurhash: Option<&'a str>, | ||||
|     } | ||||
| 
 | ||||
|     #[response(error = crate::Error)] | ||||
|     #[derive(Default)] | ||||
|         response: {} | ||||
| 
 | ||||
|         error: crate::Error | ||||
|     } | ||||
|     pub struct Response {} | ||||
| 
 | ||||
|     impl<'a> Request<'a> { | ||||
|         /// Creates a new `Request` with the given user ID and avatar URL.
 | ||||
|  | ||||
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