ruma_client_api/admin/
get_user_info.rs1pub mod v3 {
6 use std::collections::BTreeMap;
11
12 use ruma_common::{
13 MilliSecondsSinceUnixEpoch, OwnedUserId,
14 api::{OAuthClientScope, auth_scheme::AccessToken, request, response},
15 metadata,
16 };
17 use serde::{Deserialize, Serialize};
18
19 metadata! {
20 method: GET,
21 rate_limited: false,
22 authentication: AccessToken,
23 required_client_scopes: [
24 #[cfg(not(feature = "unstable-msc4484"))]
25 OAuthClientScope::ApiFullAccess,
26 #[cfg(feature = "unstable-msc4484")]
27 OAuthClientScope::ServerAdministration,
28 ],
29 history: {
30 1.0 => "/_matrix/client/r0/admin/whois/{user_id}",
31 1.1 => "/_matrix/client/v3/admin/whois/{user_id}",
32 }
33 }
34
35 #[request]
37 pub struct Request {
38 #[ruma_api(path)]
40 pub user_id: OwnedUserId,
41 }
42
43 #[response]
45 #[derive(Default)]
46 pub struct Response {
47 #[serde(skip_serializing_if = "Option::is_none")]
49 pub user_id: Option<OwnedUserId>,
50
51 #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
53 pub devices: BTreeMap<String, DeviceInfo>,
54 }
55
56 impl Request {
57 pub fn new(user_id: OwnedUserId) -> Self {
59 Self { user_id }
60 }
61 }
62
63 impl Response {
64 pub fn new() -> Self {
66 Default::default()
67 }
68 }
69
70 #[derive(Clone, Debug, Default, Deserialize, Serialize)]
72 #[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
73 pub struct DeviceInfo {
74 #[serde(default, skip_serializing_if = "Vec::is_empty")]
76 pub sessions: Vec<SessionInfo>,
77 }
78
79 impl DeviceInfo {
80 pub fn new() -> Self {
82 Self::default()
83 }
84 }
85
86 #[derive(Clone, Debug, Default, Deserialize, Serialize)]
88 #[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
89 pub struct SessionInfo {
90 #[serde(default, skip_serializing_if = "Vec::is_empty")]
92 pub connections: Vec<ConnectionInfo>,
93 }
94
95 impl SessionInfo {
96 pub fn new() -> Self {
98 Self::default()
99 }
100 }
101
102 #[derive(Clone, Debug, Default, Deserialize, Serialize)]
104 #[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
105 pub struct ConnectionInfo {
106 pub ip: Option<String>,
108
109 pub last_seen: Option<MilliSecondsSinceUnixEpoch>,
111
112 pub user_agent: Option<String>,
114 }
115
116 impl ConnectionInfo {
117 pub fn new() -> Self {
119 Self::default()
120 }
121 }
122}