1//! `POST /_matrix/federation/*/user/keys/query`
2//!
3//! Get the current devices and identity keys for the given users.
45pub mod v1 {
6//! `/v1/` ([spec])
7 //!
8 //! [spec]: https://spec.matrix.org/latest/server-server-api/#post_matrixfederationv1userkeysquery
910use std::collections::BTreeMap;
1112use ruma_common::{
13 api::{request, response, Metadata},
14 encryption::{CrossSigningKey, DeviceKeys},
15 metadata,
16 serde::Raw,
17 OwnedDeviceId, OwnedUserId,
18 };
1920const METADATA: Metadata = metadata! {
21 method: POST,
22 rate_limited: false,
23 authentication: ServerSignatures,
24 history: {
251.0 => "/_matrix/federation/v1/user/keys/query",
26 }
27 };
2829/// Request type for the `get_keys` endpoint.
30#[request]
31pub struct Request {
32/// The keys to be downloaded.
33 ///
34 /// Gives all keys for a given user if the list of device ids is empty.
35pub device_keys: BTreeMap<OwnedUserId, Vec<OwnedDeviceId>>,
36 }
3738/// Response type for the `get_keys` endpoint.
39#[response]
40 #[derive(Default)]
41pub struct Response {
42/// Keys from the queried devices.
43pub device_keys: BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, Raw<DeviceKeys>>>,
4445/// Information on the master cross-signing keys of the queried users.
46#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
47pub master_keys: BTreeMap<OwnedUserId, Raw<CrossSigningKey>>,
4849/// Information on the self-signing keys of the queried users.
50#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
51pub self_signing_keys: BTreeMap<OwnedUserId, Raw<CrossSigningKey>>,
52 }
5354impl Request {
55/// Creates a new `Request` asking for the given device keys.
56pub fn new(device_keys: BTreeMap<OwnedUserId, Vec<OwnedDeviceId>>) -> Self {
57Self { device_keys }
58 }
59 }
6061impl Response {
62/// Creates a new `Response` with the given device keys.
63pub fn new(
64 device_keys: BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, Raw<DeviceKeys>>>,
65 ) -> Self {
66Self { device_keys, ..Default::default() }
67 }
68 }
69}