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
//! [GET /_synapse/admin/v1/users/:user_id/joined_rooms](https://github.com/matrix-org/synapse/blob/master/docs/admin_api/user_admin_api.rst#list-room-memberships-of-an-user)

use ruma::{api::ruma_api, RoomId, UInt, UserId};

ruma_api! {
    metadata: {
        description: "list room memberships of a user",
        method: GET,
        name: "list_joined_rooms_v1",
        unstable_path: "/_synapse/admin/v1/users/:user_id/joined_rooms",
        rate_limited: false,
        authentication: AccessToken,
    }

    request: {
        /// User ID
        #[ruma_api(path)]
        pub user_id: &'a UserId,
    }

    response: {
        /// List all joined roo IDs.
        pub joined_rooms: Vec<Box<RoomId>>,

        /// Amount of joined of rooms.
        pub total: UInt,
    }

}

impl<'a> Request<'a> {
    /// Creates an `Request` with the given user ID.
    pub fn new(user_id: &'a UserId) -> Self {
        Self { user_id }
    }
}

impl Response {
    /// Creates a `Response` with the given joined rooms and the total amount of them.
    pub fn new(joined_rooms: Vec<Box<RoomId>>, total: UInt) -> Self {
        Self { joined_rooms, total }
    }
}