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::{auth_scheme::AccessToken, request, response},
12 metadata,
13 thirdparty::Location,
14 OwnedRoomAliasId,
15 };
16
17 metadata! {
18 method: GET,
19 rate_limited: false,
20 authentication: AccessToken,
21 path: "/_matrix/app/v1/thirdparty/location",
22 }
23
24 /// Request type for the `get_location_for_room_alias` endpoint.
25 #[request]
26 pub struct Request {
27 /// The Matrix room alias to look up.
28 #[ruma_api(query)]
29 pub alias: OwnedRoomAliasId,
30 }
31
32 /// Response type for the `get_location_for_room_alias` endpoint.
33 #[response]
34 pub struct Response {
35 /// List of matched third party locations.
36 #[ruma_api(body)]
37 pub locations: Vec<Location>,
38 }
39
40 impl Request {
41 /// Creates a new `Request` with the given room alias id.
42 pub fn new(alias: OwnedRoomAliasId) -> Self {
43 Self { alias }
44 }
45 }
46
47 impl Response {
48 /// Creates a new `Response` with the given locations.
49 pub fn new(locations: Vec<Location>) -> Self {
50 Self { locations }
51 }
52 }
53}