ruma_appservice_api/thirdparty/
get_location_for_room_alias.rs

1//! `GET /_matrix/app/*/thirdparty/location`
2//!
3//! Retrieve an array of third party network locations from a Matrix room alias.
4
5pub mod v1 {
6    //! `/v1/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/application-service-api/#get_matrixappv1thirdpartylocation
9
10    use ruma_common::{
11        api::{request, response, Metadata},
12        metadata,
13        thirdparty::Location,
14        OwnedRoomAliasId,
15    };
16
17    const METADATA: Metadata = metadata! {
18        method: GET,
19        rate_limited: false,
20        authentication: AccessToken,
21        history: {
22            1.0 => "/_matrix/app/v1/thirdparty/location",
23        }
24    };
25
26    /// Request type for the `get_location_for_room_alias` endpoint.
27    #[request]
28    pub struct Request {
29        /// The Matrix room alias to look up.
30        #[ruma_api(query)]
31        pub alias: OwnedRoomAliasId,
32    }
33
34    /// Response type for the `get_location_for_room_alias` endpoint.
35    #[response]
36    pub struct Response {
37        /// List of matched third party locations.
38        #[ruma_api(body)]
39        pub locations: Vec<Location>,
40    }
41
42    impl Request {
43        /// Creates a new `Request` with the given room alias id.
44        pub fn new(alias: OwnedRoomAliasId) -> Self {
45            Self { alias }
46        }
47    }
48
49    impl Response {
50        /// Creates a new `Response` with the given locations.
51        pub fn new(locations: Vec<Location>) -> Self {
52            Self { locations }
53        }
54    }
55}