Use folders instead of mods
This commit is contained in:
		
							parent
							
								
									c78faf0bf3
								
							
						
					
					
						commit
						d48fc54c96
					
				
							
								
								
									
										28
									
								
								src/lib.rs
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								src/lib.rs
									
									
									
									
									
								
							| @ -14,31 +14,5 @@ use serde_json; | ||||
| use serde_urlencoded; | ||||
| use url; | ||||
| 
 | ||||
| /// Endpoints for the r0.x.x versions of the client API specification.
 | ||||
| pub mod r0 { | ||||
|     pub mod account; | ||||
|     pub mod alias; | ||||
|     pub mod config; | ||||
|     pub mod contact; | ||||
|     pub mod context; | ||||
|     pub mod directory; | ||||
|     pub mod filter; | ||||
|     pub mod media; | ||||
|     pub mod membership; | ||||
|     pub mod presence; | ||||
|     pub mod profile; | ||||
|     pub mod push; | ||||
|     pub mod receipt; | ||||
|     pub mod redact; | ||||
|     pub mod room; | ||||
|     pub mod search; | ||||
|     pub mod send; | ||||
|     pub mod server; | ||||
|     pub mod session; | ||||
|     pub mod sync; | ||||
|     pub mod tag; | ||||
|     pub mod typing; | ||||
|     pub mod voip; | ||||
| } | ||||
| 
 | ||||
| pub mod r0; | ||||
| pub mod unversioned; | ||||
|  | ||||
							
								
								
									
										25
									
								
								src/r0.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/r0.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,25 @@ | ||||
| //! Endpoints for the r0.x.x versions of the client API specification.
 | ||||
| 
 | ||||
| pub mod account; | ||||
| pub mod alias; | ||||
| pub mod config; | ||||
| pub mod contact; | ||||
| pub mod context; | ||||
| pub mod directory; | ||||
| pub mod filter; | ||||
| pub mod media; | ||||
| pub mod membership; | ||||
| pub mod presence; | ||||
| pub mod profile; | ||||
| pub mod push; | ||||
| pub mod receipt; | ||||
| pub mod redact; | ||||
| pub mod room; | ||||
| pub mod search; | ||||
| pub mod send; | ||||
| pub mod server; | ||||
| pub mod session; | ||||
| pub mod sync; | ||||
| pub mod tag; | ||||
| pub mod typing; | ||||
| pub mod voip; | ||||
| @ -1,209 +1,7 @@ | ||||
| //! Endpoints for account registration and management.
 | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/register](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-register)
 | ||||
| pub mod register { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::UserId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Register an account on this homeserver.", | ||||
|             method: POST, | ||||
|             name: "register", | ||||
|             path: "/_matrix/client/r0/register", | ||||
|             rate_limited: true, | ||||
|             requires_authentication: false, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// If true, the server binds the email used for authentication
 | ||||
|             /// to the Matrix ID with the ID Server.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub bind_email: Option<bool>, | ||||
|             /// The desired password for the account.
 | ||||
|             ///
 | ||||
|             /// Should only be empty for guest accounts.
 | ||||
|             // TODO: the spec says nothing about when it is actually required.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub password: Option<String>, | ||||
|             /// local part of the desired Matrix ID.
 | ||||
|             ///
 | ||||
|             /// If omitted, the homeserver MUST generate a Matrix ID local part.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub username: Option<String>, | ||||
|             /// ID of the client device.
 | ||||
|             ///
 | ||||
|             /// If this does not correspond to a known client device, a new device will be created.
 | ||||
|             /// The server will auto-generate a device_id if this is not specified.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub device_id: Option<String>, | ||||
|             /// A display name to assign to the newly-created device.
 | ||||
|             ///
 | ||||
|             /// Ignored if `device_id` corresponds to a known device.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub initial_device_display_name: Option<String>, | ||||
|             /// Additional authentication information for the user-interactive authentication API.
 | ||||
|             ///
 | ||||
|             /// Note that this information is not used to define how the registered user should be
 | ||||
|             /// authenticated, but is instead used to authenticate the register call itself.
 | ||||
|             /// It should be left empty, or omitted, unless an earlier call returned an response
 | ||||
|             /// with status code 401.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub auth: Option<AuthenticationData>, | ||||
|             /// Kind of account to register
 | ||||
|             ///
 | ||||
|             /// Defaults to `User` if ommited.
 | ||||
|             #[ruma_api(query)] | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub kind: Option<RegistrationKind>, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// An access token for the account.
 | ||||
|             ///
 | ||||
|             /// This access token can then be used to authorize other requests.
 | ||||
|             pub access_token: String, | ||||
|             /// The hostname of the homeserver on which the account has been registered.
 | ||||
|             pub home_server: String, | ||||
|             /// The fully-qualified Matrix ID that has been registered.
 | ||||
|             pub user_id: UserId, | ||||
|             /// ID of the registered device.
 | ||||
|             ///
 | ||||
|             /// Will be the same as the corresponding parameter in the request, if one was specified.
 | ||||
|             pub device_id: String, | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /// Additional authentication information for the user-interactive authentication API.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct AuthenticationData { | ||||
|         /// The login type that the client is attempting to complete.
 | ||||
|         #[serde(rename = "type")] | ||||
|         kind: String, | ||||
|         /// The value of the session key given by the homeserver.
 | ||||
|         session: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|     /// The kind of account being registered.
 | ||||
|     #[derive(Copy, Clone, Debug, Deserialize, Serialize)] | ||||
|     pub enum RegistrationKind { | ||||
|         /// A guest account
 | ||||
|         ///
 | ||||
|         /// These accounts may have limited permissions and may not be supported by all servers.
 | ||||
|         #[serde(rename = "guest")] | ||||
|         Guest, | ||||
|         /// A regular user account
 | ||||
|         #[serde(rename = "user")] | ||||
|         User, | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/account/password/email/requestToken](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-account-password-email-requesttoken)
 | ||||
| pub mod request_password_change_token { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Request that a password change token is sent to the given email address.", | ||||
|             method: POST, | ||||
|             name: "request_password_change_token", | ||||
|             path: "/_matrix/client/r0/account/password/email/requestToken", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: false, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// TODO: This parameter is not documented in the spec.
 | ||||
|             pub client_secret: String, | ||||
|             /// TODO: This parameter is not documented in the spec.
 | ||||
|             pub email: String, | ||||
|             /// TODO: This parameter is not documented in the spec.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub id_server: Option<String>, | ||||
|             /// TODO: This parameter is not documented in the spec.
 | ||||
|             pub send_attempt: u64, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/account/deactivate](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-account-deactivate)
 | ||||
| pub mod deactivate { | ||||
|     // TODO: missing request parameters
 | ||||
| 
 | ||||
|     use ruma_api_macros::ruma_api; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Deactivate the current user's account.", | ||||
|             method: POST, | ||||
|             name: "deactivate", | ||||
|             path: "/_matrix/client/r0/account/deactivate", | ||||
|             rate_limited: true, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request {} | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/account/password](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-account-password)
 | ||||
| pub mod change_password { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Change the password of the current user's account.", | ||||
|             method: POST, | ||||
|             name: "change_password", | ||||
|             path: "/_matrix/client/r0/account/password", | ||||
|             rate_limited: true, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The new password for the account.
 | ||||
|             pub new_password: String, | ||||
|             // TODO: missing `auth` field
 | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/register/email/requestToken](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-register-email-requesttoken)
 | ||||
| pub mod request_register_token { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Request a register token with a 3rd party email.", | ||||
|             method: POST, | ||||
|             name: "request_register_token", | ||||
|             path: "/_matrix/client/r0/register/email/requestToken", | ||||
|             rate_limited: true, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// Client-generated secret string used to protect this session.
 | ||||
|             pub client_secret: String, | ||||
|             /// The email address.
 | ||||
|             pub email: String, | ||||
|             /// The ID server to send the onward request to as a hostname with an appended colon and port number if the port is not the default.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub id_server: Option<String>, | ||||
|             /// Used to distinguish protocol level retries from requests to re-send the email.
 | ||||
|             pub send_attempt: u64, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| pub mod change_password; | ||||
| pub mod deactivate; | ||||
| pub mod register; | ||||
| pub mod request_password_change_token; | ||||
| pub mod request_register_token; | ||||
|  | ||||
							
								
								
									
										23
									
								
								src/r0/account/change_password.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								src/r0/account/change_password.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | ||||
| //! [POST /_matrix/client/r0/account/password](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-account-password)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Change the password of the current user's account.", | ||||
|         method: POST, | ||||
|         name: "change_password", | ||||
|         path: "/_matrix/client/r0/account/password", | ||||
|         rate_limited: true, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The new password for the account.
 | ||||
|         pub new_password: String, | ||||
|         // TODO: missing `auth` field
 | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
							
								
								
									
										19
									
								
								src/r0/account/deactivate.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/r0/account/deactivate.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | ||||
| //! [POST /_matrix/client/r0/account/deactivate](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-account-deactivate)
 | ||||
| // TODO: missing request parameters
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Deactivate the current user's account.", | ||||
|         method: POST, | ||||
|         name: "deactivate", | ||||
|         path: "/_matrix/client/r0/account/deactivate", | ||||
|         rate_limited: true, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request {} | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
							
								
								
									
										97
									
								
								src/r0/account/register.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										97
									
								
								src/r0/account/register.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,97 @@ | ||||
| //! [POST /_matrix/client/r0/register](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-register)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::UserId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Register an account on this homeserver.", | ||||
|         method: POST, | ||||
|         name: "register", | ||||
|         path: "/_matrix/client/r0/register", | ||||
|         rate_limited: true, | ||||
|         requires_authentication: false, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// If true, the server binds the email used for authentication
 | ||||
|         /// to the Matrix ID with the ID Server.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub bind_email: Option<bool>, | ||||
|         /// The desired password for the account.
 | ||||
|         ///
 | ||||
|         /// Should only be empty for guest accounts.
 | ||||
|         // TODO: the spec says nothing about when it is actually required.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub password: Option<String>, | ||||
|         /// local part of the desired Matrix ID.
 | ||||
|         ///
 | ||||
|         /// If omitted, the homeserver MUST generate a Matrix ID local part.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub username: Option<String>, | ||||
|         /// ID of the client device.
 | ||||
|         ///
 | ||||
|         /// If this does not correspond to a known client device, a new device will be created.
 | ||||
|         /// The server will auto-generate a device_id if this is not specified.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub device_id: Option<String>, | ||||
|         /// A display name to assign to the newly-created device.
 | ||||
|         ///
 | ||||
|         /// Ignored if `device_id` corresponds to a known device.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub initial_device_display_name: Option<String>, | ||||
|         /// Additional authentication information for the user-interactive authentication API.
 | ||||
|         ///
 | ||||
|         /// Note that this information is not used to define how the registered user should be
 | ||||
|         /// authenticated, but is instead used to authenticate the register call itself.
 | ||||
|         /// It should be left empty, or omitted, unless an earlier call returned an response
 | ||||
|         /// with status code 401.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub auth: Option<AuthenticationData>, | ||||
|         /// Kind of account to register
 | ||||
|         ///
 | ||||
|         /// Defaults to `User` if ommited.
 | ||||
|         #[ruma_api(query)] | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub kind: Option<RegistrationKind>, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// An access token for the account.
 | ||||
|         ///
 | ||||
|         /// This access token can then be used to authorize other requests.
 | ||||
|         pub access_token: String, | ||||
|         /// The hostname of the homeserver on which the account has been registered.
 | ||||
|         pub home_server: String, | ||||
|         /// The fully-qualified Matrix ID that has been registered.
 | ||||
|         pub user_id: UserId, | ||||
|         /// ID of the registered device.
 | ||||
|         ///
 | ||||
|         /// Will be the same as the corresponding parameter in the request, if one was specified.
 | ||||
|         pub device_id: String, | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// Additional authentication information for the user-interactive authentication API.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct AuthenticationData { | ||||
|     /// The login type that the client is attempting to complete.
 | ||||
|     #[serde(rename = "type")] | ||||
|     kind: String, | ||||
|     /// The value of the session key given by the homeserver.
 | ||||
|     session: Option<String>, | ||||
| } | ||||
| 
 | ||||
| /// The kind of account being registered.
 | ||||
| #[derive(Copy, Clone, Debug, Deserialize, Serialize)] | ||||
| pub enum RegistrationKind { | ||||
|     /// A guest account
 | ||||
|     ///
 | ||||
|     /// These accounts may have limited permissions and may not be supported by all servers.
 | ||||
|     #[serde(rename = "guest")] | ||||
|     Guest, | ||||
|     /// A regular user account
 | ||||
|     #[serde(rename = "user")] | ||||
|     User, | ||||
| } | ||||
							
								
								
									
										29
									
								
								src/r0/account/request_password_change_token.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/r0/account/request_password_change_token.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | ||||
| //! [POST /_matrix/client/r0/account/password/email/requestToken](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-account-password-email-requesttoken)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Request that a password change token is sent to the given email address.", | ||||
|         method: POST, | ||||
|         name: "request_password_change_token", | ||||
|         path: "/_matrix/client/r0/account/password/email/requestToken", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: false, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// TODO: This parameter is not documented in the spec.
 | ||||
|         pub client_secret: String, | ||||
|         /// TODO: This parameter is not documented in the spec.
 | ||||
|         pub email: String, | ||||
|         /// TODO: This parameter is not documented in the spec.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub id_server: Option<String>, | ||||
|         /// TODO: This parameter is not documented in the spec.
 | ||||
|         pub send_attempt: u64, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
							
								
								
									
										29
									
								
								src/r0/account/request_register_token.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/r0/account/request_register_token.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | ||||
| //! [POST /_matrix/client/r0/register/email/requestToken](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-register-email-requesttoken)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Request a register token with a 3rd party email.", | ||||
|         method: POST, | ||||
|         name: "request_register_token", | ||||
|         path: "/_matrix/client/r0/register/email/requestToken", | ||||
|         rate_limited: true, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// Client-generated secret string used to protect this session.
 | ||||
|         pub client_secret: String, | ||||
|         /// The email address.
 | ||||
|         pub email: String, | ||||
|         /// The ID server to send the onward request to as a hostname with an appended colon and port number if the port is not the default.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub id_server: Option<String>, | ||||
|         /// Used to distinguish protocol level retries from requests to re-send the email.
 | ||||
|         pub send_attempt: u64, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
| @ -1,86 +1,5 @@ | ||||
| //! Endpoints for room aliases.
 | ||||
| 
 | ||||
| /// [PUT /_matrix/client/r0/directory/room/{roomAlias}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-directory-room-roomalias)
 | ||||
| pub mod create_alias { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::{RoomAliasId, RoomId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Add an alias to a room.", | ||||
|             method: PUT, | ||||
|             name: "create_alias", | ||||
|             path: "/_matrix/client/r0/directory/room/:room_alias", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room alias to set.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_alias: RoomAliasId, | ||||
|             /// The room ID to set.
 | ||||
|             pub room_id: RoomId, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [DELETE /_matrix/client/r0/directory/room/{roomAlias}](https://matrix.org/docs/spec/client_server/r0.2.0.html#delete-matrix-client-r0-directory-room-roomalias)
 | ||||
| pub mod delete_alias { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::RoomAliasId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Remove an alias from a room.", | ||||
|             method: DELETE, | ||||
|             name: "delete_alias", | ||||
|             path: "/_matrix/client/r0/directory/room/:room_alias", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room alias to remove.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_alias: RoomAliasId, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [GET /_matrix/client/r0/directory/room/{roomAlias}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-directory-room-roomalias)
 | ||||
| pub mod get_alias { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::{RoomAliasId, RoomId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Resolve a room alias to a room ID.", | ||||
|             method: GET, | ||||
|             name: "get_alias", | ||||
|             path: "/_matrix/client/r0/directory/room/:room_alias", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room alias.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_alias: RoomAliasId, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// The room ID for this room alias.
 | ||||
|             pub room_id: RoomId, | ||||
|             /// A list of servers that are aware of this room ID.
 | ||||
|             pub servers: Vec<String>, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| pub mod create_alias; | ||||
| pub mod delete_alias; | ||||
| pub mod get_alias; | ||||
|  | ||||
							
								
								
									
										26
									
								
								src/r0/alias/create_alias.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/r0/alias/create_alias.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,26 @@ | ||||
| //! [PUT /_matrix/client/r0/directory/room/{roomAlias}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-directory-room-roomalias)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::{RoomAliasId, RoomId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Add an alias to a room.", | ||||
|         method: PUT, | ||||
|         name: "create_alias", | ||||
|         path: "/_matrix/client/r0/directory/room/:room_alias", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room alias to set.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_alias: RoomAliasId, | ||||
|         /// The room ID to set.
 | ||||
|         pub room_id: RoomId, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
							
								
								
									
										24
									
								
								src/r0/alias/delete_alias.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								src/r0/alias/delete_alias.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,24 @@ | ||||
| //! [DELETE /_matrix/client/r0/directory/room/{roomAlias}](https://matrix.org/docs/spec/client_server/r0.2.0.html#delete-matrix-client-r0-directory-room-roomalias)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::RoomAliasId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Remove an alias from a room.", | ||||
|         method: DELETE, | ||||
|         name: "delete_alias", | ||||
|         path: "/_matrix/client/r0/directory/room/:room_alias", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room alias to remove.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_alias: RoomAliasId, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
							
								
								
									
										29
									
								
								src/r0/alias/get_alias.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/r0/alias/get_alias.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | ||||
| //! [GET /_matrix/client/r0/directory/room/{roomAlias}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-directory-room-roomalias)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::{RoomAliasId, RoomId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Resolve a room alias to a room ID.", | ||||
|         method: GET, | ||||
|         name: "get_alias", | ||||
|         path: "/_matrix/client/r0/directory/room/:room_alias", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room alias.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_alias: RoomAliasId, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// The room ID for this room alias.
 | ||||
|         pub room_id: RoomId, | ||||
|         /// A list of servers that are aware of this room ID.
 | ||||
|         pub servers: Vec<String>, | ||||
|     } | ||||
| } | ||||
| @ -1,78 +1,4 @@ | ||||
| //! Endpoints for client configuration.
 | ||||
| 
 | ||||
| /// [PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-user-userid-rooms-roomid-account-data-type)
 | ||||
| pub mod set_room_account_data { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::{RoomId, UserId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
|     use serde_json::Value; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Associate account data with a room.", | ||||
|             method: PUT, | ||||
|             name: "set_room_account_data", | ||||
|             path: "/_matrix/client/r0/user/:user_id/rooms/:room_id/account_data/:event_type", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// Arbitrary JSON to store as config data.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub data: Value, | ||||
|             /// The event type of the account_data to set.
 | ||||
|             ///
 | ||||
|             /// Custom types should be namespaced to avoid clashes.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub event_type: String, | ||||
|             /// The ID of the room to set account_data on.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|             /// The ID of the user to set account_data for.
 | ||||
|             ///
 | ||||
|             /// The access token must be authorized to make requests for this user ID.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: UserId, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [PUT /_matrix/client/r0/user/{userId}/account_data/{type}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-user-userid-account-data-type)
 | ||||
| pub mod set_global_account_data { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::UserId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
|     use serde_json::Value; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Sets global account data.", | ||||
|             method: PUT, | ||||
|             name: "set_global_account_data", | ||||
|             path: "/_matrix/client/r0/user/:user_id/account_data/:event_type", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// Arbitrary JSON to store as config data.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub data: Value, | ||||
|             /// The event type of the account_data to set.
 | ||||
|             ///
 | ||||
|             /// Custom types should be namespaced to avoid clashes.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub event_type: String, | ||||
|             /// The ID of the user to set account_data for.
 | ||||
|             ///
 | ||||
|             /// The access token must be authorized to make requests for this user ID.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: UserId, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| pub mod set_global_account_data; | ||||
| pub mod set_room_account_data; | ||||
|  | ||||
							
								
								
									
										35
									
								
								src/r0/config/set_global_account_data.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								src/r0/config/set_global_account_data.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,35 @@ | ||||
| //! [PUT /_matrix/client/r0/user/{userId}/account_data/{type}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-user-userid-account-data-type)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::UserId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| use serde_json::Value; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Sets global account data.", | ||||
|         method: PUT, | ||||
|         name: "set_global_account_data", | ||||
|         path: "/_matrix/client/r0/user/:user_id/account_data/:event_type", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// Arbitrary JSON to store as config data.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub data: Value, | ||||
|         /// The event type of the account_data to set.
 | ||||
|         ///
 | ||||
|         /// Custom types should be namespaced to avoid clashes.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub event_type: String, | ||||
|         /// The ID of the user to set account_data for.
 | ||||
|         ///
 | ||||
|         /// The access token must be authorized to make requests for this user ID.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: UserId, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
							
								
								
									
										38
									
								
								src/r0/config/set_room_account_data.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								src/r0/config/set_room_account_data.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,38 @@ | ||||
| //! [PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-user-userid-rooms-roomid-account-data-type)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::{RoomId, UserId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| use serde_json::Value; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Associate account data with a room.", | ||||
|         method: PUT, | ||||
|         name: "set_room_account_data", | ||||
|         path: "/_matrix/client/r0/user/:user_id/rooms/:room_id/account_data/:event_type", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// Arbitrary JSON to store as config data.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub data: Value, | ||||
|         /// The event type of the account_data to set.
 | ||||
|         ///
 | ||||
|         /// Custom types should be namespaced to avoid clashes.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub event_type: String, | ||||
|         /// The ID of the room to set account_data on.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|         /// The ID of the user to set account_data for.
 | ||||
|         ///
 | ||||
|         /// The access token must be authorized to make requests for this user ID.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: UserId, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
| @ -1,115 +1,5 @@ | ||||
| //! Endpoints for account contact information.
 | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/account/3pid](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-account-3pid)
 | ||||
| pub mod create_contact { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Adds contact information to the user's account.", | ||||
|             method: POST, | ||||
|             name: "create_contact", | ||||
|             path: "/_matrix/client/r0/account/3pid", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// Whether the homeserver should also bind this third party identifier to the account's
 | ||||
|             /// Matrix ID with the passed identity server.
 | ||||
|             ///
 | ||||
|             /// Default to `false` if not supplied.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub bind: Option<bool>, | ||||
|             /// The third party credentials to associate with the account.
 | ||||
|             pub three_pid_creds: ThreePidCredentials, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| 
 | ||||
|     /// The third party credentials to associate with the account.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct ThreePidCredentials { | ||||
|         /// The client secret used in the session with the identity server.
 | ||||
|         pub client_secret: String, | ||||
|         /// The identity server to use.
 | ||||
|         pub id_server: String, | ||||
|         /// The session identifier given by the identity server.
 | ||||
|         pub sid: String, | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [GET /_matrix/client/r0/account/3pid](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-account-3pid)
 | ||||
| pub mod get_contacts { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Get a list of 3rd party contacts associated with the user's account.", | ||||
|             method: GET, | ||||
|             name: "get_contacts", | ||||
|             path: "/_matrix/client/r0/account/3pid", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request {} | ||||
| 
 | ||||
|         response { | ||||
|             /// A list of third party identifiers the homeserver has associated with the user's
 | ||||
|             /// account.
 | ||||
|             pub threepids: Vec<ThirdPartyIdentifier>, | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /// The medium of third party identifier.
 | ||||
|     #[derive(Clone, Copy, Debug, Deserialize, Serialize)] | ||||
|     pub enum Medium { | ||||
|         /// An email address.
 | ||||
|         #[serde(rename = "email")] | ||||
|         Email, | ||||
|     } | ||||
| 
 | ||||
|     /// An identifier external to Matrix.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct ThirdPartyIdentifier { | ||||
|         /// The third party identifier address.
 | ||||
|         pub address: String, | ||||
|         /// The medium of third party identifier.
 | ||||
|         pub medium: Medium, | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/account/3pid/email/requestToken](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-account-3pid-email-requesttoken)
 | ||||
| pub mod request_contact_verification_token { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Ask for a verification token for a given 3rd party ID.", | ||||
|             method: POST, | ||||
|             name: "request_contact_verification_token", | ||||
|             path: "/_matrix/client/r0/account/3pid/email/requestToken", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: false, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// Client-generated secret string used to protect this session.
 | ||||
|             pub client_secret: String, | ||||
|             /// The email address.
 | ||||
|             pub email: String, | ||||
|             /// The ID server to send the onward request to as a hostname with an appended colon and port number if the port is not the default.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub id_server: Option<String>, | ||||
|             /// Used to distinguish protocol level retries from requests to re-send the email.
 | ||||
|             pub send_attempt: u64, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| pub mod create_contact; | ||||
| pub mod get_contacts; | ||||
| pub mod request_contact_verification_token; | ||||
|  | ||||
							
								
								
									
										39
									
								
								src/r0/contact/create_contact.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								src/r0/contact/create_contact.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,39 @@ | ||||
| //! [POST /_matrix/client/r0/account/3pid](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-account-3pid)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Adds contact information to the user's account.", | ||||
|         method: POST, | ||||
|         name: "create_contact", | ||||
|         path: "/_matrix/client/r0/account/3pid", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// Whether the homeserver should also bind this third party identifier to the account's
 | ||||
|         /// Matrix ID with the passed identity server.
 | ||||
|         ///
 | ||||
|         /// Default to `false` if not supplied.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub bind: Option<bool>, | ||||
|         /// The third party credentials to associate with the account.
 | ||||
|         pub three_pid_creds: ThreePidCredentials, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
| 
 | ||||
| /// The third party credentials to associate with the account.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct ThreePidCredentials { | ||||
|     /// The client secret used in the session with the identity server.
 | ||||
|     pub client_secret: String, | ||||
|     /// The identity server to use.
 | ||||
|     pub id_server: String, | ||||
|     /// The session identifier given by the identity server.
 | ||||
|     pub sid: String, | ||||
| } | ||||
							
								
								
									
										40
									
								
								src/r0/contact/get_contacts.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/r0/contact/get_contacts.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | ||||
| //! [GET /_matrix/client/r0/account/3pid](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-account-3pid)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Get a list of 3rd party contacts associated with the user's account.", | ||||
|         method: GET, | ||||
|         name: "get_contacts", | ||||
|         path: "/_matrix/client/r0/account/3pid", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request {} | ||||
| 
 | ||||
|     response { | ||||
|         /// A list of third party identifiers the homeserver has associated with the user's
 | ||||
|         /// account.
 | ||||
|         pub threepids: Vec<ThirdPartyIdentifier>, | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// The medium of third party identifier.
 | ||||
| #[derive(Clone, Copy, Debug, Deserialize, Serialize)] | ||||
| pub enum Medium { | ||||
|     /// An email address.
 | ||||
|     #[serde(rename = "email")] | ||||
|     Email, | ||||
| } | ||||
| 
 | ||||
| /// An identifier external to Matrix.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct ThirdPartyIdentifier { | ||||
|     /// The third party identifier address.
 | ||||
|     pub address: String, | ||||
|     /// The medium of third party identifier.
 | ||||
|     pub medium: Medium, | ||||
| } | ||||
							
								
								
									
										29
									
								
								src/r0/contact/request_contact_verification_token.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/r0/contact/request_contact_verification_token.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | ||||
| //! [POST /_matrix/client/r0/account/3pid/email/requestToken](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-account-3pid-email-requesttoken)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Ask for a verification token for a given 3rd party ID.", | ||||
|         method: POST, | ||||
|         name: "request_contact_verification_token", | ||||
|         path: "/_matrix/client/r0/account/3pid/email/requestToken", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: false, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// Client-generated secret string used to protect this session.
 | ||||
|         pub client_secret: String, | ||||
|         /// The email address.
 | ||||
|         pub email: String, | ||||
|         /// The ID server to send the onward request to as a hostname with an appended colon and port number if the port is not the default.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub id_server: Option<String>, | ||||
|         /// Used to distinguish protocol level retries from requests to re-send the email.
 | ||||
|         pub send_attempt: u64, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
| @ -1,51 +1,3 @@ | ||||
| //! Endpoints for event context.
 | ||||
| 
 | ||||
| /// [GET /_matrix/client/r0/rooms/{roomId}/context/{eventId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-context-eventid)
 | ||||
| pub mod get_context { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_events::collections::only; | ||||
|     use ruma_identifiers::{EventId, RoomId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Get the events immediately preceding and following a given event.", | ||||
|             method: GET, | ||||
|             path: "/_matrix/client/r0/rooms/:room_id/context/:event_id", | ||||
|             name: "get_context", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The event to get context around.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub event_id: EventId, | ||||
|             /// The maximum number of events to return.
 | ||||
|             ///
 | ||||
|             /// Defaults to 10 if not supplied.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub limit: u8, | ||||
|             /// The room to get events from.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// A token that can be used to paginate forwards with.
 | ||||
|             pub end: String, | ||||
|             /// Details of the requested event.
 | ||||
|             pub event: only::RoomEvent, | ||||
|             /// A list of room events that happened just after the requested event, in chronological
 | ||||
|             /// order.
 | ||||
|             pub events_after: Vec<only::RoomEvent>, | ||||
|             /// A list of room events that happened just before the requested event, in
 | ||||
|             /// reverse-chronological order.
 | ||||
|             pub events_before: Vec<only::RoomEvent>, | ||||
|             /// A token that can be used to paginate backwards with.
 | ||||
|             pub start: String, | ||||
|             /// The state of the room at the last event returned.
 | ||||
|             pub state: Vec<only::StateEvent>, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| pub mod get_context; | ||||
|  | ||||
							
								
								
									
										48
									
								
								src/r0/context/get_context.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								src/r0/context/get_context.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,48 @@ | ||||
| //! [GET /_matrix/client/r0/rooms/{roomId}/context/{eventId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-context-eventid)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_events::collections::only; | ||||
| use ruma_identifiers::{EventId, RoomId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Get the events immediately preceding and following a given event.", | ||||
|         method: GET, | ||||
|         path: "/_matrix/client/r0/rooms/:room_id/context/:event_id", | ||||
|         name: "get_context", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The event to get context around.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub event_id: EventId, | ||||
|         /// The maximum number of events to return.
 | ||||
|         ///
 | ||||
|         /// Defaults to 10 if not supplied.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub limit: u8, | ||||
|         /// The room to get events from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// A token that can be used to paginate forwards with.
 | ||||
|         pub end: String, | ||||
|         /// Details of the requested event.
 | ||||
|         pub event: only::RoomEvent, | ||||
|         /// A list of room events that happened just after the requested event, in chronological
 | ||||
|         /// order.
 | ||||
|         pub events_after: Vec<only::RoomEvent>, | ||||
|         /// A list of room events that happened just before the requested event, in
 | ||||
|         /// reverse-chronological order.
 | ||||
|         pub events_before: Vec<only::RoomEvent>, | ||||
|         /// A token that can be used to paginate backwards with.
 | ||||
|         pub start: String, | ||||
|         /// The state of the room at the last event returned.
 | ||||
|         pub state: Vec<only::StateEvent>, | ||||
|     } | ||||
| } | ||||
| @ -1,57 +1,3 @@ | ||||
| //! Endpoints for the public room directory.
 | ||||
| 
 | ||||
| /// [GET /_matrix/client/r0/publicRooms](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-publicrooms)
 | ||||
| pub mod get_public_rooms { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::{RoomAliasId, RoomId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Get the list of rooms in this homeserver's public directory.", | ||||
|             method: GET, | ||||
|             name: "get_public_rooms", | ||||
|             path: "/_matrix/client/r0/publicRooms", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: false, | ||||
|         } | ||||
| 
 | ||||
|         request {} | ||||
| 
 | ||||
|         response { | ||||
|             /// A pagination token for the response.
 | ||||
|             pub start: String, | ||||
|             /// A paginated chunk of public rooms.
 | ||||
|             pub chunk: Vec<PublicRoomsChunk>, | ||||
|             /// A pagination token for the response.
 | ||||
|             pub end: String | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /// A chunk of the response, describing one room
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct PublicRoomsChunk { | ||||
|         /// Aliases of the room.
 | ||||
|         //#[serde(skip_serializing_if = "Option::is_none")]
 | ||||
|         pub aliases: Option<Vec<RoomAliasId>>, | ||||
|         /// The URL for the room's avatar, if one is set.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub avatar_url: Option<String>, | ||||
|         /// Whether guest users may join the room and participate in it.
 | ||||
|         ///
 | ||||
|         /// If they can, they will be subject to ordinary power level rules like any other user.
 | ||||
|         pub guest_can_join: bool, | ||||
|         /// The name of the room, if any.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub name: Option<String>, | ||||
|         /// The number of members joined to the room.
 | ||||
|         pub num_joined_members: u64, | ||||
|         /// The ID of the room.
 | ||||
|         pub room_id: RoomId, | ||||
|         /// The topic of the room, if any.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub topic: Option<String>, | ||||
|         /// Whether the room may be viewed by guest users without joining.
 | ||||
|         pub world_readable: bool, | ||||
|     } | ||||
| } | ||||
| pub mod get_public_rooms; | ||||
|  | ||||
							
								
								
									
										54
									
								
								src/r0/directory/get_public_rooms.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								src/r0/directory/get_public_rooms.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,54 @@ | ||||
| //! [GET /_matrix/client/r0/publicRooms](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-publicrooms)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::{RoomAliasId, RoomId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Get the list of rooms in this homeserver's public directory.", | ||||
|         method: GET, | ||||
|         name: "get_public_rooms", | ||||
|         path: "/_matrix/client/r0/publicRooms", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: false, | ||||
|     } | ||||
| 
 | ||||
|     request {} | ||||
| 
 | ||||
|     response { | ||||
|         /// A pagination token for the response.
 | ||||
|         pub start: String, | ||||
|         /// A paginated chunk of public rooms.
 | ||||
|         pub chunk: Vec<PublicRoomsChunk>, | ||||
|         /// A pagination token for the response.
 | ||||
|         pub end: String | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// A chunk of the response, describing one room
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct PublicRoomsChunk { | ||||
|     /// Aliases of the room.
 | ||||
|     //#[serde(skip_serializing_if = "Option::is_none")]
 | ||||
|     pub aliases: Option<Vec<RoomAliasId>>, | ||||
|     /// The URL for the room's avatar, if one is set.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub avatar_url: Option<String>, | ||||
|     /// Whether guest users may join the room and participate in it.
 | ||||
|     ///
 | ||||
|     /// If they can, they will be subject to ordinary power level rules like any other user.
 | ||||
|     pub guest_can_join: bool, | ||||
|     /// The name of the room, if any.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub name: Option<String>, | ||||
|     /// The number of members joined to the room.
 | ||||
|     pub num_joined_members: u64, | ||||
|     /// The ID of the room.
 | ||||
|     pub room_id: RoomId, | ||||
|     /// The topic of the room, if any.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub topic: Option<String>, | ||||
|     /// Whether the room may be viewed by guest users without joining.
 | ||||
|     pub world_readable: bool, | ||||
| } | ||||
| @ -1,5 +1,8 @@ | ||||
| //! Endpoints for event filters.
 | ||||
| 
 | ||||
| pub mod create_filter; | ||||
| pub mod get_filter; | ||||
| 
 | ||||
| use ruma_identifiers::{RoomId, UserId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| @ -165,74 +168,3 @@ pub struct FilterDefinition { | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub presence: Option<Filter>, | ||||
| } | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/user/{userId}/filter](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-user-userid-filter)
 | ||||
| pub mod create_filter { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::UserId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     use super::FilterDefinition; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Create a new filter for event retrieval.", | ||||
|             method: POST, | ||||
|             name: "create_filter", | ||||
|             path: "/_matrix/client/r0/user/:user_id/filter", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The filter definition.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub filter: FilterDefinition, | ||||
|             /// The ID of the user uploading the filter.
 | ||||
|             ///
 | ||||
|             /// The access token must be authorized to make requests for this user ID.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: UserId, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// The ID of the filter that was created.
 | ||||
|             pub filter_id: String, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [GET /_matrix/client/r0/user/{userId}/filter/{filterId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-user-userid-filter-filterid)
 | ||||
| pub mod get_filter { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::UserId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     use super::FilterDefinition; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Retrieve a previously created filter.", | ||||
|             method: GET, | ||||
|             name: "get_filter", | ||||
|             path: "/_matrix/client/r0/user/:user_id/filter/:filter_id", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: false, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The ID of the filter to download.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub filter_id: String, | ||||
|             /// The user ID to download a filter for.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: UserId, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// The filter definition.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub filter: FilterDefinition, | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
							
								
								
									
										34
									
								
								src/r0/filter/create_filter.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								src/r0/filter/create_filter.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,34 @@ | ||||
| //! [POST /_matrix/client/r0/user/{userId}/filter](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-user-userid-filter)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::UserId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| use super::FilterDefinition; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Create a new filter for event retrieval.", | ||||
|         method: POST, | ||||
|         name: "create_filter", | ||||
|         path: "/_matrix/client/r0/user/:user_id/filter", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The filter definition.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub filter: FilterDefinition, | ||||
|         /// The ID of the user uploading the filter.
 | ||||
|         ///
 | ||||
|         /// The access token must be authorized to make requests for this user ID.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: UserId, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// The ID of the filter that was created.
 | ||||
|         pub filter_id: String, | ||||
|     } | ||||
| } | ||||
							
								
								
									
										33
									
								
								src/r0/filter/get_filter.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								src/r0/filter/get_filter.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | ||||
| //! [GET /_matrix/client/r0/user/{userId}/filter/{filterId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-user-userid-filter-filterid)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::UserId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| use super::FilterDefinition; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Retrieve a previously created filter.", | ||||
|         method: GET, | ||||
|         name: "get_filter", | ||||
|         path: "/_matrix/client/r0/user/:user_id/filter/:filter_id", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: false, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The ID of the filter to download.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub filter_id: String, | ||||
|         /// The user ID to download a filter for.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: UserId, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// The filter definition.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub filter: FilterDefinition, | ||||
|     } | ||||
| } | ||||
							
								
								
									
										122
									
								
								src/r0/media.rs
									
									
									
									
									
								
							
							
						
						
									
										122
									
								
								src/r0/media.rs
									
									
									
									
									
								
							| @ -1,121 +1,5 @@ | ||||
| //! Endpoints for the media repository.
 | ||||
| 
 | ||||
| /// [GET /_matrix/media/r0/download/{serverName}/{mediaId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-media-r0-download-servername-mediaid)
 | ||||
| pub mod get_content { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Retrieve content from the media store.", | ||||
|             method: GET, | ||||
|             name: "get_media_content", | ||||
|             path: "/_matrix/media/r0/download/:server_name/:media_id", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: false, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The media ID from the mxc:// URI (the path component).
 | ||||
|             #[ruma_api(path)] | ||||
|             pub media_id: String, | ||||
|             /// The server name from the mxc:// URI (the authoritory component).
 | ||||
|             #[ruma_api(path)] | ||||
|             pub server_name: String, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// The content that was previously uploaded.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub file: Vec<u8>, | ||||
|             /// The content type of the file that was previously uploaded.
 | ||||
|             #[ruma_api(header = "CONTENT_TYPE")] | ||||
|             pub content_type: String, | ||||
|             /// The name of the file that was previously uploaded, if set.
 | ||||
|             #[ruma_api(header = "CONTENT_DISPOSITION")] | ||||
|             pub content_disposition: String, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [POST /_matrix/media/r0/upload](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-media-r0-upload)
 | ||||
| pub mod create_content { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Upload content to the media store.", | ||||
|             method: POST, | ||||
|             name: "create_media_content", | ||||
|             path: "/_matrix/media/r0/upload", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: false, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The content type of the file being uploaded.
 | ||||
|             #[ruma_api(header = "CONTENT_TYPE")] | ||||
|             pub content_type: String, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// The MXC URI for the uploaded content.
 | ||||
|             pub content_uri: String, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [GET /_matrix/media/r0/thumbnail/{serverName}/{mediaId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-media-r0-thumbnail-servername-mediaid)
 | ||||
| pub mod get_content_thumbnail { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     /// The desired resizing method.
 | ||||
|     #[derive(Clone, Copy, Debug, Deserialize, Serialize)] | ||||
|     pub enum Method { | ||||
|         /// Crop the original to produce the requested image dimensions.
 | ||||
|         #[serde(rename = "crop")] | ||||
|         Crop, | ||||
|         /// Maintain the original aspect ratio of the source image.
 | ||||
|         #[serde(rename = "scale")] | ||||
|         Scale, | ||||
|     } | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Get a thumbnail of content from the media store.", | ||||
|             method: GET, | ||||
|             name: "get_content_thumbnail", | ||||
|             path: "/_matrix/media/r0/thumbnail/:server_name/:media_id", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: false, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The media ID from the mxc:// URI (the path component).
 | ||||
|             #[ruma_api(path)] | ||||
|             pub media_id: String, | ||||
|             /// The server name from the mxc:// URI (the authoritory component).
 | ||||
|             #[ruma_api(path)] | ||||
|             pub server_name: String, | ||||
|             /// The *desired* height of the thumbnail. The actual thumbnail may not match the size
 | ||||
|             /// specified.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub height: Option<u64>, | ||||
|             /// The desired resizing method.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub method: Option<Method>, | ||||
|             /// The *desired* width of the thumbnail. The actual thumbnail may not match the size
 | ||||
|             /// specified.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub width: Option<u64>, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// A thumbnail of the requested content.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub file: Vec<u8>, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| pub mod create_content; | ||||
| pub mod get_content; | ||||
| pub mod get_content_thumbnail; | ||||
|  | ||||
							
								
								
									
										26
									
								
								src/r0/media/create_content.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/r0/media/create_content.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,26 @@ | ||||
| //! [POST /_matrix/media/r0/upload](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-media-r0-upload)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Upload content to the media store.", | ||||
|         method: POST, | ||||
|         name: "create_media_content", | ||||
|         path: "/_matrix/media/r0/upload", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: false, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The content type of the file being uploaded.
 | ||||
|         #[ruma_api(header = "CONTENT_TYPE")] | ||||
|         pub content_type: String, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// The MXC URI for the uploaded content.
 | ||||
|         pub content_uri: String, | ||||
|     } | ||||
| } | ||||
							
								
								
									
										38
									
								
								src/r0/media/get_content.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								src/r0/media/get_content.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,38 @@ | ||||
| //! Endpoints for the media repository.
 | ||||
| 
 | ||||
| //! [GET /_matrix/media/r0/download/{serverName}/{mediaId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-media-r0-download-servername-mediaid)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Retrieve content from the media store.", | ||||
|         method: GET, | ||||
|         name: "get_media_content", | ||||
|         path: "/_matrix/media/r0/download/:server_name/:media_id", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: false, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The media ID from the mxc:// URI (the path component).
 | ||||
|         #[ruma_api(path)] | ||||
|         pub media_id: String, | ||||
|         /// The server name from the mxc:// URI (the authoritory component).
 | ||||
|         #[ruma_api(path)] | ||||
|         pub server_name: String, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// The content that was previously uploaded.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub file: Vec<u8>, | ||||
|         /// The content type of the file that was previously uploaded.
 | ||||
|         #[ruma_api(header = "CONTENT_TYPE")] | ||||
|         pub content_type: String, | ||||
|         /// The name of the file that was previously uploaded, if set.
 | ||||
|         #[ruma_api(header = "CONTENT_DISPOSITION")] | ||||
|         pub content_disposition: String, | ||||
|     } | ||||
| } | ||||
							
								
								
									
										52
									
								
								src/r0/media/get_content_thumbnail.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								src/r0/media/get_content_thumbnail.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,52 @@ | ||||
| //! [GET /_matrix/media/r0/thumbnail/{serverName}/{mediaId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-media-r0-thumbnail-servername-mediaid)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| /// The desired resizing method.
 | ||||
| #[derive(Clone, Copy, Debug, Deserialize, Serialize)] | ||||
| pub enum Method { | ||||
|     /// Crop the original to produce the requested image dimensions.
 | ||||
|     #[serde(rename = "crop")] | ||||
|     Crop, | ||||
|     /// Maintain the original aspect ratio of the source image.
 | ||||
|     #[serde(rename = "scale")] | ||||
|     Scale, | ||||
| } | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Get a thumbnail of content from the media store.", | ||||
|         method: GET, | ||||
|         name: "get_content_thumbnail", | ||||
|         path: "/_matrix/media/r0/thumbnail/:server_name/:media_id", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: false, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The media ID from the mxc:// URI (the path component).
 | ||||
|         #[ruma_api(path)] | ||||
|         pub media_id: String, | ||||
|         /// The server name from the mxc:// URI (the authoritory component).
 | ||||
|         #[ruma_api(path)] | ||||
|         pub server_name: String, | ||||
|         /// The *desired* height of the thumbnail. The actual thumbnail may not match the size
 | ||||
|         /// specified.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub height: Option<u64>, | ||||
|         /// The desired resizing method.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub method: Option<Method>, | ||||
|         /// The *desired* width of the thumbnail. The actual thumbnail may not match the size
 | ||||
|         /// specified.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub width: Option<u64>, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// A thumbnail of the requested content.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub file: Vec<u8>, | ||||
|     } | ||||
| } | ||||
| @ -1,5 +1,14 @@ | ||||
| //! Endpoints for room membership.
 | ||||
| 
 | ||||
| pub mod ban_user; | ||||
| pub mod forget_room; | ||||
| pub mod invite_user; | ||||
| pub mod join_room_by_id; | ||||
| pub mod join_room_by_id_or_alias; | ||||
| pub mod kick_user; | ||||
| pub mod leave_room; | ||||
| pub mod unban_user; | ||||
| 
 | ||||
| use ruma_signatures::Signatures; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| @ -19,243 +28,3 @@ pub struct ThirdPartySigned { | ||||
|     /// The state key of the m.third_party_invite event.
 | ||||
|     pub token: String, | ||||
| } | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/rooms/{roomId}/invite](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-invite)
 | ||||
| pub mod invite_user { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::{RoomId, UserId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Invite a user to a room.", | ||||
|             method: POST, | ||||
|             name: "invite_user", | ||||
|             path: "/_matrix/client/r0/rooms/:room_id/invite", | ||||
|             rate_limited: true, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room where the user should be invited.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|             /// The user to invite.
 | ||||
|             pub user_id: UserId, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/join/{roomIdOrAlias}](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-join-roomidoralias)
 | ||||
| pub mod join_room_by_id_or_alias { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::{RoomId, RoomIdOrAliasId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     use super::ThirdPartySigned; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Join a room using its ID or one of its aliases.", | ||||
|             method: POST, | ||||
|             name: "join_room_by_id_or_alias", | ||||
|             path: "/_matrix/client/r0/join/:room_id_or_alias", | ||||
|             rate_limited: true, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room where the user should be invited.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id_or_alias: RoomIdOrAliasId, | ||||
|             /// The signature of a `m.third_party_invite` token to prove that this user owns a third
 | ||||
|             /// party identity which has been invited to the room.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub third_party_signed: Option<ThirdPartySigned>, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// The room that the user joined.
 | ||||
|             pub room_id: RoomId, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/rooms/{roomId}/join](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-join)
 | ||||
| pub mod join_room_by_id { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::RoomId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     use super::ThirdPartySigned; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Join a room using its ID.", | ||||
|             method: POST, | ||||
|             name: "join_room_by_id", | ||||
|             path: "/_matrix/client/r0/rooms/:room_id/join", | ||||
|             rate_limited: true, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room where the user should be invited.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|             /// The signature of a `m.third_party_invite` token to prove that this user owns a third
 | ||||
|             /// party identity which has been invited to the room.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub third_party_signed: Option<ThirdPartySigned>, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// The room that the user joined.
 | ||||
|             pub room_id: RoomId, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/rooms/{roomId}/forget](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-forget)
 | ||||
| pub mod forget_room { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::RoomId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Forget a room.", | ||||
|             method: POST, | ||||
|             name: "forget_room", | ||||
|             path: "/_matrix/client/r0/rooms/:room_id/forget", | ||||
|             rate_limited: true, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room to forget.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/rooms/{roomId}/leave](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-leave)
 | ||||
| pub mod leave_room { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::RoomId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Leave a room.", | ||||
|             method: POST, | ||||
|             name: "leave_room", | ||||
|             path: "/_matrix/client/r0/rooms/:room_id/leave", | ||||
|             rate_limited: true, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room to leave.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/rooms/{roomId}/kick](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-kick)
 | ||||
| pub mod kick_user { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::{RoomId, UserId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Kick a user from a room.", | ||||
|             method: POST, | ||||
|             name: "kick_user", | ||||
|             path: "/_matrix/client/r0/rooms/:room_id/kick", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The reason for kicking the user.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub reason: Option<String>, | ||||
|             /// The room to kick the user from.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|             /// The user to kick.
 | ||||
|             pub user_id: UserId, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/rooms/{roomId}/unban](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-unban)
 | ||||
| pub mod unban_user { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::{RoomId, UserId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Unban a user from a room.", | ||||
|             method: POST, | ||||
|             name: "unban_user", | ||||
|             path: "/_matrix/client/r0/rooms/:room_id/unban", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room to unban the user from.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|             /// The user to unban.
 | ||||
|             pub user_id: UserId, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/rooms/{roomId}/ban](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-ban)
 | ||||
| pub mod ban_user { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::{RoomId, UserId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Ban a user from a room.", | ||||
|             method: POST, | ||||
|             name: "ban_user", | ||||
|             path: "/_matrix/client/r0/rooms/:room_id/ban", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The reason for banning the user.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub reason: Option<String>, | ||||
|             /// The room to kick the user from.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|             /// The user to ban.
 | ||||
|             pub user_id: UserId, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
|  | ||||
							
								
								
									
										29
									
								
								src/r0/membership/ban_user.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/r0/membership/ban_user.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | ||||
| //! [POST /_matrix/client/r0/rooms/{roomId}/ban](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-ban)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::{RoomId, UserId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Ban a user from a room.", | ||||
|         method: POST, | ||||
|         name: "ban_user", | ||||
|         path: "/_matrix/client/r0/rooms/:room_id/ban", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The reason for banning the user.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub reason: Option<String>, | ||||
|         /// The room to kick the user from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|         /// The user to ban.
 | ||||
|         pub user_id: UserId, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
							
								
								
									
										24
									
								
								src/r0/membership/forget_room.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								src/r0/membership/forget_room.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,24 @@ | ||||
| //! [POST /_matrix/client/r0/rooms/{roomId}/forget](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-forget)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::RoomId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Forget a room.", | ||||
|         method: POST, | ||||
|         name: "forget_room", | ||||
|         path: "/_matrix/client/r0/rooms/:room_id/forget", | ||||
|         rate_limited: true, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room to forget.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
							
								
								
									
										26
									
								
								src/r0/membership/invite_user.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/r0/membership/invite_user.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,26 @@ | ||||
| //! [POST /_matrix/client/r0/rooms/{roomId}/invite](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-invite)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::{RoomId, UserId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Invite a user to a room.", | ||||
|         method: POST, | ||||
|         name: "invite_user", | ||||
|         path: "/_matrix/client/r0/rooms/:room_id/invite", | ||||
|         rate_limited: true, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room where the user should be invited.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|         /// The user to invite.
 | ||||
|         pub user_id: UserId, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
							
								
								
									
										33
									
								
								src/r0/membership/join_room_by_id.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								src/r0/membership/join_room_by_id.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | ||||
| //! [POST /_matrix/client/r0/rooms/{roomId}/join](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-join)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::RoomId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| use super::ThirdPartySigned; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Join a room using its ID.", | ||||
|         method: POST, | ||||
|         name: "join_room_by_id", | ||||
|         path: "/_matrix/client/r0/rooms/:room_id/join", | ||||
|         rate_limited: true, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room where the user should be invited.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|         /// The signature of a `m.third_party_invite` token to prove that this user owns a third
 | ||||
|         /// party identity which has been invited to the room.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub third_party_signed: Option<ThirdPartySigned>, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// The room that the user joined.
 | ||||
|         pub room_id: RoomId, | ||||
|     } | ||||
| } | ||||
							
								
								
									
										33
									
								
								src/r0/membership/join_room_by_id_or_alias.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								src/r0/membership/join_room_by_id_or_alias.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | ||||
| //! [POST /_matrix/client/r0/join/{roomIdOrAlias}](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-join-roomidoralias)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::{RoomId, RoomIdOrAliasId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| use super::ThirdPartySigned; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Join a room using its ID or one of its aliases.", | ||||
|         method: POST, | ||||
|         name: "join_room_by_id_or_alias", | ||||
|         path: "/_matrix/client/r0/join/:room_id_or_alias", | ||||
|         rate_limited: true, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room where the user should be invited.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id_or_alias: RoomIdOrAliasId, | ||||
|         /// The signature of a `m.third_party_invite` token to prove that this user owns a third
 | ||||
|         /// party identity which has been invited to the room.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub third_party_signed: Option<ThirdPartySigned>, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// The room that the user joined.
 | ||||
|         pub room_id: RoomId, | ||||
|     } | ||||
| } | ||||
							
								
								
									
										29
									
								
								src/r0/membership/kick_user.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/r0/membership/kick_user.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | ||||
| //! [POST /_matrix/client/r0/rooms/{roomId}/kick](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-kick)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::{RoomId, UserId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Kick a user from a room.", | ||||
|         method: POST, | ||||
|         name: "kick_user", | ||||
|         path: "/_matrix/client/r0/rooms/:room_id/kick", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The reason for kicking the user.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub reason: Option<String>, | ||||
|         /// The room to kick the user from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|         /// The user to kick.
 | ||||
|         pub user_id: UserId, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
							
								
								
									
										24
									
								
								src/r0/membership/leave_room.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								src/r0/membership/leave_room.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,24 @@ | ||||
| //! [POST /_matrix/client/r0/rooms/{roomId}/leave](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-leave)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::RoomId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Leave a room.", | ||||
|         method: POST, | ||||
|         name: "leave_room", | ||||
|         path: "/_matrix/client/r0/rooms/:room_id/leave", | ||||
|         rate_limited: true, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room to leave.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
							
								
								
									
										26
									
								
								src/r0/membership/unban_user.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/r0/membership/unban_user.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,26 @@ | ||||
| //! [POST /_matrix/client/r0/rooms/{roomId}/unban](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-unban)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::{RoomId, UserId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Unban a user from a room.", | ||||
|         method: POST, | ||||
|         name: "unban_user", | ||||
|         path: "/_matrix/client/r0/rooms/:room_id/unban", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room to unban the user from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|         /// The user to unban.
 | ||||
|         pub user_id: UserId, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
| @ -1,137 +1,6 @@ | ||||
| //! Endpoints for user presence.
 | ||||
| 
 | ||||
| /// [PUT /_matrix/client/r0/presence/{userId}/status](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-presence-userid-status)
 | ||||
| pub mod set_presence { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_events::presence::PresenceState; | ||||
|     use ruma_identifiers::UserId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Set presence status for this user.", | ||||
|             method: PUT, | ||||
|             name: "set_presence", | ||||
|             path: "/_matrix/client/r0/presence/:user_id/status", | ||||
|             rate_limited: true, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The new presence state.
 | ||||
|             pub presence: PresenceState, | ||||
|             /// The status message to attach to this state.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub status_msg: Option<String>, | ||||
|             /// The user whose presence state will be updated.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: UserId, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [GET /_matrix/client/r0/presence/{userId}/status](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-presence-userid-status)
 | ||||
| pub mod get_presence { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_events::presence::PresenceState; | ||||
|     use ruma_identifiers::UserId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Get presence status for this user.", | ||||
|             method: GET, | ||||
|             name: "get_presence", | ||||
|             path: "/_matrix/client/r0/presence/:user_id/status", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: false, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The user whose presence state will be retrieved.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: UserId, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// The state message for this user if one was set.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub status_msg: Option<String>, | ||||
|             /// Whether or not the user is currently active.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub currently_active: Option<bool>, | ||||
|             /// The length of time in milliseconds since an action was performed by the user.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub last_active_ago: Option<u64>, | ||||
|             /// The user's presence state.
 | ||||
|             pub presence: PresenceState, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/presence/list/{userId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-presence-list-userid)
 | ||||
| pub mod update_presence_subscriptions { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::UserId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Update the presence subscriptions of the user.", | ||||
|             method: POST, | ||||
|             name: "update_presence_subscriptions", | ||||
|             path: "/_matrix/client/r0/presence/list/:user_id", | ||||
|             rate_limited: true, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// A list of user IDs to remove from the list.
 | ||||
|             #[serde(skip_serializing_if = "Vec::is_empty")] | ||||
|             #[serde(default)] | ||||
|             pub drop: Vec<UserId>, | ||||
|             /// A list of user IDs to add to the list.
 | ||||
|             #[serde(skip_serializing_if = "Vec::is_empty")] | ||||
|             #[serde(default)] | ||||
|             pub invite: Vec<UserId>, | ||||
|             /// The user whose presence state will be updated.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: UserId, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [GET /_matrix/client/r0/presence/list/{userId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-presence-list-userid)
 | ||||
| pub mod get_subscribed_presences { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_events::presence::PresenceEvent; | ||||
|     use ruma_identifiers::UserId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Get the precence status from the user's subscriptions.", | ||||
|             method: GET, | ||||
|             name: "get_subscribed_presences", | ||||
|             path: "/_matrix/client/r0/presence/list/:user_id", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The user whose presence state will be retrieved.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: UserId, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// A list of presence events for every user on this list.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub presence_events: Vec<PresenceEvent>, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| pub mod get_presence; | ||||
| pub mod get_subscribed_presences; | ||||
| pub mod set_presence; | ||||
| pub mod update_presence_subscriptions; | ||||
|  | ||||
							
								
								
									
										37
									
								
								src/r0/presence/get_presence.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/r0/presence/get_presence.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,37 @@ | ||||
| //! [GET /_matrix/client/r0/presence/{userId}/status](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-presence-userid-status)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_events::presence::PresenceState; | ||||
| use ruma_identifiers::UserId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Get presence status for this user.", | ||||
|         method: GET, | ||||
|         name: "get_presence", | ||||
|         path: "/_matrix/client/r0/presence/:user_id/status", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: false, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The user whose presence state will be retrieved.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: UserId, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// The state message for this user if one was set.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub status_msg: Option<String>, | ||||
|         /// Whether or not the user is currently active.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub currently_active: Option<bool>, | ||||
|         /// The length of time in milliseconds since an action was performed by the user.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub last_active_ago: Option<u64>, | ||||
|         /// The user's presence state.
 | ||||
|         pub presence: PresenceState, | ||||
|     } | ||||
| } | ||||
							
								
								
									
										29
									
								
								src/r0/presence/get_subscribed_presences.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								src/r0/presence/get_subscribed_presences.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | ||||
| //! [GET /_matrix/client/r0/presence/list/{userId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-presence-list-userid)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_events::presence::PresenceEvent; | ||||
| use ruma_identifiers::UserId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Get the precence status from the user's subscriptions.", | ||||
|         method: GET, | ||||
|         name: "get_subscribed_presences", | ||||
|         path: "/_matrix/client/r0/presence/list/:user_id", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The user whose presence state will be retrieved.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: UserId, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// A list of presence events for every user on this list.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub presence_events: Vec<PresenceEvent>, | ||||
|     } | ||||
| } | ||||
							
								
								
									
										30
									
								
								src/r0/presence/set_presence.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/r0/presence/set_presence.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | ||||
| //! [PUT /_matrix/client/r0/presence/{userId}/status](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-presence-userid-status)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_events::presence::PresenceState; | ||||
| use ruma_identifiers::UserId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Set presence status for this user.", | ||||
|         method: PUT, | ||||
|         name: "set_presence", | ||||
|         path: "/_matrix/client/r0/presence/:user_id/status", | ||||
|         rate_limited: true, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The new presence state.
 | ||||
|         pub presence: PresenceState, | ||||
|         /// The status message to attach to this state.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub status_msg: Option<String>, | ||||
|         /// The user whose presence state will be updated.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: UserId, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
							
								
								
									
										32
									
								
								src/r0/presence/update_presence_subscriptions.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/r0/presence/update_presence_subscriptions.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | ||||
| //! [POST /_matrix/client/r0/presence/list/{userId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-presence-list-userid)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::UserId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Update the presence subscriptions of the user.", | ||||
|         method: POST, | ||||
|         name: "update_presence_subscriptions", | ||||
|         path: "/_matrix/client/r0/presence/list/:user_id", | ||||
|         rate_limited: true, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// A list of user IDs to remove from the list.
 | ||||
|         #[serde(skip_serializing_if = "Vec::is_empty")] | ||||
|         #[serde(default)] | ||||
|         pub drop: Vec<UserId>, | ||||
|         /// A list of user IDs to add to the list.
 | ||||
|         #[serde(skip_serializing_if = "Vec::is_empty")] | ||||
|         #[serde(default)] | ||||
|         pub invite: Vec<UserId>, | ||||
|         /// The user whose presence state will be updated.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: UserId, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
| @ -1,151 +1,7 @@ | ||||
| //! Endpoints for user profiles.
 | ||||
| 
 | ||||
| /// [GET /_matrix/client/r0/profile/{userId}/displayname](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-profile-userid-displayname)
 | ||||
| pub mod get_display_name { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::UserId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Get the display name of a user.", | ||||
|             method: GET, | ||||
|             name: "get_display_name", | ||||
|             path: "/_matrix/client/r0/profile/:user_id/displayname", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: false, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The user whose display name will be retrieved.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: UserId | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// The user's display name, if set.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub displayname: Option<String> | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [PUT /_matrix/client/r0/profile/{userId}/displayname](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-profile-userid-displayname)
 | ||||
| pub mod set_display_name { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::UserId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Set the display name of the user.", | ||||
|             method: PUT, | ||||
|             name: "set_display_name", | ||||
|             path: "/_matrix/client/r0/profile/:user_id/displayname", | ||||
|             rate_limited: true, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The new display name for the user.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub displayname: Option<String>, | ||||
|             /// The user whose display name will be set.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: UserId, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [GET /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-profile-userid-avatar-url)
 | ||||
| pub mod get_avatar_url { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::UserId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Get the avatar URL of a user.", | ||||
|             method: GET, | ||||
|             name: "get_avatar_url", | ||||
|             path: "/_matrix/client/r0/profile/:user_id/avatar_url", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: false, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The user whose avatar URL will be retrieved.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: UserId | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// The user's avatar URL, if set.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub avatar_url: Option<String> | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [PUT /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-profile-userid-avatar-url)
 | ||||
| pub mod set_avatar_url { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::UserId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Set the avatar URL of the user.", | ||||
|             method: PUT, | ||||
|             name: "set_avatar_url", | ||||
|             path: "/_matrix/client/r0/profile/:user_id/avatar_url", | ||||
|             rate_limited: true, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The new avatar URL for the user.
 | ||||
|             pub avatar_url: String, | ||||
|             /// The user whose avatar URL will be set.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: UserId | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [GET /_matrix/client/r0/profile/{userId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-profile-userid)
 | ||||
| pub mod get_profile { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::UserId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Get all profile information of an user.", | ||||
|             method: GET, | ||||
|             name: "get_profile", | ||||
|             path: "/_matrix/client/r0/profile/:user_id", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: false, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The user whose profile will be retrieved.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: UserId, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// The user's avatar URL, if set.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub avatar_url: Option<String>, | ||||
|             /// The user's display name, if set.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub displayname: Option<String>, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| pub mod get_avatar_url; | ||||
| pub mod get_display_name; | ||||
| pub mod get_profile; | ||||
| pub mod set_avatar_url; | ||||
| pub mod set_display_name; | ||||
|  | ||||
							
								
								
									
										28
									
								
								src/r0/profile/get_avatar_url.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/r0/profile/get_avatar_url.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,28 @@ | ||||
| //! [GET /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-profile-userid-avatar-url)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::UserId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Get the avatar URL of a user.", | ||||
|         method: GET, | ||||
|         name: "get_avatar_url", | ||||
|         path: "/_matrix/client/r0/profile/:user_id/avatar_url", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: false, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The user whose avatar URL will be retrieved.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: UserId | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// The user's avatar URL, if set.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub avatar_url: Option<String> | ||||
|     } | ||||
| } | ||||
							
								
								
									
										28
									
								
								src/r0/profile/get_display_name.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/r0/profile/get_display_name.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,28 @@ | ||||
| //! [GET /_matrix/client/r0/profile/{userId}/displayname](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-profile-userid-displayname)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::UserId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Get the display name of a user.", | ||||
|         method: GET, | ||||
|         name: "get_display_name", | ||||
|         path: "/_matrix/client/r0/profile/:user_id/displayname", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: false, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The user whose display name will be retrieved.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: UserId | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// The user's display name, if set.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub displayname: Option<String> | ||||
|     } | ||||
| } | ||||
							
								
								
									
										31
									
								
								src/r0/profile/get_profile.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/r0/profile/get_profile.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | ||||
| //! [GET /_matrix/client/r0/profile/{userId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-profile-userid)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::UserId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Get all profile information of an user.", | ||||
|         method: GET, | ||||
|         name: "get_profile", | ||||
|         path: "/_matrix/client/r0/profile/:user_id", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: false, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The user whose profile will be retrieved.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: UserId, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// The user's avatar URL, if set.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub avatar_url: Option<String>, | ||||
|         /// The user's display name, if set.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub displayname: Option<String>, | ||||
|     } | ||||
| } | ||||
							
								
								
									
										26
									
								
								src/r0/profile/set_avatar_url.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/r0/profile/set_avatar_url.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,26 @@ | ||||
| //! [PUT /_matrix/client/r0/profile/{userId}/avatar_url](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-profile-userid-avatar-url)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::UserId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Set the avatar URL of the user.", | ||||
|         method: PUT, | ||||
|         name: "set_avatar_url", | ||||
|         path: "/_matrix/client/r0/profile/:user_id/avatar_url", | ||||
|         rate_limited: true, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The new avatar URL for the user.
 | ||||
|         pub avatar_url: String, | ||||
|         /// The user whose avatar URL will be set.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: UserId | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
							
								
								
									
										27
									
								
								src/r0/profile/set_display_name.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/r0/profile/set_display_name.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | ||||
| //! [PUT /_matrix/client/r0/profile/{userId}/displayname](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-profile-userid-displayname)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::UserId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Set the display name of the user.", | ||||
|         method: PUT, | ||||
|         name: "set_display_name", | ||||
|         path: "/_matrix/client/r0/profile/:user_id/displayname", | ||||
|         rate_limited: true, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The new display name for the user.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub displayname: Option<String>, | ||||
|         /// The user whose display name will be set.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: UserId, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
| @ -1,51 +1,3 @@ | ||||
| //! Endpoints for event receipts.
 | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/rooms/{roomId}/receipt/{receiptType}/{eventId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-receipt-receipttype-eventid)
 | ||||
| pub mod create_receipt { | ||||
|     use std::fmt::{Display, Error as FmtError, Formatter}; | ||||
| 
 | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::{EventId, RoomId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Send a receipt event to a room.", | ||||
|             method: POST, | ||||
|             name: "create_receipt", | ||||
|             path: "/_matrix/client/r0/rooms/:room_id/receipt/:receipt_type/:event_id", | ||||
|             rate_limited: true, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The event ID to acknowledge up to.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub event_id: EventId, | ||||
|             /// The type of receipt to send.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub receipt_type: ReceiptType, | ||||
|             /// The room in which to send the event.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| 
 | ||||
|     /// The type of receipt.
 | ||||
|     #[derive(Clone, Copy, Debug, Deserialize, Serialize)] | ||||
|     pub enum ReceiptType { | ||||
|         /// m.read
 | ||||
|         #[serde(rename = "m.read")] | ||||
|         Read, | ||||
|     } | ||||
| 
 | ||||
|     impl Display for ReceiptType { | ||||
|         fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { | ||||
|             match *self { | ||||
|                 ReceiptType::Read => write!(f, "m.read"), | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| pub mod create_receipt; | ||||
|  | ||||
							
								
								
									
										48
									
								
								src/r0/receipt/create_receipt.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								src/r0/receipt/create_receipt.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,48 @@ | ||||
| //! [POST /_matrix/client/r0/rooms/{roomId}/receipt/{receiptType}/{eventId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-rooms-roomid-receipt-receipttype-eventid)
 | ||||
| 
 | ||||
| use std::fmt::{Display, Error as FmtError, Formatter}; | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::{EventId, RoomId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Send a receipt event to a room.", | ||||
|         method: POST, | ||||
|         name: "create_receipt", | ||||
|         path: "/_matrix/client/r0/rooms/:room_id/receipt/:receipt_type/:event_id", | ||||
|         rate_limited: true, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The event ID to acknowledge up to.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub event_id: EventId, | ||||
|         /// The type of receipt to send.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub receipt_type: ReceiptType, | ||||
|         /// The room in which to send the event.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
| 
 | ||||
| /// The type of receipt.
 | ||||
| #[derive(Clone, Copy, Debug, Deserialize, Serialize)] | ||||
| pub enum ReceiptType { | ||||
|     /// m.read
 | ||||
|     #[serde(rename = "m.read")] | ||||
|     Read, | ||||
| } | ||||
| 
 | ||||
| impl Display for ReceiptType { | ||||
|     fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FmtError> { | ||||
|         match *self { | ||||
|             ReceiptType::Read => write!(f, "m.read"), | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -1,41 +1,3 @@ | ||||
| //! Endpoints for event redaction.
 | ||||
| 
 | ||||
| /// [PUT /_matrix/client/r0/rooms/{roomId}/redact/{eventId}/{txnId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-redact-eventid-txnid)
 | ||||
| pub mod redact_event { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::{EventId, RoomId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Redact an event, stripping all information not critical to the event graph integrity.", | ||||
|             method: PUT, | ||||
|             name: "redact_event", | ||||
|             path: "/_matrix/client/r0/rooms/:room_id/redact/:event_id/:txn_id", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The ID of the event to redact.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub event_id: EventId, | ||||
|             /// The reason for the redaction.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub reason: Option<String>, | ||||
|             /// The ID of the room of the event to redact.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|             /// The transaction ID for this event.
 | ||||
|             ///
 | ||||
|             /// Clients should generate a unique ID; it will be used by the server to ensure idempotency of requests.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub txn_id: String, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// The ID of the redacted event.
 | ||||
|             pub event_id: EventId, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| pub mod redact_event; | ||||
|  | ||||
							
								
								
									
										38
									
								
								src/r0/redact/redact_event.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								src/r0/redact/redact_event.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,38 @@ | ||||
| //! [PUT /_matrix/client/r0/rooms/{roomId}/redact/{eventId}/{txnId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-redact-eventid-txnid)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::{EventId, RoomId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Redact an event, stripping all information not critical to the event graph integrity.", | ||||
|         method: PUT, | ||||
|         name: "redact_event", | ||||
|         path: "/_matrix/client/r0/rooms/:room_id/redact/:event_id/:txn_id", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The ID of the event to redact.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub event_id: EventId, | ||||
|         /// The reason for the redaction.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub reason: Option<String>, | ||||
|         /// The ID of the room of the event to redact.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|         /// The transaction ID for this event.
 | ||||
|         ///
 | ||||
|         /// Clients should generate a unique ID; it will be used by the server to ensure idempotency of requests.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub txn_id: String, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// The ID of the redacted event.
 | ||||
|         pub event_id: EventId, | ||||
|     } | ||||
| } | ||||
| @ -1,92 +1,3 @@ | ||||
| //! Endpoints for room creation.
 | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/createRoom](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-createroom)
 | ||||
| pub mod create_room { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::{RoomId, UserId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Create a new room.", | ||||
|             method: POST, | ||||
|             name: "create_room", | ||||
|             path: "/_matrix/client/r0/createRoom", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// Extra keys to be added to the content of the `m.room.create`.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub creation_content: Option<CreationContent>, | ||||
|             /// A list of user IDs to invite to the room.
 | ||||
|             ///
 | ||||
|             /// This will tell the server to invite everyone in the list to the newly created room.
 | ||||
|             #[serde(skip_serializing_if = "Vec::is_empty")] | ||||
|             #[serde(default)] | ||||
|             pub invite: Vec<UserId>, | ||||
|             /// If this is included, an `m.room.name` event will be sent into the room to indicate
 | ||||
|             /// the name of the room.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub name: Option<String>, | ||||
|             /// Convenience parameter for setting various default state events based on a preset.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub preset: Option<RoomPreset>, | ||||
|             /// The desired room alias local part.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub room_alias_name: Option<String>, | ||||
|             /// If this is included, an `m.room.topic` event will be sent into the room to indicate
 | ||||
|             /// the topic for the room.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub topic: Option<String>, | ||||
|             /// A public visibility indicates that the room will be shown in the published room
 | ||||
|             /// list. A private visibility will hide the room from the published room list. Rooms
 | ||||
|             /// default to private visibility if this key is not included.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub visibility: Option<Visibility>, | ||||
|             // TODO: missing `invite_3pid`, `initial_state`
 | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// The created room's ID.
 | ||||
|             pub room_id: RoomId, | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /// Extra options to be added to the `m.room.create` event.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct CreationContent { | ||||
|         /// Whether users on other servers can join this room.
 | ||||
|         ///
 | ||||
|         /// Defaults to `true` if key does not exist.
 | ||||
|         #[serde(rename = "m.federate")] | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub federate: Option<bool>, | ||||
|     } | ||||
| 
 | ||||
|     /// A convenience parameter for setting a few default state events.
 | ||||
|     #[derive(Clone, Copy, Debug, Deserialize, Serialize)] | ||||
|     pub enum RoomPreset { | ||||
|         /// `join_rules` is set to `invite` and `history_visibility` is set to `shared`.
 | ||||
|         #[serde(rename = "private_chat")] | ||||
|         PrivateChat, | ||||
|         /// `join_rules` is set to `public` and `history_visibility` is set to `shared`.
 | ||||
|         #[serde(rename = "public_chat")] | ||||
|         PublicChat, | ||||
|         /// Same as `PrivateChat`, but all initial invitees get the same power level as the creator.
 | ||||
|         #[serde(rename = "trusted_private_chat")] | ||||
|         TrustedPrivateChat, | ||||
|     } | ||||
| 
 | ||||
|     /// Whether or not a newly created room will be listed in the room directory.
 | ||||
|     #[derive(Clone, Copy, Debug, Deserialize, Serialize)] | ||||
|     pub enum Visibility { | ||||
|         /// Indicates that the room will be shown in the published room list.
 | ||||
|         #[serde(rename = "public")] | ||||
|         Public, | ||||
|         /// Indicates that the room from the published room list.
 | ||||
|         #[serde(rename = "private")] | ||||
|         Private, | ||||
|     } | ||||
| } | ||||
| pub mod create_room; | ||||
|  | ||||
							
								
								
									
										89
									
								
								src/r0/room/create_room.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								src/r0/room/create_room.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,89 @@ | ||||
| //! [POST /_matrix/client/r0/createRoom](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-createroom)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::{RoomId, UserId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Create a new room.", | ||||
|         method: POST, | ||||
|         name: "create_room", | ||||
|         path: "/_matrix/client/r0/createRoom", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// Extra keys to be added to the content of the `m.room.create`.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub creation_content: Option<CreationContent>, | ||||
|         /// A list of user IDs to invite to the room.
 | ||||
|         ///
 | ||||
|         /// This will tell the server to invite everyone in the list to the newly created room.
 | ||||
|         #[serde(skip_serializing_if = "Vec::is_empty")] | ||||
|         #[serde(default)] | ||||
|         pub invite: Vec<UserId>, | ||||
|         /// If this is included, an `m.room.name` event will be sent into the room to indicate
 | ||||
|         /// the name of the room.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub name: Option<String>, | ||||
|         /// Convenience parameter for setting various default state events based on a preset.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub preset: Option<RoomPreset>, | ||||
|         /// The desired room alias local part.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub room_alias_name: Option<String>, | ||||
|         /// If this is included, an `m.room.topic` event will be sent into the room to indicate
 | ||||
|         /// the topic for the room.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub topic: Option<String>, | ||||
|         /// A public visibility indicates that the room will be shown in the published room
 | ||||
|         /// list. A private visibility will hide the room from the published room list. Rooms
 | ||||
|         /// default to private visibility if this key is not included.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub visibility: Option<Visibility>, | ||||
|         // TODO: missing `invite_3pid`, `initial_state`
 | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// The created room's ID.
 | ||||
|         pub room_id: RoomId, | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// Extra options to be added to the `m.room.create` event.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct CreationContent { | ||||
|     /// Whether users on other servers can join this room.
 | ||||
|     ///
 | ||||
|     /// Defaults to `true` if key does not exist.
 | ||||
|     #[serde(rename = "m.federate")] | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub federate: Option<bool>, | ||||
| } | ||||
| 
 | ||||
| /// A convenience parameter for setting a few default state events.
 | ||||
| #[derive(Clone, Copy, Debug, Deserialize, Serialize)] | ||||
| pub enum RoomPreset { | ||||
|     /// `join_rules` is set to `invite` and `history_visibility` is set to `shared`.
 | ||||
|     #[serde(rename = "private_chat")] | ||||
|     PrivateChat, | ||||
|     /// `join_rules` is set to `public` and `history_visibility` is set to `shared`.
 | ||||
|     #[serde(rename = "public_chat")] | ||||
|     PublicChat, | ||||
|     /// Same as `PrivateChat`, but all initial invitees get the same power level as the creator.
 | ||||
|     #[serde(rename = "trusted_private_chat")] | ||||
|     TrustedPrivateChat, | ||||
| } | ||||
| 
 | ||||
| /// Whether or not a newly created room will be listed in the room directory.
 | ||||
| #[derive(Clone, Copy, Debug, Deserialize, Serialize)] | ||||
| pub enum Visibility { | ||||
|     /// Indicates that the room will be shown in the published room list.
 | ||||
|     #[serde(rename = "public")] | ||||
|     Public, | ||||
|     /// Indicates that the room from the published room list.
 | ||||
|     #[serde(rename = "private")] | ||||
|     Private, | ||||
| } | ||||
							
								
								
									
										222
									
								
								src/r0/search.rs
									
									
									
									
									
								
							
							
						
						
									
										222
									
								
								src/r0/search.rs
									
									
									
									
									
								
							| @ -1,223 +1,3 @@ | ||||
| //! Endpoints for event searches.
 | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/search](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-search)
 | ||||
| pub mod search_events { | ||||
|     use std::collections::HashMap; | ||||
| 
 | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_events::collections::all::Event; | ||||
|     use ruma_identifiers::{EventId, RoomId, UserId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     use crate::r0::filter::RoomEventFilter; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Search events.", | ||||
|             method: POST, | ||||
|             name: "search", | ||||
|             path: "/_matrix/client/r0/search", | ||||
|             rate_limited: true, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The point to return events from.
 | ||||
|             ///
 | ||||
|             /// If given, this should be a `next_batch` result from a previous call to this endpoint.
 | ||||
|             #[ruma_api(query)] | ||||
|             pub next_batch: Option<String>, | ||||
|             /// Describes which categories to search in and their criteria.
 | ||||
|             pub search_categories: Categories, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// A grouping of search results by category.
 | ||||
|             pub search_categories: ResultCategories, | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /// Categories of events that can be searched for.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct Categories { | ||||
|         /// Criteria for searching a category of events.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub room_events: Option<Criteria>, | ||||
|     } | ||||
| 
 | ||||
|     /// Criteria for searching a category of events.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct Criteria { | ||||
|         /// Configures whether any context for the events returned are included in the response.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub event_context: Option<EventContext>, | ||||
|         /// A `Filter` to apply to the search.
 | ||||
|         // TODO: "timeline" key might need to be included.
 | ||||
|         // See https://github.com/matrix-org/matrix-doc/issues/598.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub filter: Option<RoomEventFilter>, | ||||
|         /// Requests that the server partitions the result set based on the provided list of keys.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub groupings: Option<Groupings>, | ||||
|         /// Requests the server return the current state for each room returned.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub include_state: Option<bool>, | ||||
|         /// The keys to search for. Defaults to all keys.
 | ||||
|         #[serde(skip_serializing_if = "Vec::is_empty")] | ||||
|         #[serde(default)] | ||||
|         pub keys: Vec<SearchKeys>, | ||||
|         /// The order in which to search for results.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub order_by: Option<OrderBy>, | ||||
|         /// The string to search events for.
 | ||||
|         pub search_term: String, | ||||
|     } | ||||
| 
 | ||||
|     /// Configures whether any context for the events returned are included in the response.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct EventContext { | ||||
|         /// How many events after the result are returned.
 | ||||
|         pub after_limit: u64, | ||||
|         /// How many events before the result are returned.
 | ||||
|         pub before_limit: u64, | ||||
|         /// Requests that the server returns the historic profile information for the users that
 | ||||
|         /// sent the events that were returned.
 | ||||
|         pub include_profile: bool, | ||||
|     } | ||||
| 
 | ||||
|     /// Context for search results, if requested.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct EventContextResult { | ||||
|         /// Pagination token for the end of the chunk.
 | ||||
|         pub end: String, | ||||
|         /// Events just after the result.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub events_after: Option<Vec<Event>>, | ||||
|         /// Events just before the result.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub events_before: Option<Vec<Event>>, | ||||
|         /// The historic profile information of the users that sent the events returned.
 | ||||
|         // TODO: Not sure this is right. https://github.com/matrix-org/matrix-doc/issues/773
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub profile_info: Option<HashMap<UserId, UserProfile>>, | ||||
|         /// Pagination token for the start of the chunk.
 | ||||
|         pub start: String, | ||||
|     } | ||||
| 
 | ||||
|     /// A grouping for partioning the result set.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct Grouping { | ||||
|         /// The key within events to use for this grouping.
 | ||||
|         pub key: GroupingKey, | ||||
|     } | ||||
| 
 | ||||
|     /// The key within events to use for this grouping.
 | ||||
|     #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] | ||||
|     pub enum GroupingKey { | ||||
|         /// `room_id`
 | ||||
|         #[serde(rename = "room_id")] | ||||
|         RoomId, | ||||
|         /// `sender`
 | ||||
|         #[serde(rename = "sender")] | ||||
|         Sender, | ||||
|     } | ||||
| 
 | ||||
|     /// Requests that the server partitions the result set based on the provided list of keys.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct Groupings { | ||||
|         /// List of groups to request.
 | ||||
|         pub group_by: Vec<Grouping>, | ||||
|     } | ||||
| 
 | ||||
|     /// The keys to search for.
 | ||||
|     #[derive(Clone, Copy, Debug, Deserialize, Serialize)] | ||||
|     pub enum SearchKeys { | ||||
|         /// content.body
 | ||||
|         #[serde(rename = "content.body")] | ||||
|         ContentBody, | ||||
|         /// content.name
 | ||||
|         #[serde(rename = "content.name")] | ||||
|         ContentName, | ||||
|         /// content.topic
 | ||||
|         #[serde(rename = "content.topic")] | ||||
|         ContentTopic, | ||||
|     } | ||||
| 
 | ||||
|     /// The order in which to search for results.
 | ||||
|     #[derive(Clone, Copy, Debug, Deserialize, Serialize)] | ||||
|     pub enum OrderBy { | ||||
|         /// Prioritize events by a numerical ranking of how closely they matched the search
 | ||||
|         /// criteria.
 | ||||
|         #[serde(rename = "rank")] | ||||
|         Rank, | ||||
|         /// Prioritize recent events.
 | ||||
|         #[serde(rename = "recent")] | ||||
|         Recent, | ||||
|     } | ||||
| 
 | ||||
|     /// Categories of events that can be searched for.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct ResultCategories { | ||||
|         /// Room event results.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub room_events: Option<RoomEventResults>, | ||||
|     } | ||||
| 
 | ||||
|     /// Categories of events that can be searched for.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct RoomEventResults { | ||||
|         /// An approximate count of the total number of results found.
 | ||||
|         pub count: u64, | ||||
|         /// Any groups that were requested.
 | ||||
|         // TODO: Not sure this is right. https://github.com/matrix-org/matrix-doc/issues/773
 | ||||
|         pub groups: HashMap<GroupingKey, HashMap<RoomId, ResultGroup>>, | ||||
|         /// Token that can be used to get the next batch of results, by passing as the `next_batch`
 | ||||
|         /// parameter to the next call. If this field is absent, there are no more results.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub next_batch: Option<String>, | ||||
|         /// List of results in the requested order.
 | ||||
|         pub results: Vec<SearchResult>, | ||||
|         /// The current state for every room in the results. This is included if the request had the
 | ||||
|         /// `include_state` key set with a value of `true`.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         // TODO: Major WTF here. https://github.com/matrix-org/matrix-doc/issues/773
 | ||||
|         pub state: Option<()>, | ||||
|     } | ||||
| 
 | ||||
|     /// A grouping of results, if requested.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct ResultGroup { | ||||
|         /// Token that can be used to get the next batch of results in the group, by passing as the
 | ||||
|         /// `next_batch` parameter to the next call. If this field is absent, there are no more
 | ||||
|         /// results in this group.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub next_batch: Option<String>, | ||||
|         /// Key that can be used to order different groups.
 | ||||
|         pub order: u64, | ||||
|         /// Which results are in this group.
 | ||||
|         pub results: Vec<EventId>, | ||||
|     } | ||||
| 
 | ||||
|     /// A search result.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct SearchResult { | ||||
|         /// Context for result, if requested.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub context: Option<EventContextResult>, | ||||
|         /// A number that describes how closely this result matches the search. Higher is closer.
 | ||||
|         pub rank: f64, | ||||
|         /// The event that matched.
 | ||||
|         pub result: Event, | ||||
|     } | ||||
| 
 | ||||
|     /// A user profile.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct UserProfile { | ||||
|         /// The user's avatar URL, if set.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub avatar_url: Option<String>, | ||||
|         /// The user's display name, if set.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub displayname: Option<String>, | ||||
|     } | ||||
| } | ||||
| pub mod search_events; | ||||
|  | ||||
							
								
								
									
										220
									
								
								src/r0/search/search_events.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										220
									
								
								src/r0/search/search_events.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,220 @@ | ||||
| //! [POST /_matrix/client/r0/search](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-search)
 | ||||
| 
 | ||||
| use std::collections::HashMap; | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_events::collections::all::Event; | ||||
| use ruma_identifiers::{EventId, RoomId, UserId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| use crate::r0::filter::RoomEventFilter; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Search events.", | ||||
|         method: POST, | ||||
|         name: "search", | ||||
|         path: "/_matrix/client/r0/search", | ||||
|         rate_limited: true, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The point to return events from.
 | ||||
|         ///
 | ||||
|         /// If given, this should be a `next_batch` result from a previous call to this endpoint.
 | ||||
|         #[ruma_api(query)] | ||||
|         pub next_batch: Option<String>, | ||||
|         /// Describes which categories to search in and their criteria.
 | ||||
|         pub search_categories: Categories, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// A grouping of search results by category.
 | ||||
|         pub search_categories: ResultCategories, | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// Categories of events that can be searched for.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct Categories { | ||||
|     /// Criteria for searching a category of events.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub room_events: Option<Criteria>, | ||||
| } | ||||
| 
 | ||||
| /// Criteria for searching a category of events.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct Criteria { | ||||
|     /// Configures whether any context for the events returned are included in the response.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub event_context: Option<EventContext>, | ||||
|     /// A `Filter` to apply to the search.
 | ||||
|     // TODO: "timeline" key might need to be included.
 | ||||
|     // See https://github.com/matrix-org/matrix-doc/issues/598.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub filter: Option<RoomEventFilter>, | ||||
|     /// Requests that the server partitions the result set based on the provided list of keys.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub groupings: Option<Groupings>, | ||||
|     /// Requests the server return the current state for each room returned.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub include_state: Option<bool>, | ||||
|     /// The keys to search for. Defaults to all keys.
 | ||||
|     #[serde(skip_serializing_if = "Vec::is_empty")] | ||||
|     #[serde(default)] | ||||
|     pub keys: Vec<SearchKeys>, | ||||
|     /// The order in which to search for results.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub order_by: Option<OrderBy>, | ||||
|     /// The string to search events for.
 | ||||
|     pub search_term: String, | ||||
| } | ||||
| 
 | ||||
| /// Configures whether any context for the events returned are included in the response.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct EventContext { | ||||
|     /// How many events after the result are returned.
 | ||||
|     pub after_limit: u64, | ||||
|     /// How many events before the result are returned.
 | ||||
|     pub before_limit: u64, | ||||
|     /// Requests that the server returns the historic profile information for the users that
 | ||||
|     /// sent the events that were returned.
 | ||||
|     pub include_profile: bool, | ||||
| } | ||||
| 
 | ||||
| /// Context for search results, if requested.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct EventContextResult { | ||||
|     /// Pagination token for the end of the chunk.
 | ||||
|     pub end: String, | ||||
|     /// Events just after the result.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub events_after: Option<Vec<Event>>, | ||||
|     /// Events just before the result.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub events_before: Option<Vec<Event>>, | ||||
|     /// The historic profile information of the users that sent the events returned.
 | ||||
|     // TODO: Not sure this is right. https://github.com/matrix-org/matrix-doc/issues/773
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub profile_info: Option<HashMap<UserId, UserProfile>>, | ||||
|     /// Pagination token for the start of the chunk.
 | ||||
|     pub start: String, | ||||
| } | ||||
| 
 | ||||
| /// A grouping for partioning the result set.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct Grouping { | ||||
|     /// The key within events to use for this grouping.
 | ||||
|     pub key: GroupingKey, | ||||
| } | ||||
| 
 | ||||
| /// The key within events to use for this grouping.
 | ||||
| #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] | ||||
| pub enum GroupingKey { | ||||
|     /// `room_id`
 | ||||
|     #[serde(rename = "room_id")] | ||||
|     RoomId, | ||||
|     /// `sender`
 | ||||
|     #[serde(rename = "sender")] | ||||
|     Sender, | ||||
| } | ||||
| 
 | ||||
| /// Requests that the server partitions the result set based on the provided list of keys.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct Groupings { | ||||
|     /// List of groups to request.
 | ||||
|     pub group_by: Vec<Grouping>, | ||||
| } | ||||
| 
 | ||||
| /// The keys to search for.
 | ||||
| #[derive(Clone, Copy, Debug, Deserialize, Serialize)] | ||||
| pub enum SearchKeys { | ||||
|     /// content.body
 | ||||
|     #[serde(rename = "content.body")] | ||||
|     ContentBody, | ||||
|     /// content.name
 | ||||
|     #[serde(rename = "content.name")] | ||||
|     ContentName, | ||||
|     /// content.topic
 | ||||
|     #[serde(rename = "content.topic")] | ||||
|     ContentTopic, | ||||
| } | ||||
| 
 | ||||
| /// The order in which to search for results.
 | ||||
| #[derive(Clone, Copy, Debug, Deserialize, Serialize)] | ||||
| pub enum OrderBy { | ||||
|     /// Prioritize events by a numerical ranking of how closely they matched the search
 | ||||
|     /// criteria.
 | ||||
|     #[serde(rename = "rank")] | ||||
|     Rank, | ||||
|     /// Prioritize recent events.
 | ||||
|     #[serde(rename = "recent")] | ||||
|     Recent, | ||||
| } | ||||
| 
 | ||||
| /// Categories of events that can be searched for.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct ResultCategories { | ||||
|     /// Room event results.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub room_events: Option<RoomEventResults>, | ||||
| } | ||||
| 
 | ||||
| /// Categories of events that can be searched for.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct RoomEventResults { | ||||
|     /// An approximate count of the total number of results found.
 | ||||
|     pub count: u64, | ||||
|     /// Any groups that were requested.
 | ||||
|     // TODO: Not sure this is right. https://github.com/matrix-org/matrix-doc/issues/773
 | ||||
|     pub groups: HashMap<GroupingKey, HashMap<RoomId, ResultGroup>>, | ||||
|     /// Token that can be used to get the next batch of results, by passing as the `next_batch`
 | ||||
|     /// parameter to the next call. If this field is absent, there are no more results.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub next_batch: Option<String>, | ||||
|     /// List of results in the requested order.
 | ||||
|     pub results: Vec<SearchResult>, | ||||
|     /// The current state for every room in the results. This is included if the request had the
 | ||||
|     /// `include_state` key set with a value of `true`.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     // TODO: Major WTF here. https://github.com/matrix-org/matrix-doc/issues/773
 | ||||
|     pub state: Option<()>, | ||||
| } | ||||
| 
 | ||||
| /// A grouping of results, if requested.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct ResultGroup { | ||||
|     /// Token that can be used to get the next batch of results in the group, by passing as the
 | ||||
|     /// `next_batch` parameter to the next call. If this field is absent, there are no more
 | ||||
|     /// results in this group.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub next_batch: Option<String>, | ||||
|     /// Key that can be used to order different groups.
 | ||||
|     pub order: u64, | ||||
|     /// Which results are in this group.
 | ||||
|     pub results: Vec<EventId>, | ||||
| } | ||||
| 
 | ||||
| /// A search result.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct SearchResult { | ||||
|     /// Context for result, if requested.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub context: Option<EventContextResult>, | ||||
|     /// A number that describes how closely this result matches the search. Higher is closer.
 | ||||
|     pub rank: f64, | ||||
|     /// The event that matched.
 | ||||
|     pub result: Event, | ||||
| } | ||||
| 
 | ||||
| /// A user profile.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct UserProfile { | ||||
|     /// The user's avatar URL, if set.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub avatar_url: Option<String>, | ||||
|     /// The user's display name, if set.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub displayname: Option<String>, | ||||
| } | ||||
							
								
								
									
										122
									
								
								src/r0/send.rs
									
									
									
									
									
								
							
							
						
						
									
										122
									
								
								src/r0/send.rs
									
									
									
									
									
								
							| @ -1,121 +1,5 @@ | ||||
| //! Endpoints for sending events.
 | ||||
| 
 | ||||
| /// [PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype)
 | ||||
| pub mod send_state_event_for_empty_key { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_events::EventType; | ||||
|     use ruma_identifiers::{EventId, RoomId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
|     use serde_json::Value; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Send a state event to a room associated with the empty state key.", | ||||
|             method: PUT, | ||||
|             name: "send_state_event_for_empty_key", | ||||
|             path: "/_matrix/client/r0/rooms/:room_id/state/:event_type", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room to set the state in.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|             /// The type of event to send.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub event_type: EventType, | ||||
|             /// The event's content.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub data: Value, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// A unique identifier for the event.
 | ||||
|             pub event_id: EventId, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype-statekey)
 | ||||
| pub mod send_state_event_for_key { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_events::EventType; | ||||
|     use ruma_identifiers::{EventId, RoomId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
|     use serde_json::Value; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Send a state event to a room associated with a given state key.", | ||||
|             method: PUT, | ||||
|             name: "send_state_event_for_key", | ||||
|             path: "/_matrix/client/r0/rooms/:room_id/state/:event_type/:state_key", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room to set the state in.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|             /// The type of event to send.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub event_type: EventType, | ||||
|             /// The state_key for the state to send. Defaults to the empty string.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub state_key: String, | ||||
|             /// The event's content.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub data: Value, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// A unique identifier for the event.
 | ||||
|             pub event_id: EventId, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-send-eventtype-txnid)
 | ||||
| pub mod send_message_event { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_events::{room::message::MessageEventContent, EventType}; | ||||
|     use ruma_identifiers::{EventId, RoomId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Send a message event to a room.", | ||||
|             method: PUT, | ||||
|             name: "send_message_event", | ||||
|             path: "/_matrix/client/r0/rooms/:room_id/send/:event_type/:txn_id", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room to send the event to.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|             /// The type of event to send.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub event_type: EventType, | ||||
|             /// The transaction ID for this event.
 | ||||
|             ///
 | ||||
|             /// Clients should generate an ID unique across requests with the
 | ||||
|             /// same access token; it will be used by the server to ensure
 | ||||
|             /// idempotency of requests.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub txn_id: String, | ||||
|             /// The event's content.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub data: MessageEventContent, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// A unique identifier for the event.
 | ||||
|             pub event_id: EventId, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| pub mod send_message_event; | ||||
| pub mod send_state_event_for_empty_key; | ||||
| pub mod send_state_event_for_key; | ||||
|  | ||||
							
								
								
									
										41
									
								
								src/r0/send/send_message_event.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								src/r0/send/send_message_event.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,41 @@ | ||||
| //! [PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-send-eventtype-txnid)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_events::{room::message::MessageEventContent, EventType}; | ||||
| use ruma_identifiers::{EventId, RoomId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Send a message event to a room.", | ||||
|         method: PUT, | ||||
|         name: "send_message_event", | ||||
|         path: "/_matrix/client/r0/rooms/:room_id/send/:event_type/:txn_id", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room to send the event to.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|         /// The type of event to send.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub event_type: EventType, | ||||
|         /// The transaction ID for this event.
 | ||||
|         ///
 | ||||
|         /// Clients should generate an ID unique across requests with the
 | ||||
|         /// same access token; it will be used by the server to ensure
 | ||||
|         /// idempotency of requests.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub txn_id: String, | ||||
|         /// The event's content.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub data: MessageEventContent, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// A unique identifier for the event.
 | ||||
|         pub event_id: EventId, | ||||
|     } | ||||
| } | ||||
							
								
								
									
										35
									
								
								src/r0/send/send_state_event_for_empty_key.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								src/r0/send/send_state_event_for_empty_key.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,35 @@ | ||||
| //! [PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_events::EventType; | ||||
| use ruma_identifiers::{EventId, RoomId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| use serde_json::Value; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Send a state event to a room associated with the empty state key.", | ||||
|         method: PUT, | ||||
|         name: "send_state_event_for_empty_key", | ||||
|         path: "/_matrix/client/r0/rooms/:room_id/state/:event_type", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room to set the state in.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|         /// The type of event to send.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub event_type: EventType, | ||||
|         /// The event's content.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub data: Value, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// A unique identifier for the event.
 | ||||
|         pub event_id: EventId, | ||||
|     } | ||||
| } | ||||
							
								
								
									
										38
									
								
								src/r0/send/send_state_event_for_key.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								src/r0/send/send_state_event_for_key.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,38 @@ | ||||
| //! [PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype-statekey)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_events::EventType; | ||||
| use ruma_identifiers::{EventId, RoomId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| use serde_json::Value; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Send a state event to a room associated with a given state key.", | ||||
|         method: PUT, | ||||
|         name: "send_state_event_for_key", | ||||
|         path: "/_matrix/client/r0/rooms/:room_id/state/:event_type/:state_key", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room to set the state in.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|         /// The type of event to send.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub event_type: EventType, | ||||
|         /// The state_key for the state to send. Defaults to the empty string.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub state_key: String, | ||||
|         /// The event's content.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub data: Value, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// A unique identifier for the event.
 | ||||
|         pub event_id: EventId, | ||||
|     } | ||||
| } | ||||
| @ -1,59 +1,3 @@ | ||||
| //! Endpoints for server administration.
 | ||||
| 
 | ||||
| /// [GET /_matrix/client/r0/admin/whois/{userId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-admin-whois-userid)
 | ||||
| pub mod get_user_info { | ||||
|     use std::collections::HashMap; | ||||
| 
 | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::UserId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Get information about a particular user.", | ||||
|             method: GET, | ||||
|             name: "get_user_info", | ||||
|             path: "/_matrix/client/r0/admin/whois/:user_id", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The user to look up.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: UserId, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// The Matrix user ID of the user.
 | ||||
|             pub user_id: UserId, | ||||
|             /// A map of the user's device identifiers to information about that device.
 | ||||
|             pub devices: HashMap<String, DeviceInfo>, | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /// Information about a connection in a user session.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct ConnectionInfo { | ||||
|         /// Most recently seen IP address of the session.
 | ||||
|         pub ip: String, | ||||
|         /// Unix timestamp that the session was last active.
 | ||||
|         pub last_seen: u64, | ||||
|         /// User agent string last seen in the session.
 | ||||
|         pub user_agent: String, | ||||
|     } | ||||
| 
 | ||||
|     /// Information about a user's device.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct DeviceInfo { | ||||
|         /// A list of user sessions on this device.
 | ||||
|         pub sessions: Vec<SessionInfo>, | ||||
|     } | ||||
| 
 | ||||
|     /// Information about a user session.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct SessionInfo { | ||||
|         /// A list of connections in this session.
 | ||||
|         pub connections: Vec<ConnectionInfo>, | ||||
|     } | ||||
| } | ||||
| pub mod get_user_info; | ||||
|  | ||||
							
								
								
									
										56
									
								
								src/r0/server/get_user_info.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								src/r0/server/get_user_info.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,56 @@ | ||||
| //! [GET /_matrix/client/r0/admin/whois/{userId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-admin-whois-userid)
 | ||||
| 
 | ||||
| use std::collections::HashMap; | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::UserId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Get information about a particular user.", | ||||
|         method: GET, | ||||
|         name: "get_user_info", | ||||
|         path: "/_matrix/client/r0/admin/whois/:user_id", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The user to look up.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: UserId, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// The Matrix user ID of the user.
 | ||||
|         pub user_id: UserId, | ||||
|         /// A map of the user's device identifiers to information about that device.
 | ||||
|         pub devices: HashMap<String, DeviceInfo>, | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// Information about a connection in a user session.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct ConnectionInfo { | ||||
|     /// Most recently seen IP address of the session.
 | ||||
|     pub ip: String, | ||||
|     /// Unix timestamp that the session was last active.
 | ||||
|     pub last_seen: u64, | ||||
|     /// User agent string last seen in the session.
 | ||||
|     pub user_agent: String, | ||||
| } | ||||
| 
 | ||||
| /// Information about a user's device.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct DeviceInfo { | ||||
|     /// A list of user sessions on this device.
 | ||||
|     pub sessions: Vec<SessionInfo>, | ||||
| } | ||||
| 
 | ||||
| /// Information about a user session.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct SessionInfo { | ||||
|     /// A list of connections in this session.
 | ||||
|     pub connections: Vec<ConnectionInfo>, | ||||
| } | ||||
| @ -1,92 +1,4 @@ | ||||
| //! Endpoints for user session management.
 | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/login](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-login)
 | ||||
| pub mod login { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::UserId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Login to the homeserver.", | ||||
|             method: POST, | ||||
|             name: "login", | ||||
|             path: "/_matrix/client/r0/login", | ||||
|             rate_limited: true, | ||||
|             requires_authentication: false, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The user's password.
 | ||||
|             pub password: String, | ||||
|             /// When logging in using a third party identifier, the medium of the identifier.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub medium: Option<Medium>, | ||||
|             /// The authentication mechanism.
 | ||||
|             #[serde(rename = "type")] | ||||
|             pub login_type: LoginType, | ||||
|             /// The fully qualified user ID or just local part of the user ID.
 | ||||
|             pub user: String, | ||||
|             /// Third party identifier for the user.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub address: Option<String>, | ||||
|             /// ID of the client device
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub device_id: Option<String>, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// An access token for the account.
 | ||||
|             pub access_token: String, | ||||
|             /// The hostname of the homeserver on which the account has been registered.
 | ||||
|             pub home_server: String, | ||||
|             /// A refresh token may be exchanged for a new access token using the /tokenrefresh API
 | ||||
|             /// endpoint.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub refresh_token: Option<String>, | ||||
|             /// The fully-qualified Matrix ID that has been registered.
 | ||||
|             pub user_id: UserId, | ||||
|             /// ID of the logged-in device.
 | ||||
|             ///
 | ||||
|             /// Will be the same as the corresponging parameter in the request, if one was
 | ||||
|             /// specified.
 | ||||
|             pub device_id: String, | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /// The medium of a third party identifier.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub enum Medium { | ||||
|         /// An email address.
 | ||||
|         #[serde(rename = "email")] | ||||
|         Email, | ||||
|     } | ||||
| 
 | ||||
|     /// The authentication mechanism.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub enum LoginType { | ||||
|         /// A password is supplied to authenticate.
 | ||||
|         #[serde(rename = "m.login.password")] | ||||
|         Password, | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [POST /_matrix/client/r0/logout](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-logout)
 | ||||
| pub mod logout { | ||||
|     use ruma_api_macros::ruma_api; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Log out of the homeserver.", | ||||
|             method: POST, | ||||
|             name: "logout", | ||||
|             path: "/_matrix/client/r0/logout", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request {} | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| pub mod login; | ||||
| pub mod logout; | ||||
|  | ||||
							
								
								
									
										69
									
								
								src/r0/session/login.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								src/r0/session/login.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,69 @@ | ||||
| //! [POST /_matrix/client/r0/login](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-login)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::UserId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Login to the homeserver.", | ||||
|         method: POST, | ||||
|         name: "login", | ||||
|         path: "/_matrix/client/r0/login", | ||||
|         rate_limited: true, | ||||
|         requires_authentication: false, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The user's password.
 | ||||
|         pub password: String, | ||||
|         /// When logging in using a third party identifier, the medium of the identifier.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub medium: Option<Medium>, | ||||
|         /// The authentication mechanism.
 | ||||
|         #[serde(rename = "type")] | ||||
|         pub login_type: LoginType, | ||||
|         /// The fully qualified user ID or just local part of the user ID.
 | ||||
|         pub user: String, | ||||
|         /// Third party identifier for the user.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub address: Option<String>, | ||||
|         /// ID of the client device
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub device_id: Option<String>, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// An access token for the account.
 | ||||
|         pub access_token: String, | ||||
|         /// The hostname of the homeserver on which the account has been registered.
 | ||||
|         pub home_server: String, | ||||
|         /// A refresh token may be exchanged for a new access token using the /tokenrefresh API
 | ||||
|         /// endpoint.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub refresh_token: Option<String>, | ||||
|         /// The fully-qualified Matrix ID that has been registered.
 | ||||
|         pub user_id: UserId, | ||||
|         /// ID of the logged-in device.
 | ||||
|         ///
 | ||||
|         /// Will be the same as the corresponging parameter in the request, if one was
 | ||||
|         /// specified.
 | ||||
|         pub device_id: String, | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// The medium of a third party identifier.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub enum Medium { | ||||
|     /// An email address.
 | ||||
|     #[serde(rename = "email")] | ||||
|     Email, | ||||
| } | ||||
| 
 | ||||
| /// The authentication mechanism.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub enum LoginType { | ||||
|     /// A password is supplied to authenticate.
 | ||||
|     #[serde(rename = "m.login.password")] | ||||
|     Password, | ||||
| } | ||||
							
								
								
									
										18
									
								
								src/r0/session/logout.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/r0/session/logout.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,18 @@ | ||||
| //! [POST /_matrix/client/r0/logout](https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-logout)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Log out of the homeserver.", | ||||
|         method: POST, | ||||
|         name: "logout", | ||||
|         path: "/_matrix/client/r0/logout", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request {} | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
							
								
								
									
										385
									
								
								src/r0/sync.rs
									
									
									
									
									
								
							
							
						
						
									
										385
									
								
								src/r0/sync.rs
									
									
									
									
									
								
							| @ -1,381 +1,8 @@ | ||||
| //! Endpoints for getting and synchronizing events.
 | ||||
| 
 | ||||
| /// [GET /_matrix/client/r0/rooms/{roomId}/state](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-state)
 | ||||
| pub mod get_state_events { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_events::collections::only; | ||||
|     use ruma_identifiers::RoomId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Get state events for a room.", | ||||
|             method: GET, | ||||
|             name: "get_state_events", | ||||
|             path: "/_matrix/client/r0/rooms/:room_id/state", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room to look up the state for.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// If the user is a member of the room this will be the current state of the room as a
 | ||||
|             /// list of events. If the user has left the room then this will be the state of the
 | ||||
|             /// room when they left as a list of events.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub room_state: Vec<only::StateEvent>, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-state-eventtype)
 | ||||
| pub mod get_state_events_for_empty_key { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_events::EventType; | ||||
|     use ruma_identifiers::RoomId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Get state events of a given type associated with the empty key.", | ||||
|             method: GET, | ||||
|             name: "get_state_events_for_empty_key", | ||||
|             path: "/_matrix/client/r0/rooms/:room_id/state/:event_type", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room to look up the state for.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|             /// The type of state to look up.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub event_type: EventType, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// The content of the state event.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub content: ::serde_json::Value, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-state-eventtype-state-key)
 | ||||
| pub mod get_state_events_for_key { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_events::EventType; | ||||
|     use ruma_identifiers::RoomId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Get state events associated with a given key.", | ||||
|             method: GET, | ||||
|             name: "get_state_events_for_key", | ||||
|             path: "/_matrix/client/r0/rooms/:room_id/state/:event_type/:state_key", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room to look up the state for.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|             /// The type of state to look up.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub event_type: EventType, | ||||
|             /// The key of the state to look up.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub state_key: String, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// The content of the state event.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub content: ::serde_json::Value, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [GET /_matrix/client/r0/rooms/{roomId}/members](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-members)
 | ||||
| pub mod get_member_events { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_events::room::member::MemberEvent; | ||||
|     use ruma_identifiers::RoomId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Get membership events for a room.", | ||||
|             method: GET, | ||||
|             name: "get_member_events", | ||||
|             path: "/_matrix/client/r0/rooms/:room_id/members", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room to get the member events for.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// A list of member events.
 | ||||
|             pub chunk: Vec<MemberEvent> | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [GET /_matrix/client/r0/rooms/{roomId}/messages](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-messages)
 | ||||
| pub mod get_message_events { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_events::collections::only; | ||||
|     use ruma_identifiers::RoomId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Get message events for a room.", | ||||
|             method: GET, | ||||
|             name: "get_message_events", | ||||
|             path: "/_matrix/client/r0/rooms/:room_id/messages", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room to get events from.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|             /// The token to start returning events from.
 | ||||
|             ///
 | ||||
|             /// This token can be obtained from a
 | ||||
|             /// prev_batch token returned for each room by the sync API, or from a start or end token
 | ||||
|             /// returned by a previous request to this endpoint.
 | ||||
|             pub from: String, | ||||
|             /// The token to stop returning events at.
 | ||||
|             ///
 | ||||
|             /// This token can be obtained from a prev_batch
 | ||||
|             /// token returned for each room by the sync endpoint, or from a start or end token returned
 | ||||
|             /// by a previous request to this endpoint.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub to: Option<String>, | ||||
|             /// The direction to return events from.
 | ||||
|             pub dir: Direction, | ||||
|             /// The maximum number of events to return.
 | ||||
|             ///
 | ||||
|             /// Default: 10.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub limit: Option<u64>, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// The token the pagination starts from.
 | ||||
|             pub start: String, | ||||
|             /// A list of room events.
 | ||||
|             pub chunk: Vec<only::RoomEvent>, | ||||
|             /// The token the pagination ends at.
 | ||||
|             pub end: String, | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /// The direction to return events from.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub enum Direction { | ||||
|         /// Return events backwards in time from the requested `from` token.
 | ||||
|         #[serde(rename = "b")] | ||||
|         Backward, | ||||
|         /// Return events forwards in time from the requested `from` token.
 | ||||
|         #[serde(rename = "f")] | ||||
|         Forward, | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [GET /_matrix/client/r0/sync](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-sync)
 | ||||
| pub mod sync_events { | ||||
|     use std::collections::HashMap; | ||||
| 
 | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_events::{ | ||||
|         collections::{all, only}, | ||||
|         stripped, | ||||
|     }; | ||||
|     use ruma_identifiers::RoomId; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     use crate::r0::filter::FilterDefinition; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Get all new events from all rooms since the last sync or a given point of time.", | ||||
|             method: GET, | ||||
|             name: "sync", | ||||
|             path: "/_matrix/client/r0/sync", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// A filter represented either as its full JSON definition or the ID of a saved filter.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[ruma_api(query)] | ||||
|             pub filter: Option<Filter>, | ||||
|             /// A point in time to continue a sync from.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[ruma_api(query)] | ||||
|             pub since: Option<String>, | ||||
|             /// Controls whether to include the full state for all rooms the user is a member of.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[ruma_api(query)] | ||||
|             pub full_state: Option<bool>, | ||||
|             /// Controls whether the client is automatically marked as online by polling this API.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[ruma_api(query)] | ||||
|             pub set_presence: Option<SetPresence>, | ||||
|             /// The maximum time to poll in milliseconds before returning this request.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             #[ruma_api(query)] | ||||
|             pub timeout: Option<u64>, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// The batch token to supply in the `since` param of the next `/sync` request.
 | ||||
|             pub next_batch: String, | ||||
|             /// Updates to rooms.
 | ||||
|             pub rooms: Rooms, | ||||
|             /// Updates to the presence status of other users.
 | ||||
|             pub presence: Presence, | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     /// Whether to set presence or not during sync.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub enum SetPresence { | ||||
|         /// Do not set the presence of the user calling this API.
 | ||||
|         #[serde(rename = "offline")] | ||||
|         Offline, | ||||
|     } | ||||
| 
 | ||||
|     /// A filter represented either as its full JSON definition or the ID of a saved filter.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     #[serde(untagged)] | ||||
|     pub enum Filter { | ||||
|         /// A complete filter definition serialized to JSON.
 | ||||
|         FilterDefinition(FilterDefinition), | ||||
|         /// The ID of a filter saved on the server.
 | ||||
|         FilterId(String), | ||||
|     } | ||||
| 
 | ||||
|     /// Updates to rooms.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct Rooms { | ||||
|         /// The rooms that the user has left or been banned from.
 | ||||
|         pub leave: HashMap<RoomId, LeftRoom>, | ||||
|         /// The rooms that the user has joined.
 | ||||
|         pub join: HashMap<RoomId, JoinedRoom>, | ||||
|         /// The rooms that the user has been invited to.
 | ||||
|         pub invite: HashMap<RoomId, InvitedRoom>, | ||||
|     } | ||||
| 
 | ||||
|     /// Historical updates to left rooms.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct LeftRoom { | ||||
|         /// The timeline of messages and state changes in the room up to the point when the user
 | ||||
|         /// left.
 | ||||
|         pub timeline: Timeline, | ||||
|         /// The state updates for the room up to the start of the timeline.
 | ||||
|         pub state: State, | ||||
|     } | ||||
| 
 | ||||
|     /// Updates to joined rooms.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct JoinedRoom { | ||||
|         /// Counts of unread notifications for this room.
 | ||||
|         pub unread_notifications: UnreadNotificationsCount, | ||||
|         /// The timeline of messages and state changes in the room.
 | ||||
|         pub timeline: Timeline, | ||||
|         /// Updates to the state, between the time indicated by the `since` parameter, and the start
 | ||||
|         /// of the `timeline` (or all state up to the start of the `timeline`, if `since` is not
 | ||||
|         /// given, or `full_state` is true).
 | ||||
|         pub state: State, | ||||
|         /// The private data that this user has attached to this room.
 | ||||
|         pub account_data: AccountData, | ||||
|         /// The ephemeral events in the room that aren't recorded in the timeline or state of the
 | ||||
|         /// room. e.g. typing.
 | ||||
|         pub ephemeral: Ephemeral, | ||||
|     } | ||||
| 
 | ||||
|     /// unread notifications count
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct UnreadNotificationsCount { | ||||
|         /// The number of unread notifications for this room with the highlight flag set.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub highlight_count: Option<u64>, | ||||
|         /// The total number of unread notifications for this room.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub notification_count: Option<u64>, | ||||
|     } | ||||
| 
 | ||||
|     /// Events in the room.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct Timeline { | ||||
|         /// True if the number of events returned was limited by the `limit` on the filter.
 | ||||
|         pub limited: bool, | ||||
|         /// A token that can be supplied to to the `from` parameter of the
 | ||||
|         /// `/rooms/{roomId}/messages` endpoint.
 | ||||
|         pub prev_batch: String, | ||||
|         /// A list of events.
 | ||||
|         pub events: Vec<all::RoomEvent>, | ||||
|     } | ||||
| 
 | ||||
|     /// State events in the room.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct State { | ||||
|         /// A list of state events.
 | ||||
|         pub events: Vec<only::StateEvent>, | ||||
|     } | ||||
| 
 | ||||
|     /// The private data that this user has attached to this room.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct AccountData { | ||||
|         /// A list of events.
 | ||||
|         pub events: Vec<only::Event>, | ||||
|     } | ||||
| 
 | ||||
|     /// Ephemeral events not recorded in the timeline or state of the room.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct Ephemeral { | ||||
|         /// A list of events.
 | ||||
|         pub events: Vec<only::Event>, | ||||
|     } | ||||
| 
 | ||||
|     /// Updates to the rooms that the user has been invited to.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct InvitedRoom { | ||||
|         /// The state of a room that the user has been invited to.
 | ||||
|         pub invite_state: InviteState, | ||||
|     } | ||||
| 
 | ||||
|     /// The state of a room that the user has been invited to.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct InviteState { | ||||
|         /// A list of state events.
 | ||||
|         pub events: Vec<stripped::StrippedState>, | ||||
|     } | ||||
| 
 | ||||
|     /// Updates to the presence status of other users.
 | ||||
|     #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
|     pub struct Presence { | ||||
|         /// A list of events.
 | ||||
|         pub events: Vec<only::Event>, | ||||
|     } | ||||
| } | ||||
| pub mod get_member_events; | ||||
| pub mod get_message_events; | ||||
| pub mod get_state_events; | ||||
| pub mod get_state_events_for_empty_key; | ||||
| pub mod get_state_events_for_key; | ||||
| pub mod sync_events; | ||||
|  | ||||
							
								
								
									
										28
									
								
								src/r0/sync/get_member_events.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/r0/sync/get_member_events.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,28 @@ | ||||
| //! [GET /_matrix/client/r0/rooms/{roomId}/members](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-members)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_events::room::member::MemberEvent; | ||||
| use ruma_identifiers::RoomId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Get membership events for a room.", | ||||
|         method: GET, | ||||
|         name: "get_member_events", | ||||
|         path: "/_matrix/client/r0/rooms/:room_id/members", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room to get the member events for.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// A list of member events.
 | ||||
|         pub chunk: Vec<MemberEvent> | ||||
|     } | ||||
| } | ||||
							
								
								
									
										63
									
								
								src/r0/sync/get_message_events.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								src/r0/sync/get_message_events.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,63 @@ | ||||
| //! [GET /_matrix/client/r0/rooms/{roomId}/messages](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-messages)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_events::collections::only; | ||||
| use ruma_identifiers::RoomId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Get message events for a room.", | ||||
|         method: GET, | ||||
|         name: "get_message_events", | ||||
|         path: "/_matrix/client/r0/rooms/:room_id/messages", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room to get events from.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|         /// The token to start returning events from.
 | ||||
|         ///
 | ||||
|         /// This token can be obtained from a
 | ||||
|         /// prev_batch token returned for each room by the sync API, or from a start or end token
 | ||||
|         /// returned by a previous request to this endpoint.
 | ||||
|         pub from: String, | ||||
|         /// The token to stop returning events at.
 | ||||
|         ///
 | ||||
|         /// This token can be obtained from a prev_batch
 | ||||
|         /// token returned for each room by the sync endpoint, or from a start or end token returned
 | ||||
|         /// by a previous request to this endpoint.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub to: Option<String>, | ||||
|         /// The direction to return events from.
 | ||||
|         pub dir: Direction, | ||||
|         /// The maximum number of events to return.
 | ||||
|         ///
 | ||||
|         /// Default: 10.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub limit: Option<u64>, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// The token the pagination starts from.
 | ||||
|         pub start: String, | ||||
|         /// A list of room events.
 | ||||
|         pub chunk: Vec<only::RoomEvent>, | ||||
|         /// The token the pagination ends at.
 | ||||
|         pub end: String, | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// The direction to return events from.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub enum Direction { | ||||
|     /// Return events backwards in time from the requested `from` token.
 | ||||
|     #[serde(rename = "b")] | ||||
|     Backward, | ||||
|     /// Return events forwards in time from the requested `from` token.
 | ||||
|     #[serde(rename = "f")] | ||||
|     Forward, | ||||
| } | ||||
							
								
								
									
										31
									
								
								src/r0/sync/get_state_events.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/r0/sync/get_state_events.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | ||||
| //! [GET /_matrix/client/r0/rooms/{roomId}/state](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-state)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_events::collections::only; | ||||
| use ruma_identifiers::RoomId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Get state events for a room.", | ||||
|         method: GET, | ||||
|         name: "get_state_events", | ||||
|         path: "/_matrix/client/r0/rooms/:room_id/state", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room to look up the state for.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// If the user is a member of the room this will be the current state of the room as a
 | ||||
|         /// list of events. If the user has left the room then this will be the state of the
 | ||||
|         /// room when they left as a list of events.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub room_state: Vec<only::StateEvent>, | ||||
|     } | ||||
| } | ||||
							
								
								
									
										32
									
								
								src/r0/sync/get_state_events_for_empty_key.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/r0/sync/get_state_events_for_empty_key.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | ||||
| //! [GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-state-eventtype)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_events::EventType; | ||||
| use ruma_identifiers::RoomId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Get state events of a given type associated with the empty key.", | ||||
|         method: GET, | ||||
|         name: "get_state_events_for_empty_key", | ||||
|         path: "/_matrix/client/r0/rooms/:room_id/state/:event_type", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room to look up the state for.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|         /// The type of state to look up.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub event_type: EventType, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// The content of the state event.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub content: ::serde_json::Value, | ||||
|     } | ||||
| } | ||||
							
								
								
									
										35
									
								
								src/r0/sync/get_state_events_for_key.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								src/r0/sync/get_state_events_for_key.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,35 @@ | ||||
| //! [GET /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-rooms-roomid-state-eventtype-state-key)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_events::EventType; | ||||
| use ruma_identifiers::RoomId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Get state events associated with a given key.", | ||||
|         method: GET, | ||||
|         name: "get_state_events_for_key", | ||||
|         path: "/_matrix/client/r0/rooms/:room_id/state/:event_type/:state_key", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room to look up the state for.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|         /// The type of state to look up.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub event_type: EventType, | ||||
|         /// The key of the state to look up.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub state_key: String, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// The content of the state event.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub content: ::serde_json::Value, | ||||
|     } | ||||
| } | ||||
							
								
								
									
										179
									
								
								src/r0/sync/sync_events.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										179
									
								
								src/r0/sync/sync_events.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,179 @@ | ||||
| //! [GET /_matrix/client/r0/sync](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-sync)
 | ||||
| 
 | ||||
| use std::collections::HashMap; | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_events::{ | ||||
|     collections::{all, only}, | ||||
|     stripped, | ||||
| }; | ||||
| use ruma_identifiers::RoomId; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| use crate::r0::filter::FilterDefinition; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Get all new events from all rooms since the last sync or a given point of time.", | ||||
|         method: GET, | ||||
|         name: "sync", | ||||
|         path: "/_matrix/client/r0/sync", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// A filter represented either as its full JSON definition or the ID of a saved filter.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[ruma_api(query)] | ||||
|         pub filter: Option<Filter>, | ||||
|         /// A point in time to continue a sync from.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[ruma_api(query)] | ||||
|         pub since: Option<String>, | ||||
|         /// Controls whether to include the full state for all rooms the user is a member of.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[ruma_api(query)] | ||||
|         pub full_state: Option<bool>, | ||||
|         /// Controls whether the client is automatically marked as online by polling this API.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[ruma_api(query)] | ||||
|         pub set_presence: Option<SetPresence>, | ||||
|         /// The maximum time to poll in milliseconds before returning this request.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         #[ruma_api(query)] | ||||
|         pub timeout: Option<u64>, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// The batch token to supply in the `since` param of the next `/sync` request.
 | ||||
|         pub next_batch: String, | ||||
|         /// Updates to rooms.
 | ||||
|         pub rooms: Rooms, | ||||
|         /// Updates to the presence status of other users.
 | ||||
|         pub presence: Presence, | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| /// Whether to set presence or not during sync.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub enum SetPresence { | ||||
|     /// Do not set the presence of the user calling this API.
 | ||||
|     #[serde(rename = "offline")] | ||||
|     Offline, | ||||
| } | ||||
| 
 | ||||
| /// A filter represented either as its full JSON definition or the ID of a saved filter.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| #[serde(untagged)] | ||||
| pub enum Filter { | ||||
|     /// A complete filter definition serialized to JSON.
 | ||||
|     FilterDefinition(FilterDefinition), | ||||
|     /// The ID of a filter saved on the server.
 | ||||
|     FilterId(String), | ||||
| } | ||||
| 
 | ||||
| /// Updates to rooms.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct Rooms { | ||||
|     /// The rooms that the user has left or been banned from.
 | ||||
|     pub leave: HashMap<RoomId, LeftRoom>, | ||||
|     /// The rooms that the user has joined.
 | ||||
|     pub join: HashMap<RoomId, JoinedRoom>, | ||||
|     /// The rooms that the user has been invited to.
 | ||||
|     pub invite: HashMap<RoomId, InvitedRoom>, | ||||
| } | ||||
| 
 | ||||
| /// Historical updates to left rooms.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct LeftRoom { | ||||
|     /// The timeline of messages and state changes in the room up to the point when the user
 | ||||
|     /// left.
 | ||||
|     pub timeline: Timeline, | ||||
|     /// The state updates for the room up to the start of the timeline.
 | ||||
|     pub state: State, | ||||
| } | ||||
| 
 | ||||
| /// Updates to joined rooms.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct JoinedRoom { | ||||
|     /// Counts of unread notifications for this room.
 | ||||
|     pub unread_notifications: UnreadNotificationsCount, | ||||
|     /// The timeline of messages and state changes in the room.
 | ||||
|     pub timeline: Timeline, | ||||
|     /// Updates to the state, between the time indicated by the `since` parameter, and the start
 | ||||
|     /// of the `timeline` (or all state up to the start of the `timeline`, if `since` is not
 | ||||
|     /// given, or `full_state` is true).
 | ||||
|     pub state: State, | ||||
|     /// The private data that this user has attached to this room.
 | ||||
|     pub account_data: AccountData, | ||||
|     /// The ephemeral events in the room that aren't recorded in the timeline or state of the
 | ||||
|     /// room. e.g. typing.
 | ||||
|     pub ephemeral: Ephemeral, | ||||
| } | ||||
| 
 | ||||
| /// unread notifications count
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct UnreadNotificationsCount { | ||||
|     /// The number of unread notifications for this room with the highlight flag set.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub highlight_count: Option<u64>, | ||||
|     /// The total number of unread notifications for this room.
 | ||||
|     #[serde(skip_serializing_if = "Option::is_none")] | ||||
|     pub notification_count: Option<u64>, | ||||
| } | ||||
| 
 | ||||
| /// Events in the room.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct Timeline { | ||||
|     /// True if the number of events returned was limited by the `limit` on the filter.
 | ||||
|     pub limited: bool, | ||||
|     /// A token that can be supplied to to the `from` parameter of the
 | ||||
|     /// `/rooms/{roomId}/messages` endpoint.
 | ||||
|     pub prev_batch: String, | ||||
|     /// A list of events.
 | ||||
|     pub events: Vec<all::RoomEvent>, | ||||
| } | ||||
| 
 | ||||
| /// State events in the room.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct State { | ||||
|     /// A list of state events.
 | ||||
|     pub events: Vec<only::StateEvent>, | ||||
| } | ||||
| 
 | ||||
| /// The private data that this user has attached to this room.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct AccountData { | ||||
|     /// A list of events.
 | ||||
|     pub events: Vec<only::Event>, | ||||
| } | ||||
| 
 | ||||
| /// Ephemeral events not recorded in the timeline or state of the room.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct Ephemeral { | ||||
|     /// A list of events.
 | ||||
|     pub events: Vec<only::Event>, | ||||
| } | ||||
| 
 | ||||
| /// Updates to the rooms that the user has been invited to.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct InvitedRoom { | ||||
|     /// The state of a room that the user has been invited to.
 | ||||
|     pub invite_state: InviteState, | ||||
| } | ||||
| 
 | ||||
| /// The state of a room that the user has been invited to.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct InviteState { | ||||
|     /// A list of state events.
 | ||||
|     pub events: Vec<stripped::StrippedState>, | ||||
| } | ||||
| 
 | ||||
| /// Updates to the presence status of other users.
 | ||||
| #[derive(Clone, Debug, Deserialize, Serialize)] | ||||
| pub struct Presence { | ||||
|     /// A list of events.
 | ||||
|     pub events: Vec<only::Event>, | ||||
| } | ||||
							
								
								
									
										103
									
								
								src/r0/tag.rs
									
									
									
									
									
								
							
							
						
						
									
										103
									
								
								src/r0/tag.rs
									
									
									
									
									
								
							| @ -1,102 +1,5 @@ | ||||
| //! Endpoints for tagging rooms.
 | ||||
| 
 | ||||
| /// [PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-user-userid-rooms-roomid-tags-tag)
 | ||||
| pub mod create_tag { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_events::tag::TagInfo; | ||||
|     use ruma_identifiers::{RoomId, UserId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Add a new tag to a room.", | ||||
|             method: PUT, | ||||
|             name: "create_tag", | ||||
|             path: "/_matrix/client/r0/user/:user_id/rooms/:room_id/tags/:tag", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room to tag.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|             /// The name of the tag to create.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub tag: String, | ||||
|             /// Info about the tag.
 | ||||
|             #[ruma_api(body)] | ||||
|             pub tag_info: TagInfo, | ||||
|             /// The ID of the user creating the tag.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: UserId, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-user-userid-rooms-roomid-tags)
 | ||||
| pub mod get_tags { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_events::tag::TagEventContent; | ||||
|     use ruma_identifiers::{RoomId, UserId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Get the tags associated with a room.", | ||||
|             method: GET, | ||||
|             name: "get_tags", | ||||
|             path: "/_matrix/client/r0/user/:user_id/rooms/:room_id/tags", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room from which tags will be retrieved.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|             /// The user whose tags will be retrieved.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: UserId, | ||||
|         } | ||||
| 
 | ||||
|         response { | ||||
|             /// The user's tags for the room.
 | ||||
|             pub tags: TagEventContent, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// [DELETE /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}](https://matrix.org/docs/spec/client_server/r0.2.0.html#delete-matrix-client-r0-user-userid-rooms-roomid-tags-tag)
 | ||||
| pub mod delete_tag { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::{RoomId, UserId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Remove a tag from a room.", | ||||
|             method: DELETE, | ||||
|             name: "delete_tag", | ||||
|             path: "/_matrix/client/r0/user/:user_id/rooms/:room_id/tags/:tag", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The tagged room.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|             /// The name of the tag to delete.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub tag: String, | ||||
|             /// The user whose tag will be deleted.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: UserId, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| pub mod create_tag; | ||||
| pub mod delete_tag; | ||||
| pub mod get_tags; | ||||
|  | ||||
							
								
								
									
										34
									
								
								src/r0/tag/create_tag.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								src/r0/tag/create_tag.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,34 @@ | ||||
| //! [PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-user-userid-rooms-roomid-tags-tag)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_events::tag::TagInfo; | ||||
| use ruma_identifiers::{RoomId, UserId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Add a new tag to a room.", | ||||
|         method: PUT, | ||||
|         name: "create_tag", | ||||
|         path: "/_matrix/client/r0/user/:user_id/rooms/:room_id/tags/:tag", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room to tag.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|         /// The name of the tag to create.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub tag: String, | ||||
|         /// Info about the tag.
 | ||||
|         #[ruma_api(body)] | ||||
|         pub tag_info: TagInfo, | ||||
|         /// The ID of the user creating the tag.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: UserId, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
							
								
								
									
										30
									
								
								src/r0/tag/delete_tag.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/r0/tag/delete_tag.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | ||||
| //! [DELETE /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags/{tag}](https://matrix.org/docs/spec/client_server/r0.2.0.html#delete-matrix-client-r0-user-userid-rooms-roomid-tags-tag)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::{RoomId, UserId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Remove a tag from a room.", | ||||
|         method: DELETE, | ||||
|         name: "delete_tag", | ||||
|         path: "/_matrix/client/r0/user/:user_id/rooms/:room_id/tags/:tag", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The tagged room.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|         /// The name of the tag to delete.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub tag: String, | ||||
|         /// The user whose tag will be deleted.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: UserId, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
							
								
								
									
										31
									
								
								src/r0/tag/get_tags.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/r0/tag/get_tags.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | ||||
| //! [GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/tags](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-user-userid-rooms-roomid-tags)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_events::tag::TagEventContent; | ||||
| use ruma_identifiers::{RoomId, UserId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Get the tags associated with a room.", | ||||
|         method: GET, | ||||
|         name: "get_tags", | ||||
|         path: "/_matrix/client/r0/user/:user_id/rooms/:room_id/tags", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room from which tags will be retrieved.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|         /// The user whose tags will be retrieved.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: UserId, | ||||
|     } | ||||
| 
 | ||||
|     response { | ||||
|         /// The user's tags for the room.
 | ||||
|         pub tags: TagEventContent, | ||||
|     } | ||||
| } | ||||
| @ -1,35 +1,3 @@ | ||||
| //! Endpoints for typing notifications.
 | ||||
| 
 | ||||
| /// [PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-typing-userid)
 | ||||
| pub mod create_typing_event { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use ruma_identifiers::{RoomId, UserId}; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             method: PUT, | ||||
|             path: "/_matrix/client/r0/rooms/:room_id/typing/:user_id", | ||||
|             name: "create_typing_event", | ||||
|             description: "Send a typing event to a room.", | ||||
|             requires_authentication: true, | ||||
|             rate_limited: true, | ||||
|         } | ||||
| 
 | ||||
|         request { | ||||
|             /// The room in which the user is typing.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub room_id: RoomId, | ||||
|             /// The length of time in milliseconds to mark this user as typing.
 | ||||
|             #[serde(skip_serializing_if = "Option::is_none")] | ||||
|             pub timeout: Option<u64>, | ||||
|             /// Whether the user is typing or not. If `false`, the `timeout` key can be omitted.
 | ||||
|             pub typing: bool, | ||||
|             /// The user who has started to type.
 | ||||
|             #[ruma_api(path)] | ||||
|             pub user_id: UserId, | ||||
|         } | ||||
| 
 | ||||
|         response {} | ||||
|     } | ||||
| } | ||||
| pub mod create_typing_event; | ||||
|  | ||||
							
								
								
									
										32
									
								
								src/r0/typing/create_typing_event.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/r0/typing/create_typing_event.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | ||||
| //! [PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}](https://matrix.org/docs/spec/client_server/r0.2.0.html#put-matrix-client-r0-rooms-roomid-typing-userid)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use ruma_identifiers::{RoomId, UserId}; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         method: PUT, | ||||
|         path: "/_matrix/client/r0/rooms/:room_id/typing/:user_id", | ||||
|         name: "create_typing_event", | ||||
|         description: "Send a typing event to a room.", | ||||
|         requires_authentication: true, | ||||
|         rate_limited: true, | ||||
|     } | ||||
| 
 | ||||
|     request { | ||||
|         /// The room in which the user is typing.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub room_id: RoomId, | ||||
|         /// The length of time in milliseconds to mark this user as typing.
 | ||||
|         #[serde(skip_serializing_if = "Option::is_none")] | ||||
|         pub timeout: Option<u64>, | ||||
|         /// Whether the user is typing or not. If `false`, the `timeout` key can be omitted.
 | ||||
|         pub typing: bool, | ||||
|         /// The user who has started to type.
 | ||||
|         #[ruma_api(path)] | ||||
|         pub user_id: UserId, | ||||
|     } | ||||
| 
 | ||||
|     response {} | ||||
| } | ||||
| @ -1,31 +1,3 @@ | ||||
| //! Endpoints for Voice over IP.
 | ||||
| 
 | ||||
| /// [GET /_matrix/client/r0/voip/turnServer](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-voip-turnserver)
 | ||||
| pub mod get_turn_server_info { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Get credentials for the client to use when initiating VoIP calls.", | ||||
|             method: GET, | ||||
|             name: "turn_server_info", | ||||
|             path: "_matrix/client/r0/voip/turnServer", | ||||
|             rate_limited: true, | ||||
|             requires_authentication: true, | ||||
|         } | ||||
| 
 | ||||
|         request {} | ||||
| 
 | ||||
|         response { | ||||
|             /// The password to use.
 | ||||
|             pub password: String, | ||||
|             /// The time-to-live in seconds.
 | ||||
|             pub ttl: u64, | ||||
|             /// A list of TURN URIs.
 | ||||
|             pub uris: Vec<String>, | ||||
|             /// The username to use.
 | ||||
|             pub username: String, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| pub mod get_turn_server_info; | ||||
|  | ||||
							
								
								
									
										28
									
								
								src/r0/voip/get_turn_server_info.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								src/r0/voip/get_turn_server_info.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,28 @@ | ||||
| //! [GET /_matrix/client/r0/voip/turnServer](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-voip-turnserver)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Get credentials for the client to use when initiating VoIP calls.", | ||||
|         method: GET, | ||||
|         name: "turn_server_info", | ||||
|         path: "_matrix/client/r0/voip/turnServer", | ||||
|         rate_limited: true, | ||||
|         requires_authentication: true, | ||||
|     } | ||||
| 
 | ||||
|     request {} | ||||
| 
 | ||||
|     response { | ||||
|         /// The password to use.
 | ||||
|         pub password: String, | ||||
|         /// The time-to-live in seconds.
 | ||||
|         pub ttl: u64, | ||||
|         /// A list of TURN URIs.
 | ||||
|         pub uris: Vec<String>, | ||||
|         /// The username to use.
 | ||||
|         pub username: String, | ||||
|     } | ||||
| } | ||||
| @ -1,25 +1,3 @@ | ||||
| //! Endpoints that cannot change with new versions of the Matrix specification.
 | ||||
| 
 | ||||
| /// [GET /_matrix/client/versions](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-versions)
 | ||||
| pub mod get_supported_versions { | ||||
|     use ruma_api_macros::ruma_api; | ||||
|     use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
|     ruma_api! { | ||||
|         metadata { | ||||
|             description: "Get the versions of the client-server API supported by this homeserver.", | ||||
|             method: GET, | ||||
|             name: "api_versions", | ||||
|             path: "/_matrix/client/versions", | ||||
|             rate_limited: false, | ||||
|             requires_authentication: false, | ||||
|         } | ||||
| 
 | ||||
|         request {} | ||||
| 
 | ||||
|         response { | ||||
|             /// A list of Matrix client API protocol versions supported by the homeserver.
 | ||||
|             pub versions: Vec<String>, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| pub mod get_supported_versions; | ||||
|  | ||||
							
								
								
									
										22
									
								
								src/unversioned/get_supported_versions.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/unversioned/get_supported_versions.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| //! [GET /_matrix/client/versions](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-versions)
 | ||||
| 
 | ||||
| use ruma_api_macros::ruma_api; | ||||
| use serde_derive::{Deserialize, Serialize}; | ||||
| 
 | ||||
| ruma_api! { | ||||
|     metadata { | ||||
|         description: "Get the versions of the client-server API supported by this homeserver.", | ||||
|         method: GET, | ||||
|         name: "api_versions", | ||||
|         path: "/_matrix/client/versions", | ||||
|         rate_limited: false, | ||||
|         requires_authentication: false, | ||||
|     } | ||||
| 
 | ||||
|     request {} | ||||
| 
 | ||||
|     response { | ||||
|         /// A list of Matrix client API protocol versions supported by the homeserver.
 | ||||
|         pub versions: Vec<String>, | ||||
|     } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user