This commit is contained in:
Alex Emmet 2025-11-22 13:11:12 +00:00
commit ec0a6311f1
4 changed files with 48 additions and 11 deletions

View file

@ -50,7 +50,18 @@ impl UserProfile {
}
obj
}
pub fn frontend(&self) -> JsonValue {
let mut obj = object! {
"uuid" => self.user_id.to_string(),
"username" => self.username.clone(),
"public_key" => self.public_key.clone(),
"private_key_hash" => self.private_key_hash.clone(),
};
if let Some(d) = &self.display_name {
obj["display_name"] = d.clone().into();
}
obj
}
pub async fn from_json(j: &JsonValue) -> Option<Self> {
let uuid = Uuid::parse_str(j["uuid"].as_str()?).ok()?;
let username = j["username"].as_str()?.to_string();