pub mod v1 {
use std::collections::BTreeMap;
use ruma_common::{
OwnedDeviceId, OwnedUserId,
api::{request, response},
encryption::{CrossSigningKey, DeviceKeys},
metadata,
serde::Raw,
};
use crate::authentication::ServerSignatures;
metadata! {
method: POST,
rate_limited: false,
authentication: ServerSignatures,
path: "/_matrix/federation/v1/user/keys/query",
}
#[request]
pub struct Request {
pub device_keys: BTreeMap<OwnedUserId, Vec<OwnedDeviceId>>,
}
#[response]
#[derive(Default)]
pub struct Response {
pub device_keys: BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, Raw<DeviceKeys>>>,
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
pub master_keys: BTreeMap<OwnedUserId, Raw<CrossSigningKey>>,
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
pub self_signing_keys: BTreeMap<OwnedUserId, Raw<CrossSigningKey>>,
}
impl Request {
pub fn new(device_keys: BTreeMap<OwnedUserId, Vec<OwnedDeviceId>>) -> Self {
Self { device_keys }
}
}
impl Response {
pub fn new(
device_keys: BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, Raw<DeviceKeys>>>,
) -> Self {
Self { device_keys, ..Default::default() }
}
}
}