Add get_keys endpoint and changelog entry

This commit is contained in:
Amanda Graven 2020-08-11 15:58:38 +02:00
parent de337ecb8c
commit 636cc503ed
No known key found for this signature in database
GPG Key ID: 45C461CDC9286390
4 changed files with 51 additions and 1 deletions

View File

@ -6,7 +6,10 @@ Improvements:
``` ```
device::get_devices::v1, device::get_devices::v1,
keys::claim_keys::v1, keys::{
claim_keys::v1,
query_keys::v1,
},
``` ```
# 0.0.3 # 0.0.3

View File

@ -1,3 +1,4 @@
//! Endpoints for handling keys for end-to-end encryption //! Endpoints for handling keys for end-to-end encryption
pub mod claim_keys; pub mod claim_keys;
pub mod get_keys;

View File

@ -0,0 +1,3 @@
//! Module for getting information about the current devices and identity keys for the given users
pub mod v1;

View File

@ -0,0 +1,43 @@
//! [POST /_matrix/federation/v1/user/keys/query](https://matrix.org/docs/spec/server_server/r0.1.4#post-matrix-federation-v1-user-keys-claim)
use std::collections::BTreeMap;
use ruma_api::ruma_api;
use ruma_common::encryption::DeviceKeys;
use ruma_identifiers::{DeviceId, UserId};
ruma_api! {
metadata: {
description: "Returns the current devices and identity keys for the given users.",
method: POST,
name: "get_keys",
path: "/_matrix/federation/v1/user/keys/query",
rate_limited: false,
requires_authentication: true,
}
request: {
/// The keys to be downloaded. Gives all keys for a given user if the list of device ids is
/// empty.
device_keys: BTreeMap<UserId, Vec<Box<DeviceId>>>,
}
response: {
/// Keys from the queried devices.
device_keys: BTreeMap<UserId, BTreeMap<Box<DeviceId>, DeviceKeys>>,
}
}
impl Request {
/// Creates a new `Request` asking for the given device keys.
pub fn new(device_keys: BTreeMap<UserId, Vec<Box<DeviceId>>>) -> Self {
Self { device_keys }
}
}
impl Response {
/// Creates a new `Response` with the given device keys.
pub fn new(device_keys: BTreeMap<UserId, BTreeMap<Box<DeviceId>, DeviceKeys>>) -> Self {
Self { device_keys }
}
}