Update lots of types to the new API standards
This commit is contained in:
parent
bfe4e9fa27
commit
fec07a7426
@ -18,17 +18,26 @@ pub mod unbind_3pid;
|
|||||||
|
|
||||||
pub mod whoami;
|
pub mod whoami;
|
||||||
|
|
||||||
|
use ruma_api::Outgoing;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Additional authentication information for requestToken endpoints.
|
/// Additional authentication information for requestToken endpoints.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||||
pub struct IdentityServerInfo {
|
#[non_exhaustive]
|
||||||
|
pub struct IdentityServerInfo<'a> {
|
||||||
/// The ID server to send the onward request to as a hostname with an
|
/// 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.
|
/// appended colon and port number if the port is not the default.
|
||||||
pub id_server: String,
|
pub id_server: &'a str,
|
||||||
|
|
||||||
/// Access token previously registered with identity server.
|
/// Access token previously registered with identity server.
|
||||||
pub id_access_token: String,
|
pub id_access_token: &'a str,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> IdentityServerInfo<'a> {
|
||||||
|
/// Creates a new `IdentityServerInfo` with the given server name and access token.
|
||||||
|
pub fn new(id_server: &'a str, id_access_token: &'a str) -> Self {
|
||||||
|
Self { id_server, id_access_token }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Possible values for deleting or unbinding 3PIDs
|
/// Possible values for deleting or unbinding 3PIDs
|
||||||
|
@ -14,6 +14,7 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// Additional information for the User-Interactive Authentication API.
|
/// Additional information for the User-Interactive Authentication API.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
@ -26,7 +27,23 @@ ruma_api! {
|
|||||||
pub sid: &'a str,
|
pub sid: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
response: {}
|
response: {}
|
||||||
|
|
||||||
error: UiaaResponse
|
error: UiaaResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given client secret and session identifier.
|
||||||
|
pub fn new(client_secret: &'a str, sid: &'a str) -> Self {
|
||||||
|
Self { auth: None, client_secret, sid }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates an empty `Response`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
|
|
||||||
use super::IdentityServerInfo;
|
use super::{IdentityServerInfo, IncomingIdentityServerInfo};
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -14,20 +14,42 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// Client-generated secret string used to protect this session.
|
/// Client-generated secret string used to protect this session.
|
||||||
pub client_secret: String,
|
pub client_secret: &'a str,
|
||||||
|
|
||||||
/// The ID server to send the onward request to as a hostname with an
|
/// 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.
|
/// appended colon and port number if the port is not the default.
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub identity_server_info: IdentityServerInfo,
|
pub identity_server_info: IdentityServerInfo<'a>,
|
||||||
|
|
||||||
/// The session identifier given by the identity server.
|
/// The session identifier given by the identity server.
|
||||||
pub sid: String,
|
pub sid: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
response: {}
|
response: {}
|
||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given client secret, identity server information and
|
||||||
|
/// session identifier.
|
||||||
|
pub fn new(
|
||||||
|
client_secret: &'a str,
|
||||||
|
identity_server_info: IdentityServerInfo<'a>,
|
||||||
|
sid: &'a str,
|
||||||
|
) -> Self {
|
||||||
|
Self { client_secret, identity_server_info, sid }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates an empty `Response`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -14,9 +14,10 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// The new password for the account.
|
/// The new password for the account.
|
||||||
pub new_password: String,
|
pub new_password: &'a str,
|
||||||
|
|
||||||
/// True to revoke the user's other access tokens, and their associated devices if the
|
/// True to revoke the user's other access tokens, and their associated devices if the
|
||||||
/// request succeeds.
|
/// request succeeds.
|
||||||
@ -29,10 +30,27 @@ ruma_api! {
|
|||||||
pub logout_devices: bool,
|
pub logout_devices: bool,
|
||||||
|
|
||||||
/// Additional authentication information for the user-interactive authentication API.
|
/// Additional authentication information for the user-interactive authentication API.
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub auth: Option<AuthData<'a>>,
|
pub auth: Option<AuthData<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
response: {}
|
response: {}
|
||||||
|
|
||||||
error: UiaaResponse
|
error: UiaaResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given password.
|
||||||
|
pub fn new(new_password: &'a str) -> Self {
|
||||||
|
Self { new_password, logout_devices: true, auth: None }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates an empty `Response`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -16,6 +16,8 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// Additional authentication information for the user-interactive authentication API.
|
/// Additional authentication information for the user-interactive authentication API.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
@ -27,6 +29,7 @@ ruma_api! {
|
|||||||
pub id_server: Option<&'a str>,
|
pub id_server: Option<&'a str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// Result of unbind operation.
|
/// Result of unbind operation.
|
||||||
pub id_server_unbind_result: ThirdPartyIdRemovalStatus,
|
pub id_server_unbind_result: ThirdPartyIdRemovalStatus,
|
||||||
@ -34,3 +37,17 @@ ruma_api! {
|
|||||||
|
|
||||||
error: UiaaResponse
|
error: UiaaResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Request<'_> {
|
||||||
|
/// Creates an empty `Request`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given unbind result.
|
||||||
|
pub fn new(id_server_unbind_result: ThirdPartyIdRemovalStatus) -> Self {
|
||||||
|
Self { id_server_unbind_result }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -15,23 +15,31 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// Identity server to delete from.
|
/// Identity server to delete from.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub id_server: Option<String>,
|
pub id_server: Option<&'a str>,
|
||||||
|
|
||||||
/// Medium of the 3PID to be removed.
|
/// Medium of the 3PID to be removed.
|
||||||
pub medium: Medium,
|
pub medium: Medium,
|
||||||
|
|
||||||
/// Third-party address being removed.
|
/// Third-party address being removed.
|
||||||
pub address: String,
|
pub address: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// Result of unbind operation.
|
/// Result of unbind operation.
|
||||||
pub id_server_unbind_result: ThirdPartyIdRemovalStatus,
|
pub id_server_unbind_result: ThirdPartyIdRemovalStatus,
|
||||||
}
|
}
|
||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given medium and address.
|
||||||
|
pub fn new(medium: Medium, address: &'a str) -> Self {
|
||||||
|
Self { id_server: None, medium, address }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,17 +12,33 @@ ruma_api! {
|
|||||||
requires_authentication: false,
|
requires_authentication: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// The username to check the availability of.
|
/// The username to check the availability of.
|
||||||
#[ruma_api(query)]
|
#[ruma_api(query)]
|
||||||
pub username: String,
|
pub username: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// A flag to indicate that the username is available.
|
/// A flag to indicate that the username is available.
|
||||||
/// This should always be true when the server replies with 200 OK.
|
/// This should always be true when the server replies with 200 OK.
|
||||||
pub available: bool
|
pub available: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given username.
|
||||||
|
pub fn new(username: &'a str) -> Self {
|
||||||
|
Self { username }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given availability flag.
|
||||||
|
pub fn new(available: bool) -> Self {
|
||||||
|
Self { available }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
|
|
||||||
use super::IdentityServerInfo;
|
use super::{IdentityServerInfo, IncomingIdentityServerInfo};
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -15,26 +15,28 @@ ruma_api! {
|
|||||||
requires_authentication: false,
|
requires_authentication: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// Client-generated secret string used to protect this session.
|
/// Client-generated secret string used to protect this session.
|
||||||
pub client_secret: String,
|
pub client_secret: &'a str,
|
||||||
|
|
||||||
/// The email address.
|
/// The email address.
|
||||||
pub email: String,
|
pub email: &'a str,
|
||||||
|
|
||||||
/// Used to distinguish protocol level retries from requests to re-send the email.
|
/// Used to distinguish protocol level retries from requests to re-send the email.
|
||||||
pub send_attempt: UInt,
|
pub send_attempt: UInt,
|
||||||
|
|
||||||
/// Return URL for identity server to redirect the client back to.
|
/// Return URL for identity server to redirect the client back to.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub next_link: Option<String>,
|
pub next_link: Option<&'a str>,
|
||||||
|
|
||||||
/// Optional identity server hostname and access token. Deprecated since r0.6.0.
|
/// Optional identity server hostname and access token. Deprecated since r0.6.0.
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub identity_server_info: Option<IdentityServerInfo>,
|
pub identity_server_info: Option<IdentityServerInfo<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// The session identifier given by the identity server.
|
/// The session identifier given by the identity server.
|
||||||
pub sid: String,
|
pub sid: String,
|
||||||
@ -46,3 +48,17 @@ ruma_api! {
|
|||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the client secret, email and send-attempt counter.
|
||||||
|
pub fn new(client_secret: &'a str, email: &'a str, send_attempt: UInt) -> Self {
|
||||||
|
Self { client_secret, email, send_attempt, next_link: None, identity_server_info: None }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given session identifier.
|
||||||
|
pub fn new(sid: String) -> Self {
|
||||||
|
Self { sid, submit_url: None }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
|
|
||||||
use super::IdentityServerInfo;
|
use super::{IdentityServerInfo, IncomingIdentityServerInfo};
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -15,29 +15,31 @@ ruma_api! {
|
|||||||
requires_authentication: false,
|
requires_authentication: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// Client-generated secret string used to protect this session.
|
/// Client-generated secret string used to protect this session.
|
||||||
pub client_secret: String,
|
pub client_secret: &'a str,
|
||||||
|
|
||||||
/// Two-letter ISO 3166 country code for the phone number.
|
/// Two-letter ISO 3166 country code for the phone number.
|
||||||
pub country: String,
|
pub country: &'a str,
|
||||||
|
|
||||||
/// Phone number to validate.
|
/// Phone number to validate.
|
||||||
pub phone_number: String,
|
pub phone_number: &'a str,
|
||||||
|
|
||||||
/// Used to distinguish protocol level retries from requests to re-send the SMS.
|
/// Used to distinguish protocol level retries from requests to re-send the SMS.
|
||||||
pub send_attempt: UInt,
|
pub send_attempt: UInt,
|
||||||
|
|
||||||
/// Return URL for identity server to redirect the client back to.
|
/// Return URL for identity server to redirect the client back to.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub next_link: Option<String>,
|
pub next_link: Option<&'a str>,
|
||||||
|
|
||||||
/// Optional identity server hostname and access token. Deprecated since r0.6.0.
|
/// Optional identity server hostname and access token. Deprecated since r0.6.0.
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub identity_server_info: Option<IdentityServerInfo>,
|
pub identity_server_info: Option<IdentityServerInfo<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// The session identifier given by the identity server.
|
/// The session identifier given by the identity server.
|
||||||
pub sid: String,
|
pub sid: String,
|
||||||
@ -49,3 +51,30 @@ ruma_api! {
|
|||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given client secret, country code, phone number and
|
||||||
|
/// send-attempt counter.
|
||||||
|
pub fn new(
|
||||||
|
client_secret: &'a str,
|
||||||
|
country: &'a str,
|
||||||
|
phone_number: &'a str,
|
||||||
|
send_attempt: UInt,
|
||||||
|
) -> Self {
|
||||||
|
Self {
|
||||||
|
client_secret,
|
||||||
|
country,
|
||||||
|
phone_number,
|
||||||
|
send_attempt,
|
||||||
|
next_link: None,
|
||||||
|
identity_server_info: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given session identifier.
|
||||||
|
pub fn new(sid: String) -> Self {
|
||||||
|
Self { sid, submit_url: None }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -16,12 +16,14 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// User ID of authenticated user.
|
/// User ID of authenticated user.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub user_id: UserId,
|
pub user_id: &'a UserId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// Access token for verifying user's identity.
|
/// Access token for verifying user's identity.
|
||||||
pub access_token: String,
|
pub access_token: String,
|
||||||
@ -40,8 +42,29 @@ ruma_api! {
|
|||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given user ID.
|
||||||
|
pub fn new(user_id: &'a UserId) -> Self {
|
||||||
|
Self { user_id }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given access token, token type, server name and expiration
|
||||||
|
/// duration.
|
||||||
|
pub fn new(
|
||||||
|
access_token: String,
|
||||||
|
token_type: TokenType,
|
||||||
|
matrix_server_name: ServerNameBox,
|
||||||
|
expires_in: Duration,
|
||||||
|
) -> Self {
|
||||||
|
Self { access_token, token_type, matrix_server_name, expires_in }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Access token types.
|
/// Access token types.
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub enum TokenType {
|
pub enum TokenType {
|
||||||
/// Bearer token type
|
/// Bearer token type
|
||||||
Bearer,
|
Bearer,
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
|
|
||||||
use super::IdentityServerInfo;
|
use super::{IdentityServerInfo, IncomingIdentityServerInfo};
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -15,26 +15,28 @@ ruma_api! {
|
|||||||
requires_authentication: false,
|
requires_authentication: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// Client-generated secret string used to protect this session.
|
/// Client-generated secret string used to protect this session.
|
||||||
pub client_secret: String,
|
pub client_secret: &'a str,
|
||||||
|
|
||||||
/// The email address.
|
/// The email address.
|
||||||
pub email: String,
|
pub email: &'a str,
|
||||||
|
|
||||||
/// Used to distinguish protocol level retries from requests to re-send the email.
|
/// Used to distinguish protocol level retries from requests to re-send the email.
|
||||||
pub send_attempt: UInt,
|
pub send_attempt: UInt,
|
||||||
|
|
||||||
/// Return URL for identity server to redirect the client back to.
|
/// Return URL for identity server to redirect the client back to.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub next_link: Option<String>,
|
pub next_link: Option<&'a str>,
|
||||||
|
|
||||||
/// Optional identity server hostname and access token. Deprecated since r0.6.0.
|
/// Optional identity server hostname and access token. Deprecated since r0.6.0.
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub identity_server_info: Option<IdentityServerInfo>,
|
pub identity_server_info: Option<IdentityServerInfo<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// The session identifier given by the identity server.
|
/// The session identifier given by the identity server.
|
||||||
pub sid: String,
|
pub sid: String,
|
||||||
@ -46,3 +48,18 @@ ruma_api! {
|
|||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given client secret, email address and send-attempt
|
||||||
|
/// counter.
|
||||||
|
pub fn new(client_secret: &'a str, email: &'a str, send_attempt: UInt) -> Self {
|
||||||
|
Self { client_secret, email, send_attempt, next_link: None, identity_server_info: None }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given session identifier.
|
||||||
|
pub fn new(sid: String) -> Self {
|
||||||
|
Self { sid, submit_url: None }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -13,24 +13,26 @@ ruma_api! {
|
|||||||
requires_authentication: false,
|
requires_authentication: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// Client-generated secret string used to protect this session.
|
/// Client-generated secret string used to protect this session.
|
||||||
pub client_secret: String,
|
pub client_secret: &'a str,
|
||||||
|
|
||||||
/// Two-letter ISO 3166 country code for the phone number.
|
/// Two-letter ISO 3166 country code for the phone number.
|
||||||
pub country: String,
|
pub country: &'a str,
|
||||||
|
|
||||||
/// Phone number to validate.
|
/// Phone number to validate.
|
||||||
pub phone_number: String,
|
pub phone_number: &'a str,
|
||||||
|
|
||||||
/// Used to distinguish protocol level retries from requests to re-send the SMS.
|
/// Used to distinguish protocol level retries from requests to re-send the SMS.
|
||||||
pub send_attempt: UInt,
|
pub send_attempt: UInt,
|
||||||
|
|
||||||
/// Return URL for identity server to redirect the client back to.
|
/// Return URL for identity server to redirect the client back to.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub next_link: Option<String>,
|
pub next_link: Option<&'a str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// The session identifier given by the identity server.
|
/// The session identifier given by the identity server.
|
||||||
pub sid: String,
|
pub sid: String,
|
||||||
@ -42,3 +44,23 @@ ruma_api! {
|
|||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given client secret, country code, phone number and
|
||||||
|
/// send-attempt counter.
|
||||||
|
pub fn new(
|
||||||
|
client_secret: &'a str,
|
||||||
|
country: &'a str,
|
||||||
|
phone_number: &'a str,
|
||||||
|
send_attempt: UInt,
|
||||||
|
) -> Self {
|
||||||
|
Self { client_secret, country, phone_number, send_attempt, next_link: None }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given session identifier.
|
||||||
|
pub fn new(sid: String) -> Self {
|
||||||
|
Self { sid, submit_url: None }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
|
|
||||||
use super::IdentityServerInfo;
|
use super::{IdentityServerInfo, IncomingIdentityServerInfo};
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -15,26 +15,28 @@ ruma_api! {
|
|||||||
requires_authentication: false,
|
requires_authentication: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// Client-generated secret string used to protect this session.
|
/// Client-generated secret string used to protect this session.
|
||||||
pub client_secret: String,
|
pub client_secret: &'a str,
|
||||||
|
|
||||||
/// The email address.
|
/// The email address.
|
||||||
pub email: String,
|
pub email: &'a str,
|
||||||
|
|
||||||
/// Used to distinguish protocol level retries from requests to re-send the email.
|
/// Used to distinguish protocol level retries from requests to re-send the email.
|
||||||
pub send_attempt: UInt,
|
pub send_attempt: UInt,
|
||||||
|
|
||||||
/// Return URL for identity server to redirect the client back to.
|
/// Return URL for identity server to redirect the client back to.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub next_link: Option<String>,
|
pub next_link: Option<&'a str>,
|
||||||
|
|
||||||
/// Optional identity server hostname and access token. Deprecated since r0.6.0.
|
/// Optional identity server hostname and access token. Deprecated since r0.6.0.
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub identity_server_info: Option<IdentityServerInfo>,
|
pub identity_server_info: Option<IdentityServerInfo<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// The session identifier given by the identity server.
|
/// The session identifier given by the identity server.
|
||||||
pub sid: String,
|
pub sid: String,
|
||||||
@ -46,3 +48,18 @@ ruma_api! {
|
|||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given client secret, email address and send-attempt
|
||||||
|
/// counter.
|
||||||
|
pub fn new(client_secret: &'a str, email: &'a str, send_attempt: UInt) -> Self {
|
||||||
|
Self { client_secret, email, send_attempt, next_link: None, identity_server_info: None }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given session identifier.
|
||||||
|
pub fn new(sid: String) -> Self {
|
||||||
|
Self { sid, submit_url: None }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
|
|
||||||
use super::IdentityServerInfo;
|
use super::{IdentityServerInfo, IncomingIdentityServerInfo};
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
metadata: {
|
metadata: {
|
||||||
@ -15,29 +15,31 @@ ruma_api! {
|
|||||||
requires_authentication: false,
|
requires_authentication: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// Client-generated secret string used to protect this session.
|
/// Client-generated secret string used to protect this session.
|
||||||
pub client_secret: String,
|
pub client_secret: &'a str,
|
||||||
|
|
||||||
/// Two-letter ISO 3166 country code for the phone number.
|
/// Two-letter ISO 3166 country code for the phone number.
|
||||||
pub country: String,
|
pub country: &'a str,
|
||||||
|
|
||||||
/// Phone number to validate.
|
/// Phone number to validate.
|
||||||
pub phone_number: String,
|
pub phone_number: &'a str,
|
||||||
|
|
||||||
/// Return URL for identity server to redirect the client back to.
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
|
||||||
pub next_link: Option<String>,
|
|
||||||
|
|
||||||
/// Used to distinguish protocol level retries from requests to re-send the SMS.
|
/// Used to distinguish protocol level retries from requests to re-send the SMS.
|
||||||
pub send_attempt: UInt,
|
pub send_attempt: UInt,
|
||||||
|
|
||||||
|
/// Return URL for identity server to redirect the client back to.
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub next_link: Option<&'a str>,
|
||||||
|
|
||||||
/// Optional identity server hostname and access token. Deprecated since r0.6.0.
|
/// Optional identity server hostname and access token. Deprecated since r0.6.0.
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub identity_server_info: Option<IdentityServerInfo>,
|
pub identity_server_info: Option<IdentityServerInfo<'a>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// The session identifier given by the identity server.
|
/// The session identifier given by the identity server.
|
||||||
pub sid: String,
|
pub sid: String,
|
||||||
@ -49,3 +51,23 @@ ruma_api! {
|
|||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given client secret, country code, phone number and
|
||||||
|
/// send-attempt counter.
|
||||||
|
pub fn new(
|
||||||
|
client_secret: &'a str,
|
||||||
|
country: &'a str,
|
||||||
|
phone_number: &'a str,
|
||||||
|
send_attempt: UInt,
|
||||||
|
) -> Self {
|
||||||
|
Self {
|
||||||
|
client_secret,
|
||||||
|
country,
|
||||||
|
phone_number,
|
||||||
|
send_attempt,
|
||||||
|
next_link: None,
|
||||||
|
identity_server_info: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -15,18 +15,20 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// Identity server to unbind from.
|
/// Identity server to unbind from.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub id_server: Option<String>,
|
pub id_server: Option<&'a str>,
|
||||||
|
|
||||||
/// Medium of the 3PID to be removed.
|
/// Medium of the 3PID to be removed.
|
||||||
pub medium: Medium,
|
pub medium: Medium,
|
||||||
|
|
||||||
/// Third-party address being removed.
|
/// Third-party address being removed.
|
||||||
pub address: String,
|
pub address: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// Result of unbind operation.
|
/// Result of unbind operation.
|
||||||
pub id_server_unbind_result: ThirdPartyIdRemovalStatus,
|
pub id_server_unbind_result: ThirdPartyIdRemovalStatus,
|
||||||
@ -34,3 +36,17 @@ ruma_api! {
|
|||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given medium and third-party address.
|
||||||
|
pub fn new(medium: Medium, address: &'a str) -> Self {
|
||||||
|
Self { id_server: None, medium, address }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given unbind result.
|
||||||
|
pub fn new(id_server_unbind_result: ThirdPartyIdRemovalStatus) -> Self {
|
||||||
|
Self { id_server_unbind_result }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -13,8 +13,11 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
request: {}
|
request: {}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// The id of the user that owns the access token.
|
/// The id of the user that owns the access token.
|
||||||
pub user_id: UserId,
|
pub user_id: UserId,
|
||||||
@ -22,3 +25,17 @@ ruma_api! {
|
|||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Request {
|
||||||
|
/// Creates an empty `Request`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given user ID.
|
||||||
|
pub fn new(user_id: UserId) -> Self {
|
||||||
|
Self { user_id }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -15,20 +15,37 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// The protocol (network) ID to update the room list for.
|
/// The protocol (network) ID to update the room list for.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub network_id: String,
|
pub network_id: &'a str,
|
||||||
|
|
||||||
/// The room ID to add to the directory.
|
/// The room ID to add to the directory.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub room_id: RoomId,
|
pub room_id: &'a RoomId,
|
||||||
|
|
||||||
/// Whether the room should be visible (public) in the directory or not (private).
|
/// Whether the room should be visible (public) in the directory or not (private).
|
||||||
pub visibility: Visibility,
|
pub visibility: Visibility,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
response: {}
|
response: {}
|
||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given network ID, room ID and visibility.
|
||||||
|
pub fn new(network_id: &'a str, room_id: &'a RoomId, visibility: Visibility) -> Self {
|
||||||
|
Self { network_id, room_id, visibility }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates an empty `Response`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -16,8 +16,11 @@ ruma_api! {
|
|||||||
requires_authentication: true
|
requires_authentication: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
request: {}
|
request: {}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// The capabilities the server supports
|
/// The capabilities the server supports
|
||||||
pub capabilities: Capabilities,
|
pub capabilities: Capabilities,
|
||||||
@ -26,6 +29,26 @@ ruma_api! {
|
|||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Request {
|
||||||
|
/// Creates an empty `Request`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given capabilities.
|
||||||
|
pub fn new(capabilities: Capabilities) -> Self {
|
||||||
|
Self { capabilities }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Capabilities> for Response {
|
||||||
|
fn from(capabilities: Capabilities) -> Self {
|
||||||
|
Self::new(capabilities)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Contains information about all the capabilities that the server supports.
|
/// Contains information about all the capabilities that the server supports.
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct Capabilities {
|
pub struct Capabilities {
|
||||||
|
@ -20,6 +20,7 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// The time (in milliseconds) to wait when downloading keys from remote servers.
|
/// The time (in milliseconds) to wait when downloading keys from remote servers.
|
||||||
/// 10 seconds is the recommended default.
|
/// 10 seconds is the recommended default.
|
||||||
@ -34,6 +35,7 @@ ruma_api! {
|
|||||||
pub one_time_keys: BTreeMap<UserId, BTreeMap<DeviceIdBox, DeviceKeyAlgorithm>>,
|
pub one_time_keys: BTreeMap<UserId, BTreeMap<DeviceIdBox, DeviceKeyAlgorithm>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// If any remote homeservers could not be reached, they are recorded here.
|
/// If any remote homeservers could not be reached, they are recorded here.
|
||||||
/// The names of the properties are the names of the unreachable servers.
|
/// The names of the properties are the names of the unreachable servers.
|
||||||
@ -46,5 +48,19 @@ ruma_api! {
|
|||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Request {
|
||||||
|
/// Creates a new `Request` with the given key claims and the recommended 10 second timeout.
|
||||||
|
pub fn new(one_time_keys: BTreeMap<UserId, BTreeMap<DeviceIdBox, DeviceKeyAlgorithm>>) -> Self {
|
||||||
|
Self { timeout: Some(Duration::from_secs(10)), one_time_keys }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given keys and no failures.
|
||||||
|
pub fn new(one_time_keys: BTreeMap<UserId, OneTimeKeys>) -> Self {
|
||||||
|
Self { failures: BTreeMap::new(), one_time_keys }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The one-time keys for a given device.
|
/// The one-time keys for a given device.
|
||||||
pub type OneTimeKeys = BTreeMap<DeviceIdBox, BTreeMap<DeviceKeyId, OneTimeKey>>;
|
pub type OneTimeKeys = BTreeMap<DeviceIdBox, BTreeMap<DeviceKeyId, OneTimeKey>>;
|
||||||
|
@ -13,6 +13,7 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// The desired start point of the list.
|
/// The desired start point of the list.
|
||||||
///
|
///
|
||||||
@ -28,6 +29,7 @@ ruma_api! {
|
|||||||
pub to: &'a str,
|
pub to: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// The Matrix User IDs of all users who updated their device identity keys.
|
/// The Matrix User IDs of all users who updated their device identity keys.
|
||||||
pub changed: Vec<UserId>,
|
pub changed: Vec<UserId>,
|
||||||
@ -39,3 +41,17 @@ ruma_api! {
|
|||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given start and end points.
|
||||||
|
pub fn new(from: &'a str, to: &'a str) -> Self {
|
||||||
|
Self { from, to }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given changed and left user ID lists.
|
||||||
|
pub fn new(changed: Vec<UserId>, left: Vec<UserId>) -> Self {
|
||||||
|
Self { changed, left }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use std::{collections::BTreeMap, time::Duration};
|
use std::{collections::BTreeMap, time::Duration};
|
||||||
|
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
use ruma_common::encryption::DeviceKeys;
|
use ruma_common::encryption::IncomingDeviceKeys;
|
||||||
use ruma_identifiers::{DeviceIdBox, UserId};
|
use ruma_identifiers::{DeviceIdBox, UserId};
|
||||||
use serde_json::Value as JsonValue;
|
use serde_json::Value as JsonValue;
|
||||||
|
|
||||||
@ -20,6 +20,8 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// The time (in milliseconds) to wait when downloading keys from remote
|
/// The time (in milliseconds) to wait when downloading keys from remote
|
||||||
/// servers. 10 seconds is the recommended default.
|
/// servers. 10 seconds is the recommended default.
|
||||||
@ -43,6 +45,8 @@ ruma_api! {
|
|||||||
pub token: Option<&'a str>,
|
pub token: Option<&'a str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// If any remote homeservers could not be reached, they are recorded
|
/// If any remote homeservers could not be reached, they are recorded
|
||||||
/// here. The names of the properties are the names of the unreachable
|
/// here. The names of the properties are the names of the unreachable
|
||||||
@ -52,7 +56,7 @@ ruma_api! {
|
|||||||
|
|
||||||
/// Information on the queried devices.
|
/// Information on the queried devices.
|
||||||
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
||||||
pub device_keys: BTreeMap<UserId, BTreeMap<DeviceIdBox, DeviceKeys>>,
|
pub device_keys: BTreeMap<UserId, BTreeMap<DeviceIdBox, IncomingDeviceKeys>>,
|
||||||
|
|
||||||
/// Information on the master cross-signing keys of the queried users.
|
/// Information on the master cross-signing keys of the queried users.
|
||||||
#[cfg(feature = "unstable-pre-spec")]
|
#[cfg(feature = "unstable-pre-spec")]
|
||||||
@ -72,3 +76,17 @@ ruma_api! {
|
|||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Request<'_> {
|
||||||
|
/// Creates an empty `Request`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates an empty `Response`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -4,7 +4,7 @@ use std::collections::BTreeMap;
|
|||||||
|
|
||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
use ruma_common::encryption::DeviceKeys;
|
use ruma_common::encryption::{DeviceKeys, IncomingDeviceKeys};
|
||||||
use ruma_identifiers::{DeviceKeyAlgorithm, DeviceKeyId};
|
use ruma_identifiers::{DeviceKeyAlgorithm, DeviceKeyId};
|
||||||
|
|
||||||
use super::OneTimeKey;
|
use super::OneTimeKey;
|
||||||
@ -19,16 +19,19 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// Identity keys for the device. May be absent if no new identity keys are required.
|
/// Identity keys for the device. May be absent if no new identity keys are required.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub device_keys: Option<DeviceKeys>,
|
pub device_keys: Option<DeviceKeys<'a>>,
|
||||||
|
|
||||||
/// One-time public keys for "pre-key" messages.
|
/// One-time public keys for "pre-key" messages.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub one_time_keys: Option<BTreeMap<DeviceKeyId, OneTimeKey>>,
|
pub one_time_keys: Option<BTreeMap<DeviceKeyId, OneTimeKey>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// For each key algorithm, the number of unclaimed one-time keys of that
|
/// For each key algorithm, the number of unclaimed one-time keys of that
|
||||||
/// type currently held on the server for this device.
|
/// type currently held on the server for this device.
|
||||||
@ -37,3 +40,17 @@ ruma_api! {
|
|||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Request<'_> {
|
||||||
|
/// Creates an empty `Request`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given one time key counts.
|
||||||
|
pub fn new(one_time_key_counts: BTreeMap<DeviceKeyAlgorithm, UInt>) -> Self {
|
||||||
|
Self { one_time_key_counts }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -15,13 +15,30 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// Signed keys.
|
/// Signed keys.
|
||||||
#[ruma_api(body)]
|
#[ruma_api(body)]
|
||||||
pub signed_keys: BTreeMap<UserId, BTreeMap<String, serde_json::Value>>,
|
pub signed_keys: BTreeMap<UserId, BTreeMap<String, serde_json::Value>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
response: {}
|
response: {}
|
||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Request {
|
||||||
|
/// Creates a new `Request` with the given signed keys.
|
||||||
|
pub fn new(signed_keys: BTreeMap<UserId, BTreeMap<String, serde_json::Value>>) -> Self {
|
||||||
|
Self { signed_keys }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates an empty `Response`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -15,6 +15,8 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// Additional authentication information for the user-interactive authentication API.
|
/// Additional authentication information for the user-interactive authentication API.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
@ -35,7 +37,23 @@ ruma_api! {
|
|||||||
pub user_signing_key: Option<CrossSigningKey>,
|
pub user_signing_key: Option<CrossSigningKey>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
response: {}
|
response: {}
|
||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Request<'_> {
|
||||||
|
/// Creates an empty `Request`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates an empty `Response`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -22,6 +22,7 @@ pub mod set_pushrule_enabled;
|
|||||||
#[derive(
|
#[derive(
|
||||||
Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Display, EnumString,
|
Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Display, EnumString,
|
||||||
)]
|
)]
|
||||||
|
#[non_exhaustive]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
#[strum(serialize_all = "snake_case")]
|
#[strum(serialize_all = "snake_case")]
|
||||||
pub enum RuleKind {
|
pub enum RuleKind {
|
||||||
|
@ -15,6 +15,7 @@ ruma_api! {
|
|||||||
requires_authentication: false,
|
requires_authentication: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// Identification information for the user.
|
/// Identification information for the user.
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
@ -34,6 +35,7 @@ ruma_api! {
|
|||||||
pub initial_device_display_name: Option<&'a str>,
|
pub initial_device_display_name: Option<&'a str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// The fully-qualified Matrix ID that has been registered.
|
/// The fully-qualified Matrix ID that has been registered.
|
||||||
pub user_id: UserId,
|
pub user_id: UserId,
|
||||||
@ -63,6 +65,20 @@ ruma_api! {
|
|||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given user and login info.
|
||||||
|
pub fn new(user: UserInfo<'a>, login_info: LoginInfo<'a>) -> Self {
|
||||||
|
Self { user, login_info, device_id: None, initial_device_display_name: None }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates a new `Response` with the given user ID, access token and device ID.
|
||||||
|
pub fn new(user_id: UserId, access_token: String, device_id: DeviceIdBox) -> Self {
|
||||||
|
Self { user_id, access_token, home_server: None, device_id, well_known: None }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Identification information for the user.
|
/// Identification information for the user.
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Outgoing, Serialize)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Outgoing, Serialize)]
|
||||||
#[serde(from = "user_serde::IncomingUserInfo", into = "user_serde::UserInfo")]
|
#[serde(from = "user_serde::IncomingUserInfo", into = "user_serde::UserInfo")]
|
||||||
|
@ -19,6 +19,7 @@ ruma_api! {
|
|||||||
requires_authentication: true,
|
requires_authentication: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
request: {
|
request: {
|
||||||
/// Type of event being sent to each device.
|
/// Type of event being sent to each device.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
@ -37,7 +38,27 @@ ruma_api! {
|
|||||||
pub messages: BTreeMap<UserId, BTreeMap<DeviceIdOrAllDevices, Box<RawJsonValue>>>
|
pub messages: BTreeMap<UserId, BTreeMap<DeviceIdOrAllDevices, Box<RawJsonValue>>>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
#[non_exhaustive]
|
||||||
response: {}
|
response: {}
|
||||||
|
|
||||||
error: crate::Error
|
error: crate::Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Request<'a> {
|
||||||
|
/// Creates a new `Request` with the given event type, transaction ID and messages.
|
||||||
|
pub fn new(
|
||||||
|
event_type: EventType,
|
||||||
|
txn_id: &'a str,
|
||||||
|
messages: BTreeMap<UserId, BTreeMap<DeviceIdOrAllDevices, Box<RawJsonValue>>>,
|
||||||
|
) -> Self {
|
||||||
|
Self { event_type, txn_id, messages }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Response {
|
||||||
|
/// Creates an empty `Response`.
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -214,15 +214,15 @@ where
|
|||||||
device_id: Option<&DeviceId>,
|
device_id: Option<&DeviceId>,
|
||||||
initial_device_display_name: Option<&str>,
|
initial_device_display_name: Option<&str>,
|
||||||
) -> Result<Session, Error<ruma_client_api::Error>> {
|
) -> Result<Session, Error<ruma_client_api::Error>> {
|
||||||
use ruma_client_api::r0::session::login;
|
use ruma_client_api::r0::session::login::{LoginInfo, Request as LoginRequest, UserInfo};
|
||||||
|
|
||||||
let response = self
|
let response = self
|
||||||
.request(login::Request {
|
.request(assign!(
|
||||||
user: login::UserInfo::MatrixId(user),
|
LoginRequest::new(UserInfo::MatrixId(user), LoginInfo::Password { password }), {
|
||||||
login_info: login::LoginInfo::Password { password },
|
device_id,
|
||||||
device_id,
|
initial_device_display_name,
|
||||||
initial_device_display_name,
|
}
|
||||||
})
|
))
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let session = Session {
|
let session = Session {
|
||||||
|
@ -4,21 +4,24 @@
|
|||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use ruma_identifiers::{DeviceIdBox, DeviceKeyId, EventEncryptionAlgorithm, UserId};
|
use ruma_api::Outgoing;
|
||||||
use serde::{Deserialize, Serialize};
|
use ruma_identifiers::{DeviceId, DeviceKeyId, EventEncryptionAlgorithm, UserId};
|
||||||
|
use ruma_serde::CanBeEmpty;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
/// Identity keys for a device.
|
/// Identity keys for a device.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Outgoing, Serialize)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub struct DeviceKeys {
|
#[incoming_derive(Clone, Serialize)]
|
||||||
|
pub struct DeviceKeys<'a> {
|
||||||
/// The ID of the user the device belongs to. Must match the user ID used when logging in.
|
/// The ID of the user the device belongs to. Must match the user ID used when logging in.
|
||||||
pub user_id: UserId,
|
pub user_id: &'a UserId,
|
||||||
|
|
||||||
/// The ID of the device these keys belong to. Must match the device ID used when logging in.
|
/// The ID of the device these keys belong to. Must match the device ID used when logging in.
|
||||||
pub device_id: DeviceIdBox,
|
pub device_id: &'a DeviceId,
|
||||||
|
|
||||||
/// The encryption algorithms supported by this device.
|
/// The encryption algorithms supported by this device.
|
||||||
pub algorithms: Vec<EventEncryptionAlgorithm>,
|
pub algorithms: &'a [EventEncryptionAlgorithm],
|
||||||
|
|
||||||
/// Public identity keys.
|
/// Public identity keys.
|
||||||
pub keys: BTreeMap<DeviceKeyId, String>,
|
pub keys: BTreeMap<DeviceKeyId, String>,
|
||||||
@ -28,17 +31,17 @@ pub struct DeviceKeys {
|
|||||||
|
|
||||||
/// Additional data added to the device key information by intermediate servers, and
|
/// Additional data added to the device key information by intermediate servers, and
|
||||||
/// not covered by the signatures.
|
/// not covered by the signatures.
|
||||||
#[serde(skip_serializing_if = "UnsignedDeviceInfo::is_empty")]
|
#[serde(skip_serializing_if = "ruma_serde::is_empty")]
|
||||||
pub unsigned: UnsignedDeviceInfo,
|
pub unsigned: UnsignedDeviceInfo<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DeviceKeys {
|
impl<'a> DeviceKeys<'a> {
|
||||||
/// Creates a new `DeviceKeys` from the given user id, device id, algorithms, keys and
|
/// Creates a new `DeviceKeys` from the given user id, device id, algorithms, keys and
|
||||||
/// signatures.
|
/// signatures.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
user_id: UserId,
|
user_id: &'a UserId,
|
||||||
device_id: DeviceIdBox,
|
device_id: &'a DeviceId,
|
||||||
algorithms: Vec<EventEncryptionAlgorithm>,
|
algorithms: &'a [EventEncryptionAlgorithm],
|
||||||
keys: BTreeMap<DeviceKeyId, String>,
|
keys: BTreeMap<DeviceKeyId, String>,
|
||||||
signatures: BTreeMap<UserId, BTreeMap<DeviceKeyId, String>>,
|
signatures: BTreeMap<UserId, BTreeMap<DeviceKeyId, String>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
@ -47,14 +50,16 @@ impl DeviceKeys {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Additional data added to device key information by intermediate servers.
|
/// Additional data added to device key information by intermediate servers.
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, Outgoing, Serialize)]
|
||||||
pub struct UnsignedDeviceInfo {
|
#[non_exhaustive]
|
||||||
|
#[incoming_derive(Clone, Serialize)]
|
||||||
|
pub struct UnsignedDeviceInfo<'a> {
|
||||||
/// The display name which the user set on the device.
|
/// The display name which the user set on the device.
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub device_display_name: Option<String>,
|
pub device_display_name: Option<&'a str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UnsignedDeviceInfo {
|
impl UnsignedDeviceInfo<'_> {
|
||||||
/// Creates an empty `UnsignedDeviceInfo`.
|
/// Creates an empty `UnsignedDeviceInfo`.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Default::default()
|
Default::default()
|
||||||
@ -65,3 +70,22 @@ impl UnsignedDeviceInfo {
|
|||||||
self.device_display_name.is_none()
|
self.device_display_name.is_none()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl IncomingUnsignedDeviceInfo {
|
||||||
|
/// Checks whether all fields are empty / `None`.
|
||||||
|
pub fn is_empty(&self) -> bool {
|
||||||
|
self.device_display_name.is_none()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CanBeEmpty for UnsignedDeviceInfo<'_> {
|
||||||
|
fn is_empty(&self) -> bool {
|
||||||
|
self.is_empty()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CanBeEmpty for IncomingUnsignedDeviceInfo {
|
||||||
|
fn is_empty(&self) -> bool {
|
||||||
|
self.is_empty()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use js_int::UInt;
|
use js_int::UInt;
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
use ruma_common::encryption::DeviceKeys;
|
use ruma_common::encryption::IncomingDeviceKeys;
|
||||||
use ruma_identifiers::{DeviceIdBox, UserId};
|
use ruma_identifiers::{DeviceIdBox, UserId};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ pub struct UserDevice {
|
|||||||
pub device_id: DeviceIdBox,
|
pub device_id: DeviceIdBox,
|
||||||
|
|
||||||
/// Identity keys for the device.
|
/// Identity keys for the device.
|
||||||
pub keys: DeviceKeys,
|
pub keys: IncomingDeviceKeys,
|
||||||
|
|
||||||
/// Optional display name for the device
|
/// Optional display name for the device
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
@ -71,7 +71,7 @@ pub struct UserDevice {
|
|||||||
|
|
||||||
impl UserDevice {
|
impl UserDevice {
|
||||||
/// Creates a new `UserDevice` with the given device id and keys.
|
/// Creates a new `UserDevice` with the given device id and keys.
|
||||||
pub fn new(device_id: DeviceIdBox, keys: DeviceKeys) -> Self {
|
pub fn new(device_id: DeviceIdBox, keys: IncomingDeviceKeys) -> Self {
|
||||||
Self { device_id, keys, device_display_name: None }
|
Self { device_id, keys, device_display_name: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use ruma_api::ruma_api;
|
use ruma_api::ruma_api;
|
||||||
use ruma_common::encryption::DeviceKeys;
|
use ruma_common::encryption::IncomingDeviceKeys;
|
||||||
use ruma_identifiers::{DeviceIdBox, UserId};
|
use ruma_identifiers::{DeviceIdBox, UserId};
|
||||||
|
|
||||||
ruma_api! {
|
ruma_api! {
|
||||||
@ -26,7 +26,7 @@ ruma_api! {
|
|||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
response: {
|
response: {
|
||||||
/// Keys from the queried devices.
|
/// Keys from the queried devices.
|
||||||
pub device_keys: BTreeMap<UserId, BTreeMap<DeviceIdBox, DeviceKeys>>,
|
pub device_keys: BTreeMap<UserId, BTreeMap<DeviceIdBox, IncomingDeviceKeys>>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ impl Request {
|
|||||||
|
|
||||||
impl Response {
|
impl Response {
|
||||||
/// Creates a new `Response` with the given device keys.
|
/// Creates a new `Response` with the given device keys.
|
||||||
pub fn new(device_keys: BTreeMap<UserId, BTreeMap<DeviceIdBox, DeviceKeys>>) -> Self {
|
pub fn new(device_keys: BTreeMap<UserId, BTreeMap<DeviceIdBox, IncomingDeviceKeys>>) -> Self {
|
||||||
Self { device_keys }
|
Self { device_keys }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user