ruma_federation_api/keys/
get_keys.rs1pub mod v1 {
6 use std::collections::BTreeMap;
11
12 use ruma_common::{
13 api::{request, response, Metadata},
14 encryption::{CrossSigningKey, DeviceKeys},
15 metadata,
16 serde::Raw,
17 OwnedDeviceId, OwnedUserId,
18 };
19
20 const METADATA: Metadata = metadata! {
21 method: POST,
22 rate_limited: false,
23 authentication: ServerSignatures,
24 history: {
25 1.0 => "/_matrix/federation/v1/user/keys/query",
26 }
27 };
28
29 #[request]
31 pub struct Request {
32 pub device_keys: BTreeMap<OwnedUserId, Vec<OwnedDeviceId>>,
36 }
37
38 #[response]
40 #[derive(Default)]
41 pub struct Response {
42 pub device_keys: BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, Raw<DeviceKeys>>>,
44
45 #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
47 pub master_keys: BTreeMap<OwnedUserId, Raw<CrossSigningKey>>,
48
49 #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
51 pub self_signing_keys: BTreeMap<OwnedUserId, Raw<CrossSigningKey>>,
52 }
53
54 impl Request {
55 pub fn new(device_keys: BTreeMap<OwnedUserId, Vec<OwnedDeviceId>>) -> Self {
57 Self { device_keys }
58 }
59 }
60
61 impl Response {
62 pub fn new(
64 device_keys: BTreeMap<OwnedUserId, BTreeMap<OwnedDeviceId, Raw<DeviceKeys>>>,
65 ) -> Self {
66 Self { device_keys, ..Default::default() }
67 }
68 }
69}