1//! `GET /_matrix/client/*/user/mutual_rooms/{user_id}`
2//!
3//! Get mutual rooms with another user.
45pub mod unstable {
6//! `/unstable/` ([spec])
7 //!
8 //! [spec]: https://github.com/matrix-org/matrix-spec-proposals/blob/hs/shared-rooms/proposals/2666-get-rooms-in-common.md
910use ruma_common::{
11 api::{request, response, Metadata},
12 metadata, OwnedRoomId, OwnedUserId,
13 };
1415const METADATA: Metadata = metadata! {
16 method: GET,
17 rate_limited: true,
18 authentication: AccessToken,
19 history: {
20 unstable => "/_matrix/client/unstable/uk.half-shot.msc2666/user/mutual_rooms",
21 }
22 };
2324/// Request type for the `mutual_rooms` endpoint.
25#[request(error = crate::Error)]
26pub struct Request {
27/// The user to search mutual rooms for.
28#[ruma_api(query)]
29pub user_id: OwnedUserId,
3031/// The `next_batch_token` returned from a previous response, to get the next batch of
32 /// rooms.
33#[serde(skip_serializing_if = "Option::is_none")]
34 #[ruma_api(query)]
35pub batch_token: Option<String>,
36 }
3738/// Response type for the `mutual_rooms` endpoint.
39#[response(error = crate::Error)]
40pub struct Response {
41/// A list of rooms the user is in together with the authenticated user.
42pub joined: Vec<OwnedRoomId>,
4344/// An opaque string, returned when the server paginates this response.
45#[serde(skip_serializing_if = "Option::is_none")]
46pub next_batch_token: Option<String>,
47 }
4849impl Request {
50/// Creates a new `Request` with the given user id.
51pub fn new(user_id: OwnedUserId) -> Self {
52Self { user_id, batch_token: None }
53 }
5455/// Creates a new `Request` with the given user id, together with a batch token.
56pub fn with_token(user_id: OwnedUserId, token: String) -> Self {
57Self { user_id, batch_token: Some(token) }
58 }
59 }
6061impl Response {
62/// Creates a `Response` with the given room ids.
63pub fn new(joined: Vec<OwnedRoomId>) -> Self {
64Self { joined, next_batch_token: None }
65 }
6667/// Creates a `Response` with the given room ids, together with a batch token.
68pub fn with_token(joined: Vec<OwnedRoomId>, token: String) -> Self {
69Self { joined, next_batch_token: Some(token) }
70 }
71 }
72}