ruma_federation_api/discovery/
get_server_keys.rs

1//! `GET /_matrix/key/*/server`
2//!
3//! Get the homeserver's published signing keys.
4
5pub mod v2 {
6    //! `/v2/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/server-server-api/#get_matrixkeyv2server
9
10    use ruma_common::{
11        api::{auth_scheme::NoAuthentication, request, response},
12        metadata,
13        serde::Raw,
14    };
15
16    use crate::discovery::ServerSigningKeys;
17
18    metadata! {
19        method: GET,
20        rate_limited: false,
21        authentication: NoAuthentication,
22        path: "/_matrix/key/v2/server",
23    }
24
25    /// Request type for the `get_server_keys` endpoint.
26    #[request]
27    #[derive(Default)]
28    pub struct Request {}
29
30    /// Response type for the `get_server_keys` endpoint.
31    #[response]
32    pub struct Response {
33        /// Queried server key, signed by the notary server.
34        #[ruma_api(body)]
35        pub server_key: Raw<ServerSigningKeys>,
36    }
37
38    impl Request {
39        /// Creates an empty `Request`.
40        pub fn new() -> Self {
41            Self {}
42        }
43    }
44
45    impl Response {
46        /// Creates a new `Response` with the given server key.
47        pub fn new(server_key: Raw<ServerSigningKeys>) -> Self {
48            Self { server_key }
49        }
50    }
51
52    impl From<Raw<ServerSigningKeys>> for Response {
53        fn from(server_key: Raw<ServerSigningKeys>) -> Self {
54            Self::new(server_key)
55        }
56    }
57}