federation-api: Use Raw around CrossSigningKey, DeviceKeys, OneTimeKey
This commit is contained in:
parent
1a9047a715
commit
d3679c1902
@ -4,6 +4,7 @@ use js_int::UInt;
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_common::encryption::DeviceKeys;
|
||||
use ruma_identifiers::{DeviceId, UserId};
|
||||
use ruma_serde::Raw;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
ruma_api! {
|
||||
@ -63,7 +64,7 @@ pub struct UserDevice {
|
||||
pub device_id: Box<DeviceId>,
|
||||
|
||||
/// Identity keys for the device.
|
||||
pub keys: DeviceKeys,
|
||||
pub keys: Raw<DeviceKeys>,
|
||||
|
||||
/// Optional display name for the device
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
@ -72,7 +73,7 @@ pub struct UserDevice {
|
||||
|
||||
impl UserDevice {
|
||||
/// Creates a new `UserDevice` with the given device id and keys.
|
||||
pub fn new(device_id: Box<DeviceId>, keys: DeviceKeys) -> Self {
|
||||
pub fn new(device_id: Box<DeviceId>, keys: Raw<DeviceKeys>) -> Self {
|
||||
Self { device_id, keys, device_display_name: None }
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ use std::collections::BTreeMap;
|
||||
use ruma_api::ruma_api;
|
||||
use ruma_common::encryption::OneTimeKey;
|
||||
use ruma_identifiers::{DeviceId, DeviceKeyAlgorithm, DeviceKeyId, UserId};
|
||||
use ruma_serde::Raw;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
ruma_api! {
|
||||
@ -48,7 +49,7 @@ pub type OneTimeKeyClaims = BTreeMap<Box<UserId>, BTreeMap<Box<DeviceId>, Device
|
||||
|
||||
/// One time keys for use in pre-key messages
|
||||
pub type OneTimeKeys =
|
||||
BTreeMap<Box<UserId>, BTreeMap<Box<DeviceId>, BTreeMap<Box<DeviceKeyId>, OneTimeKey>>>;
|
||||
BTreeMap<Box<UserId>, BTreeMap<Box<DeviceId>, BTreeMap<Box<DeviceKeyId>, Raw<OneTimeKey>>>>;
|
||||
|
||||
/// A key and its signature
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
@ -7,6 +7,7 @@ use ruma_api::ruma_api;
|
||||
use ruma_common::encryption::CrossSigningKey;
|
||||
use ruma_common::encryption::DeviceKeys;
|
||||
use ruma_identifiers::{DeviceId, UserId};
|
||||
use ruma_serde::Raw;
|
||||
|
||||
ruma_api! {
|
||||
metadata: {
|
||||
@ -28,17 +29,17 @@ ruma_api! {
|
||||
#[derive(Default)]
|
||||
response: {
|
||||
/// Keys from the queried devices.
|
||||
pub device_keys: BTreeMap<Box<UserId>, BTreeMap<Box<DeviceId>, DeviceKeys>>,
|
||||
pub device_keys: BTreeMap<Box<UserId>, BTreeMap<Box<DeviceId>, Raw<DeviceKeys>>>,
|
||||
|
||||
/// Information on the master cross-signing keys of the queried users.
|
||||
#[cfg(feature = "unstable-pre-spec")]
|
||||
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
||||
pub master_keys: BTreeMap<Box<UserId>, CrossSigningKey>,
|
||||
pub master_keys: BTreeMap<Box<UserId>, Raw<CrossSigningKey>>,
|
||||
|
||||
/// Information on the self-signing keys of the queried users.
|
||||
#[cfg(feature = "unstable-pre-spec")]
|
||||
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
||||
pub self_signing_keys: BTreeMap<Box<UserId>, CrossSigningKey>,
|
||||
pub self_signing_keys: BTreeMap<Box<UserId>, Raw<CrossSigningKey>>,
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,7 +52,9 @@ impl Request {
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Response` with the given device keys.
|
||||
pub fn new(device_keys: BTreeMap<Box<UserId>, BTreeMap<Box<DeviceId>, DeviceKeys>>) -> Self {
|
||||
pub fn new(
|
||||
device_keys: BTreeMap<Box<UserId>, BTreeMap<Box<DeviceId>, Raw<DeviceKeys>>>,
|
||||
) -> Self {
|
||||
Self { device_keys, ..Default::default() }
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ pub struct DeviceListUpdateContent {
|
||||
|
||||
/// The updated identity keys (if any) for this device.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub keys: Option<DeviceKeys>,
|
||||
pub keys: Option<Raw<DeviceKeys>>,
|
||||
}
|
||||
|
||||
impl DeviceListUpdateContent {
|
||||
|
Loading…
x
Reference in New Issue
Block a user