synapse_admin_api/
users.rs1pub mod create_or_modify;
4pub mod deactivate_account;
5pub mod get_details;
6pub mod is_user_admin;
7pub mod list_joined_rooms;
8pub mod list_users;
9pub mod reset_password;
10
11use ruma::{SecondsSinceUnixEpoch, thirdparty::ThirdPartyIdentifier};
12use serde::{Deserialize, Serialize};
13
14#[derive(Serialize, Deserialize, Clone, Debug)]
16#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
17pub struct UserDetails {
18 pub name: String,
20
21 pub password_hash: Option<String>,
23
24 #[serde(deserialize_with = "crate::serde::bool_or_uint")]
26 pub is_guest: bool,
27
28 #[serde(deserialize_with = "crate::serde::bool_or_uint")]
30 pub admin: bool,
31
32 #[serde(skip_serializing_if = "Option::is_none")]
34 pub consent_version: Option<String>,
35
36 #[serde(skip_serializing_if = "Option::is_none")]
38 pub consent_server_notice_sent: Option<bool>,
39
40 #[serde(skip_serializing_if = "Option::is_none")]
42 pub appservice_id: Option<String>,
43
44 pub creation_ts: Option<SecondsSinceUnixEpoch>,
47
48 #[serde(skip_serializing_if = "Option::is_none")]
50 pub user_type: Option<String>,
51
52 #[serde(deserialize_with = "crate::serde::bool_or_uint")]
54 pub deactivated: bool,
55
56 pub displayname: String,
58
59 #[serde(skip_serializing_if = "Option::is_none")]
61 pub avatar_url: Option<String>,
62
63 #[serde(default, skip_serializing_if = "Vec::is_empty")]
65 pub threepids: Vec<ThirdPartyIdentifier>,
66
67 #[serde(default, skip_serializing_if = "Vec::is_empty")]
69 pub external_ids: Vec<ExternalId>,
70
71 #[serde(default, deserialize_with = "crate::serde::bool_or_uint")]
73 pub locked: bool,
74}
75
76impl UserDetails {
77 pub fn new(name: String) -> Self {
80 Self {
81 name,
82 password_hash: None,
83 is_guest: false,
84 admin: false,
85 consent_version: None,
86 consent_server_notice_sent: None,
87 appservice_id: None,
88 creation_ts: None,
89 user_type: None,
90 deactivated: false,
91 displayname: String::new(),
92 avatar_url: None,
93 threepids: Vec::new(),
94 external_ids: Vec::new(),
95 locked: false,
96 }
97 }
98}
99
100#[derive(Clone, Debug, Deserialize, Serialize)]
102#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
103pub struct ExternalId {
104 pub auth_provider: String,
106
107 pub external_id: String,
109}
110
111impl ExternalId {
112 pub fn new(auth_provider: String, external_id: String) -> Self {
114 Self { auth_provider, external_id }
115 }
116}