1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
pub mod v3 {
use std::collections::BTreeMap;
use ruma_common::{
api::ruma_api,
encryption::{CrossSigningKey, DeviceKeys},
serde::{Raw, StringEnum},
OwnedDeviceId, OwnedUserId,
};
use serde::{Deserialize, Serialize};
use serde_json::value::RawValue as RawJsonValue;
use crate::PrivOwnedStr;
pub use super::iter::SignedKeysIter;
ruma_api! {
metadata: {
description: "Publishes cross-signing signatures for the user.",
method: POST,
name: "upload_signatures",
unstable_path: "/_matrix/client/unstable/keys/signatures/upload",
stable_path: "/_matrix/client/v3/keys/signatures/upload",
rate_limited: false,
authentication: AccessToken,
added: 1.1,
}
request: {
#[ruma_api(body)]
pub signed_keys: BTreeMap<OwnedUserId, SignedKeys>,
}
#[derive(Default)]
response: {
pub failures: BTreeMap<OwnedUserId, BTreeMap<String, Failure>>,
}
error: crate::Error
}
impl Request {
pub fn new(signed_keys: BTreeMap<OwnedUserId, SignedKeys>) -> Self {
Self { signed_keys }
}
}
impl Response {
pub fn new() -> Self {
Self::default()
}
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[serde(transparent)]
pub struct SignedKeys(BTreeMap<Box<str>, Box<RawJsonValue>>);
impl SignedKeys {
pub fn new() -> Self {
Self::default()
}
pub fn add_device_keys(&mut self, device_id: OwnedDeviceId, device_keys: Raw<DeviceKeys>) {
self.0.insert(device_id.as_str().into(), device_keys.into_json());
}
pub fn add_cross_signing_keys(
&mut self,
cross_signing_key_id: Box<str>,
cross_signing_keys: Raw<CrossSigningKey>,
) {
self.0.insert(cross_signing_key_id, cross_signing_keys.into_json());
}
pub fn iter(&self) -> SignedKeysIter<'_> {
SignedKeysIter(self.0.iter())
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Failure {
errcode: FailureErrorCode,
error: String,
}
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[non_exhaustive]
#[ruma_enum(rename_all = "M_MATRIX_ERROR_CASE")]
pub enum FailureErrorCode {
InvalidSignature,
#[doc(hidden)]
_Custom(PrivOwnedStr),
}
}
mod iter;