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, +}