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