Skip to main content

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/v1.19/application-service-api/#get_matrixappv1thirdpartylocation
9
10    use ruma_common::{
11        OwnedRoomAliasId,
12        api::{request, response},
13        metadata,
14        thirdparty::Location,
15    };
16
17    use crate::HomeserverToken;
18
19    metadata! {
20        method: GET,
21        rate_limited: false,
22        authentication: HomeserverToken,
23        path: "/_matrix/app/v1/thirdparty/location",
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}