ruma_client_api/server/
get_user_info.rs1pub mod v3 {
6 use std::collections::BTreeMap;
11
12 use ruma_common::{
13 api::{request, response, Metadata},
14 metadata, MilliSecondsSinceUnixEpoch, OwnedUserId,
15 };
16 use serde::{Deserialize, Serialize};
17
18 const METADATA: Metadata = metadata! {
19 method: GET,
20 rate_limited: false,
21 authentication: AccessToken,
22 history: {
23 1.0 => "/_matrix/client/r0/admin/whois/:user_id",
24 1.1 => "/_matrix/client/v3/admin/whois/:user_id",
25 }
26 };
27
28 #[request(error = crate::Error)]
30 pub struct Request {
31 #[ruma_api(path)]
33 pub user_id: OwnedUserId,
34 }
35
36 #[response(error = crate::Error)]
38 #[derive(Default)]
39 pub struct Response {
40 #[serde(skip_serializing_if = "Option::is_none")]
42 pub user_id: Option<OwnedUserId>,
43
44 #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
46 pub devices: BTreeMap<String, DeviceInfo>,
47 }
48
49 impl Request {
50 pub fn new(user_id: OwnedUserId) -> Self {
52 Self { user_id }
53 }
54 }
55
56 impl Response {
57 pub fn new() -> Self {
59 Default::default()
60 }
61 }
62
63 #[derive(Clone, Debug, Default, Deserialize, Serialize)]
65 #[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
66 pub struct DeviceInfo {
67 #[serde(default, skip_serializing_if = "Vec::is_empty")]
69 pub sessions: Vec<SessionInfo>,
70 }
71
72 impl DeviceInfo {
73 pub fn new() -> Self {
75 Self::default()
76 }
77 }
78
79 #[derive(Clone, Debug, Default, Deserialize, Serialize)]
81 #[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
82 pub struct SessionInfo {
83 #[serde(default, skip_serializing_if = "Vec::is_empty")]
85 pub connections: Vec<ConnectionInfo>,
86 }
87
88 impl SessionInfo {
89 pub fn new() -> Self {
91 Self::default()
92 }
93 }
94
95 #[derive(Clone, Debug, Default, Deserialize, Serialize)]
97 #[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
98 pub struct ConnectionInfo {
99 pub ip: Option<String>,
101
102 pub last_seen: Option<MilliSecondsSinceUnixEpoch>,
104
105 pub user_agent: Option<String>,
107 }
108
109 impl ConnectionInfo {
110 pub fn new() -> Self {
112 Self::default()
113 }
114 }
115}