Api
This commit is contained in:
parent
25ee0246de
commit
ec0a6311f1
4 changed files with 48 additions and 11 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue