synapse_admin_api/
users.rs1pub mod create_or_modify;
4pub mod get_details;
5pub mod is_user_admin;
6pub mod list_joined_rooms;
7pub mod list_users;
8pub mod reset_password;
9
10use ruma::{thirdparty::ThirdPartyIdentifier, SecondsSinceUnixEpoch};
11use serde::{Deserialize, Serialize};
12
13#[derive(Serialize, Deserialize, Clone, Debug)]
15#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
16pub struct UserDetails {
17 pub name: String,
19
20 pub password_hash: Option<String>,
22
23 #[serde(deserialize_with = "crate::serde::bool_or_uint")]
25 pub is_guest: bool,
26
27 #[serde(deserialize_with = "crate::serde::bool_or_uint")]
29 pub admin: bool,
30
31 #[serde(skip_serializing_if = "Option::is_none")]
33 pub consent_version: Option<String>,
34
35 #[serde(skip_serializing_if = "Option::is_none")]
37 pub consent_server_notice_sent: Option<bool>,
38
39 #[serde(skip_serializing_if = "Option::is_none")]
41 pub appservice_id: Option<String>,
42
43 pub creation_ts: Option<SecondsSinceUnixEpoch>,
46
47 #[serde(skip_serializing_if = "Option::is_none")]
49 pub user_type: Option<String>,
50
51 #[serde(deserialize_with = "crate::serde::bool_or_uint")]
53 pub deactivated: bool,
54
55 pub displayname: String,
57
58 #[serde(skip_serializing_if = "Option::is_none")]
60 pub avatar_url: Option<String>,
61
62 #[serde(default, skip_serializing_if = "Vec::is_empty")]
64 pub threepids: Vec<ThirdPartyIdentifier>,
65
66 #[serde(default, skip_serializing_if = "Vec::is_empty")]
68 pub external_ids: Vec<ExternalId>,
69
70 #[serde(default, deserialize_with = "crate::serde::bool_or_uint")]
72 pub locked: bool,
73}
74
75impl UserDetails {
76 pub fn new(name: String) -> Self {
79 Self {
80 name,
81 password_hash: None,
82 is_guest: false,
83 admin: false,
84 consent_version: None,
85 consent_server_notice_sent: None,
86 appservice_id: None,
87 creation_ts: None,
88 user_type: None,
89 deactivated: false,
90 displayname: String::new(),
91 avatar_url: None,
92 threepids: Vec::new(),
93 external_ids: Vec::new(),
94 locked: false,
95 }
96 }
97}
98
99#[derive(Clone, Debug, Deserialize, Serialize)]
101#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
102pub struct ExternalId {
103 pub auth_provider: String,
105
106 pub external_id: String,
108}
109
110impl ExternalId {
111 pub fn new(auth_provider: String, external_id: String) -> Self {
113 Self { auth_provider, external_id }
114 }
115}