Skip to main content

tuwunel_api_client/dehydrated_device/
get_dehydrated_device.rs

1use axum::extract::State;
2use ruma::api::client::dehydrated_device::get_dehydrated_device::unstable::{Request, Response};
3use tuwunel_core::Result;
4
5use crate::{ClientIp, Ruma};
6
7/// # `GET /_matrix/client/../dehydrated_device`
8///
9/// Returns the user's dehydrated device.
10///
11/// The device data is opaque to the server and comes back as the client
12/// stored it. A user without one gets `M_NOT_FOUND`.
13#[tracing::instrument(
14	level = "debug",
15	skip_all,
16	fields(
17		%client,
18	),
19)]
20pub(crate) async fn get_dehydrated_device_route(
21	State(services): State<crate::State>,
22	ClientIp(client): ClientIp,
23	body: Ruma<Request>,
24) -> Result<Response> {
25	let sender_user = body.sender_user();
26
27	let device = services
28		.users
29		.get_dehydrated_device(sender_user)
30		.await?;
31
32	Ok(Response {
33		device_id: device.device_id,
34		device_data: device.device_data,
35	})
36}