pub mod v1 {
use js_int::UInt;
use ruma_common::{
OwnedDeviceId, OwnedUserId,
api::{request, response},
encryption::{CrossSigningKey, DeviceKeys},
metadata,
serde::Raw,
};
use serde::{Deserialize, Serialize};
use crate::authentication::ServerSignatures;
metadata! {
method: GET,
rate_limited: false,
authentication: ServerSignatures,
path: "/_matrix/federation/v1/user/devices/{user_id}",
}
#[request]
pub struct Request {
#[ruma_api(path)]
pub user_id: OwnedUserId,
}
#[response]
pub struct Response {
pub user_id: OwnedUserId,
pub stream_id: UInt,
pub devices: Vec<UserDevice>,
#[serde(skip_serializing_if = "Option::is_none")]
pub master_key: Option<Raw<CrossSigningKey>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub self_signing_key: Option<Raw<CrossSigningKey>>,
}
impl Request {
pub fn new(user_id: OwnedUserId) -> Self {
Self { user_id }
}
}
impl Response {
pub fn new(user_id: OwnedUserId, stream_id: UInt) -> Self {
Self {
user_id,
stream_id,
devices: Vec::new(),
master_key: None,
self_signing_key: None,
}
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
pub struct UserDevice {
pub device_id: OwnedDeviceId,
pub keys: Raw<DeviceKeys>,
#[serde(skip_serializing_if = "Option::is_none")]
pub device_display_name: Option<String>,
}
impl UserDevice {
pub fn new(device_id: OwnedDeviceId, keys: Raw<DeviceKeys>) -> Self {
Self { device_id, keys, device_display_name: None }
}
}
}