ruma_client_api/room/
aliases.rs

1//! `GET /_matrix/client/*/rooms/{roomId}/aliases`
2//!
3//! Get a list of aliases maintained by the local server for the given room.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3roomsroomidaliases
9
10    use ruma_common::{
11        OwnedRoomAliasId, OwnedRoomId,
12        api::{auth_scheme::AccessToken, request, response},
13        metadata,
14    };
15
16    metadata! {
17        method: GET,
18        rate_limited: true,
19        authentication: AccessToken,
20        history: {
21            unstable("org.matrix.msc2432") => "/_matrix/client/unstable/org.matrix.msc2432/rooms/{room_id}/aliases",
22            1.0 => "/_matrix/client/r0/rooms/{room_id}/aliases",
23            1.1 => "/_matrix/client/v3/rooms/{room_id}/aliases",
24        }
25    }
26
27    /// Request type for the `aliases` endpoint.
28    #[request(error = crate::Error)]
29    pub struct Request {
30        /// The room ID to get aliases of.
31        #[ruma_api(path)]
32        pub room_id: OwnedRoomId,
33    }
34
35    /// Response type for the `aliases` endpoint.
36    #[response(error = crate::Error)]
37    pub struct Response {
38        /// The server's local aliases on the room.
39        pub aliases: Vec<OwnedRoomAliasId>,
40    }
41
42    impl Request {
43        /// Creates a new `Request` with the given room ID.
44        pub fn new(room_id: OwnedRoomId) -> Self {
45            Self { room_id }
46        }
47    }
48
49    impl Response {
50        /// Creates a new `Response` with the given aliases.
51        pub fn new(aliases: Vec<OwnedRoomAliasId>) -> Self {
52            Self { aliases }
53        }
54    }
55}