1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Endpoints for the public room directory.

/// [GET /_matrix/client/r0/publicRooms](https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-publicrooms)
pub mod get_public_rooms {
    use ruma_identifiers::{RoomId, RoomAliasId};
    use ruma_api_macros::ruma_api;

    ruma_api! {
        metadata {
            description: "Get the list of rooms in this homeserver's public directory.",
            method: Method::Get,
            name: "get_public_rooms",
            path: "/_matrix/client/r0/publicRooms",
            rate_limited: false,
            requires_authentication: false,
        }

        request {}

        response {
            /// A pagination token for the response.
            pub start: String,
            /// A paginated chunk of public rooms.
            pub chunk: Vec<PublicRoomsChunk>,
            /// A pagination token for the response.
            pub end: String
        }
    }

    /// A chunk of the response, describing one room
    #[derive(Clone, Debug, Deserialize, Serialize)]
    pub struct PublicRoomsChunk {
        /// Aliases of the room.
        //#[serde(skip_serializing_if = "Option::is_none")]
        pub aliases: Option<Vec<RoomAliasId>>,
        /// The URL for the room's avatar, if one is set.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub avatar_url: Option<String>,
        /// Whether guest users may join the room and participate in it.
        ///
        /// If they can, they will be subject to ordinary power level rules like any other user.
        pub guest_can_join: bool,
        /// The name of the room, if any.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub name: Option<String>,
        /// The number of members joined to the room.
        pub num_joined_members: u64,
        /// The ID of the room.
        pub room_id: RoomId,
        /// The topic of the room, if any.
        #[serde(skip_serializing_if = "Option::is_none")]
        pub topic: Option<String>,
        /// Whether the room may be viewed by guest users without joining.
        pub world_readable: bool,
    }
}