Use DeviceIdBox in ruma-events, ruma-*-api

This commit is contained in:
Jonas Platte 2020-08-13 21:13:36 +02:00
parent f210f91611
commit 4a1b6d5607
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
19 changed files with 45 additions and 45 deletions

View File

@ -1,7 +1,7 @@
//! [POST /_matrix/client/r0/register](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-register)
use ruma_api::ruma_api;
use ruma_identifiers::{DeviceId, UserId};
use ruma_identifiers::{DeviceId, DeviceIdBox, UserId};
use serde::{Deserialize, Serialize};
use crate::r0::uiaa::{AuthData, IncomingAuthData, UiaaResponse};
@ -78,7 +78,7 @@ ruma_api! {
/// ID of the registered device.
///
/// Will be the same as the corresponding parameter in the request, if one was specified.
pub device_id: Option<Box<DeviceId>>,
pub device_id: Option<DeviceIdBox>,
}
error: UiaaResponse

View File

@ -2,7 +2,7 @@
use std::time::SystemTime;
use ruma_identifiers::DeviceId;
use ruma_identifiers::DeviceIdBox;
use serde::{Deserialize, Serialize};
pub mod delete_device;
@ -15,7 +15,7 @@ pub mod update_device;
#[derive(Clone, Debug, Deserialize, Hash, PartialEq, Serialize)]
pub struct Device {
/// Device ID
pub device_id: Box<DeviceId>,
pub device_id: DeviceIdBox,
/// Public display name of the device.
pub display_name: Option<String>,

View File

@ -1,7 +1,7 @@
//! [POST /_matrix/client/r0/delete_devices](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-delete-devices)
use ruma_api::ruma_api;
use ruma_identifiers::DeviceId;
use ruma_identifiers::DeviceIdBox;
use crate::r0::uiaa::{AuthData, IncomingAuthData, UiaaResponse};
@ -17,7 +17,7 @@ ruma_api! {
request: {
/// List of devices to delete.
pub devices: &'a [Box<DeviceId>],
pub devices: &'a [DeviceIdBox],
/// Additional authentication information for the user-interactive authentication API.
#[serde(skip_serializing_if = "Option::is_none")]

View File

@ -17,7 +17,7 @@ ruma_api! {
request: {
/// The device to retrieve.
#[ruma_api(path)]
pub device_id: Box<DeviceId>,
pub device_id: &'a DeviceId,
}
response: {

View File

@ -16,7 +16,7 @@ ruma_api! {
request: {
/// The device to update.
#[ruma_api(path)]
pub device_id: Box<DeviceId>,
pub device_id: &'a DeviceId,
/// The new display name for this device. If this is `None`, the display name won't be
/// changed.

View File

@ -5,7 +5,7 @@ use std::collections::BTreeMap;
use std::time::Duration;
use ruma_api::ruma_api;
use ruma_identifiers::{DeviceId, DeviceKeyAlgorithm, DeviceKeyId, UserId};
use ruma_identifiers::{DeviceIdBox, DeviceKeyAlgorithm, DeviceKeyId, UserId};
use serde_json::Value as JsonValue;
use super::OneTimeKey;
@ -31,7 +31,7 @@ ruma_api! {
pub timeout: Option<Duration>,
/// The keys to be claimed.
pub one_time_keys: BTreeMap<UserId, BTreeMap<Box<DeviceId>, DeviceKeyAlgorithm>>,
pub one_time_keys: BTreeMap<UserId, BTreeMap<DeviceIdBox, DeviceKeyAlgorithm>>,
}
response: {
@ -47,4 +47,4 @@ ruma_api! {
}
/// The one-time keys for a given device.
pub type OneTimeKeys = BTreeMap<Box<DeviceId>, BTreeMap<DeviceKeyId, OneTimeKey>>;
pub type OneTimeKeys = BTreeMap<DeviceIdBox, BTreeMap<DeviceKeyId, OneTimeKey>>;

View File

@ -4,7 +4,7 @@ use std::{collections::BTreeMap, time::Duration};
use ruma_api::ruma_api;
use ruma_common::encryption::DeviceKeys;
use ruma_identifiers::{DeviceId, UserId};
use ruma_identifiers::{DeviceIdBox, UserId};
use serde_json::Value as JsonValue;
#[cfg(feature = "unstable-pre-spec")]
@ -32,7 +32,7 @@ ruma_api! {
/// The keys to be downloaded. An empty list indicates all devices for
/// the corresponding user.
pub device_keys: BTreeMap<UserId, Vec<Box<DeviceId>>>,
pub device_keys: BTreeMap<UserId, Vec<DeviceIdBox>>,
/// If the client is fetching keys as a result of a device update
/// received in a sync request, this should be the 'since' token of that
@ -52,7 +52,7 @@ ruma_api! {
/// Information on the queried devices.
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
pub device_keys: BTreeMap<UserId, BTreeMap<Box<DeviceId>, DeviceKeys>>,
pub device_keys: BTreeMap<UserId, BTreeMap<DeviceIdBox, DeviceKeys>>,
/// Information on the master cross-signing keys of the queried users.
#[cfg(feature = "unstable-pre-spec")]

View File

@ -2,7 +2,7 @@
use ruma_api::ruma_api;
use ruma_common::thirdparty::Medium;
use ruma_identifiers::{DeviceId, ServerName, UserId};
use ruma_identifiers::{DeviceIdBox, ServerName, UserId};
use serde::{Deserialize, Serialize};
ruma_api! {
@ -26,7 +26,7 @@ ruma_api! {
/// ID of the client device
#[serde(skip_serializing_if = "Option::is_none")]
pub device_id: Option<Box<DeviceId>>,
pub device_id: Option<DeviceIdBox>,
/// A display name to assign to the newly-created device. Ignored if device_id corresponds
/// to a known device.
@ -52,7 +52,7 @@ ruma_api! {
///
/// Will be the same as the corresponding parameter in the request, if one was
/// specified.
pub device_id: Box<DeviceId>,
pub device_id: DeviceIdBox,
/// Client configuration provided by the server.
///

View File

@ -5,7 +5,7 @@ use std::{
fmt::{Display, Formatter, Result as FmtResult},
};
use ruma_identifiers::DeviceId;
use ruma_identifiers::DeviceIdBox;
use serde::{
de::{self, Unexpected},
Deserialize, Deserializer, Serialize, Serializer,
@ -17,7 +17,7 @@ pub mod send_event_to_device;
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum DeviceIdOrAllDevices {
/// Represents a device Id for one of a user's devices.
DeviceId(Box<DeviceId>),
DeviceId(DeviceIdBox),
/// Represents all devices for a user.
AllDevices,

View File

@ -117,7 +117,7 @@ use ruma_api::OutgoingRequest;
use ruma_client_api::r0::sync::sync_events::{
Filter as SyncFilter, Request as SyncRequest, Response as SyncResponse,
};
use ruma_identifiers::DeviceId;
use ruma_identifiers::DeviceIdBox;
use ruma_serde::urlencoded;
use std::collections::BTreeMap;
@ -211,7 +211,7 @@ where
&self,
user: String,
password: String,
device_id: Option<Box<DeviceId>>,
device_id: Option<DeviceIdBox>,
initial_device_display_name: Option<String>,
) -> Result<Session, Error<ruma_client_api::Error>> {
use ruma_client_api::r0::session::login;

View File

@ -1,6 +1,6 @@
//! User sessions.
use ruma_identifiers::{DeviceId, UserId};
use ruma_identifiers::{DeviceId, DeviceIdBox, UserId};
/// A user session, containing an access token and information about the associated user account.
#[derive(Clone, Debug, serde::Deserialize, Eq, Hash, PartialEq, serde::Serialize)]
@ -18,13 +18,13 @@ pub struct Identification {
/// The user the access token was issued for.
pub user_id: UserId,
/// The ID of the client device
pub device_id: Box<DeviceId>,
pub device_id: DeviceIdBox,
}
impl Session {
/// Create a new user session from an access token and a user ID.
#[deprecated]
pub fn new(access_token: String, user_id: UserId, device_id: Box<DeviceId>) -> Self {
pub fn new(access_token: String, user_id: UserId, device_id: DeviceIdBox) -> Self {
Self { access_token, identification: Some(Identification { user_id, device_id }) }
}

View File

@ -4,7 +4,7 @@
use std::collections::BTreeMap;
use ruma_identifiers::{DeviceId, DeviceKeyId, EventEncryptionAlgorithm, UserId};
use ruma_identifiers::{DeviceIdBox, DeviceKeyId, EventEncryptionAlgorithm, UserId};
use serde::{Deserialize, Serialize};
/// Identity keys for a device.
@ -14,7 +14,7 @@ pub struct DeviceKeys {
pub user_id: UserId,
/// The ID of the device these keys belong to. Must match the device ID used when logging in.
pub device_id: Box<DeviceId>,
pub device_id: DeviceIdBox,
/// The encryption algorithms supported by this device.
pub algorithms: Vec<EventEncryptionAlgorithm>,

View File

@ -3,7 +3,7 @@
use std::time::SystemTime;
use ruma_events_macros::BasicEventContent;
use ruma_identifiers::DeviceId;
use ruma_identifiers::DeviceIdBox;
use serde::{Deserialize, Serialize};
use super::VerificationMethod;
@ -19,7 +19,7 @@ pub type RequestEvent = BasicEvent<RequestEventContent>;
#[ruma_event(type = "m.key.verification.request")]
pub struct RequestEventContent {
/// The device ID which is initiating the request.
pub from_device: Box<DeviceId>,
pub from_device: DeviceIdBox,
/// An opaque identifier for the verification request.
///

View File

@ -3,7 +3,7 @@
use std::{collections::BTreeMap, convert::TryFrom};
use ruma_events_macros::BasicEventContent;
use ruma_identifiers::DeviceId;
use ruma_identifiers::DeviceIdBox;
use serde::{Deserialize, Serialize};
use serde_json::Value as JsonValue;
@ -22,7 +22,7 @@ pub type StartEvent = BasicEvent<StartEventContent>;
#[ruma_event(type = "m.key.verification.start")]
pub struct StartEventContent {
/// The device ID which is initiating the process.
pub from_device: Box<DeviceId>,
pub from_device: DeviceIdBox,
/// An opaque identifier for the verification process.
///

View File

@ -4,7 +4,7 @@ use std::collections::BTreeMap;
use js_int::UInt;
use ruma_events_macros::MessageEventContent;
use ruma_identifiers::DeviceId;
use ruma_identifiers::DeviceIdBox;
use serde::{Deserialize, Serialize};
use crate::MessageEvent;
@ -80,7 +80,7 @@ pub struct MegolmV1AesSha2Content {
pub sender_key: String,
/// The ID of the sending device.
pub device_id: Box<DeviceId>,
pub device_id: DeviceIdBox,
/// The ID of the session used to encrypt the message.
pub session_id: String,
@ -99,7 +99,7 @@ pub struct MegolmV1AesSha2ContentInit {
pub sender_key: String,
/// The ID of the sending device.
pub device_id: Box<DeviceId>,
pub device_id: DeviceIdBox,
/// The ID of the session used to encrypt the message.
pub session_id: String,

View File

@ -1,7 +1,7 @@
//! Types for the *m.room_key_request* event.
use ruma_events_macros::BasicEventContent;
use ruma_identifiers::{DeviceId, EventEncryptionAlgorithm, RoomId};
use ruma_identifiers::{DeviceIdBox, EventEncryptionAlgorithm, RoomId};
use serde::{Deserialize, Serialize};
use strum::{Display, EnumString};
@ -25,7 +25,7 @@ pub struct RoomKeyRequestEventContent {
pub body: Option<RequestedKeyInfo>,
/// ID of the device requesting the key.
pub requesting_device_id: Box<DeviceId>,
pub requesting_device_id: DeviceIdBox,
/// A random string uniquely identifying the request for a key.
///

View File

@ -3,7 +3,7 @@
use js_int::UInt;
use ruma_api::ruma_api;
use ruma_common::encryption::DeviceKeys;
use ruma_identifiers::{DeviceId, UserId};
use ruma_identifiers::{DeviceIdBox, UserId};
use serde::{Deserialize, Serialize};
ruma_api! {
@ -40,7 +40,7 @@ ruma_api! {
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct UserDevice {
/// The device ID.
pub device_id: Box<DeviceId>,
pub device_id: DeviceIdBox,
/// Identity keys for the device.
pub keys: DeviceKeys,

View File

@ -4,7 +4,7 @@
use std::collections::BTreeMap;
use ruma_api::ruma_api;
use ruma_identifiers::{DeviceId, DeviceKeyAlgorithm, DeviceKeyId, UserId};
use ruma_identifiers::{DeviceIdBox, DeviceKeyAlgorithm, DeviceKeyId, UserId};
use serde::{Deserialize, Serialize};
ruma_api! {
@ -29,10 +29,10 @@ ruma_api! {
}
/// A claim for one time keys
pub type OneTimeKeyClaims = BTreeMap<UserId, BTreeMap<Box<DeviceId>, DeviceKeyAlgorithm>>;
pub type OneTimeKeyClaims = BTreeMap<UserId, BTreeMap<DeviceIdBox, DeviceKeyAlgorithm>>;
/// One time keys for use in pre-key messages
pub type OneTimeKeys = BTreeMap<UserId, BTreeMap<Box<DeviceId>, BTreeMap<DeviceKeyId, KeyObject>>>;
pub type OneTimeKeys = BTreeMap<UserId, BTreeMap<DeviceIdBox, BTreeMap<DeviceKeyId, KeyObject>>>;
/// A key and its signature
#[non_exhaustive]

View File

@ -4,7 +4,7 @@ use std::collections::BTreeMap;
use ruma_api::ruma_api;
use ruma_common::encryption::DeviceKeys;
use ruma_identifiers::{DeviceId, UserId};
use ruma_identifiers::{DeviceIdBox, UserId};
ruma_api! {
metadata: {
@ -19,25 +19,25 @@ ruma_api! {
request: {
/// The keys to be downloaded. Gives all keys for a given user if the list of device ids is
/// empty.
device_keys: BTreeMap<UserId, Vec<Box<DeviceId>>>,
device_keys: BTreeMap<UserId, Vec<DeviceIdBox>>,
}
response: {
/// Keys from the queried devices.
device_keys: BTreeMap<UserId, BTreeMap<Box<DeviceId>, DeviceKeys>>,
device_keys: BTreeMap<UserId, BTreeMap<DeviceIdBox, DeviceKeys>>,
}
}
impl Request {
/// Creates a new `Request` asking for the given device keys.
pub fn new(device_keys: BTreeMap<UserId, Vec<Box<DeviceId>>>) -> Self {
pub fn new(device_keys: BTreeMap<UserId, Vec<DeviceIdBox>>) -> Self {
Self { device_keys }
}
}
impl Response {
/// Creates a new `Response` with the given device keys.
pub fn new(device_keys: BTreeMap<UserId, BTreeMap<Box<DeviceId>, DeviceKeys>>) -> Self {
pub fn new(device_keys: BTreeMap<UserId, BTreeMap<DeviceIdBox, DeviceKeys>>) -> Self {
Self { device_keys }
}
}