[fractal] Add types related to room listing API



commit 32ff088156a1e39e37a58d956766b548192eecd8
Author: Alejandro Domínguez <adomu net-c com>
Date:   Mon Jan 14 11:10:33 2019 +0100

    Add types related to room listing API

 fractal-matrix-api/src/model/room.rs | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
---
diff --git a/fractal-matrix-api/src/model/room.rs b/fractal-matrix-api/src/model/room.rs
index 19021e79..e3423458 100644
--- a/fractal-matrix-api/src/model/room.rs
+++ b/fractal-matrix-api/src/model/room.rs
@@ -141,6 +141,21 @@ impl Room {
     }
 }
 
+impl From<PublicRoomsChunk> for Room {
+    fn from(input: PublicRoomsChunk) -> Self {
+        let mut room = Self::new(input.room_id, RoomMembership::None);
+        room.alias = input.canonical_alias;
+        room.name = input.name;
+        room.avatar = input.avatar_url;
+        room.topic = input.topic;
+        room.n_members = input.num_joined_members;
+        room.world_readable = input.world_readable;
+        room.guest_can_join = input.guest_can_join;
+
+        room
+    }
+}
+
 impl PartialEq for Room {
     fn eq(&self, other: &Room) -> bool {
         self.id == other.id
@@ -148,3 +163,24 @@ impl PartialEq for Room {
 }
 
 pub type RoomList = HashMap<String, Room>;
+
+#[derive(Clone, Debug, Deserialize)]
+pub struct PublicRoomsResponse {
+    pub chunk: Vec<PublicRoomsChunk>,
+    pub next_batch: Option<String>,
+    pub prev_batch: Option<String>,
+    pub total_room_count_estimate: Option<u64>,
+}
+
+#[derive(Clone, Debug, Deserialize)]
+pub struct PublicRoomsChunk {
+    pub aliases: Option<Vec<String>>,
+    pub avatar_url: Option<String>,
+    pub canonical_alias: Option<String>,
+    pub guest_can_join: bool,
+    pub name: Option<String>,
+    pub num_joined_members: i32,
+    pub room_id: String,
+    pub topic: Option<String>,
+    pub world_readable: bool,
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]