Local API

This commit is contained in:
Alex Emmet 2025-11-17 21:09:20 +01:00
commit 927c377822
6 changed files with 155 additions and 21 deletions

View file

@ -76,6 +76,23 @@ impl Community {
c
}
pub async fn to_json(&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["private_key"] = self.private_key.as_bytes().to_vec().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);
}