pub mod create_or_modify;
pub mod deactivate_account;
pub mod get_details;
pub mod is_user_admin;
pub mod list_joined_rooms;
pub mod list_users;
pub mod reset_password;
use ruma::{SecondsSinceUnixEpoch, thirdparty::ThirdPartyIdentifier};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug)]
#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
pub struct UserDetails {
pub name: String,
pub password_hash: Option<String>,
#[serde(deserialize_with = "crate::serde::bool_or_uint")]
pub is_guest: bool,
#[serde(deserialize_with = "crate::serde::bool_or_uint")]
pub admin: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub consent_version: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub consent_server_notice_sent: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub appservice_id: Option<String>,
pub creation_ts: Option<SecondsSinceUnixEpoch>,
#[serde(skip_serializing_if = "Option::is_none")]
pub user_type: Option<String>,
#[serde(deserialize_with = "crate::serde::bool_or_uint")]
pub deactivated: bool,
pub displayname: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub avatar_url: Option<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub threepids: Vec<ThirdPartyIdentifier>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub external_ids: Vec<ExternalId>,
#[serde(default, deserialize_with = "crate::serde::bool_or_uint")]
pub locked: bool,
}
impl UserDetails {
pub fn new(name: String) -> Self {
Self {
name,
password_hash: None,
is_guest: false,
admin: false,
consent_version: None,
consent_server_notice_sent: None,
appservice_id: None,
creation_ts: None,
user_type: None,
deactivated: false,
displayname: String::new(),
avatar_url: None,
threepids: Vec::new(),
external_ids: Vec::new(),
locked: false,
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
pub struct ExternalId {
pub auth_provider: String,
pub external_id: String,
}
impl ExternalId {
pub fn new(auth_provider: String, external_id: String) -> Self {
Self { auth_provider, external_id }
}
}