From 32ff088156a1e39e37a58d956766b548192eecd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Dom=C3=ADnguez?= Date: Mon, 14 Jan 2019 11:10:33 +0100 Subject: [PATCH] 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 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; + +#[derive(Clone, Debug, Deserialize)] +pub struct PublicRoomsResponse { + pub chunk: Vec, + pub next_batch: Option, + pub prev_batch: Option, + pub total_room_count_estimate: Option, +} + +#[derive(Clone, Debug, Deserialize)] +pub struct PublicRoomsChunk { + pub aliases: Option>, + pub avatar_url: Option, + pub canonical_alias: Option, + pub guest_can_join: bool, + pub name: Option, + pub num_joined_members: i32, + pub room_id: String, + pub topic: Option, + pub world_readable: bool, +}