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

@ -93,6 +93,22 @@ impl Community {
json
}
pub async fn frontend(&self) -> JsonValue {
let mut json = JsonValue::new_object();
json["name"] = self.name.clone().into();
json["owner_id"] = self.owner_id.to_string().into();
json["members"] = self
.members
.clone()
.iter()
.map(|f| f.to_string())
.collect::<Vec<String>>()
.into();
json["public_key"] = self.public_key.as_bytes().to_vec().into();
json["connections"] = self.connections.read().await.clone().len().into();
json
}
pub fn add_member(&mut self, member_id: Uuid) {
self.members.push(member_id);
}