1- //! `GET /_matrix/client/*/user/ mutual_rooms/{user_id} `
1+ //! `GET /_matrix/client/*/mutual_rooms`
22//!
3- //! Get mutual rooms with another user.
3+ //! Get the list of rooms a user shares with another user.
44
5- pub mod unstable {
6- //! `/unstable /` ([spec])
5+ pub mod v1 {
6+ //! `/v1 /` ([spec])
77 //!
8- //! [spec]: https://github.com/ matrix- org/matrix-spec-proposals/blob/hs/shared-rooms/proposals/2666-get-rooms-in-common.md
8+ //! [spec]: https://spec. matrix. org/v1.19/client-server-api/#get_matrixclientv1mutual_rooms
99
10+ use js_int:: UInt ;
1011 use ruma_common:: {
1112 OwnedRoomId , OwnedUserId ,
1213 api:: { auth_scheme:: AccessToken , request, response} ,
@@ -19,6 +20,7 @@ pub mod unstable {
1920 authentication: AccessToken ,
2021 history: {
2122 unstable( "uk.half-shot.msc2666.query_mutual_rooms" ) => "/_matrix/client/unstable/uk.half-shot.msc2666/user/mutual_rooms" ,
23+ 1.19 => "/_matrix/client/v1/mutual_rooms" ,
2224 }
2325 }
2426
@@ -29,15 +31,14 @@ pub mod unstable {
2931 #[ ruma_api( query) ]
3032 pub user_id : OwnedUserId ,
3133
32- /// The `next_batch_token` returned from a previous response, to get the next batch of
33- /// rooms.
34+ /// The pagination token from a previous response, to get the next batch of rooms.
3435 #[ serde( skip_serializing_if = "Option::is_none" ) ]
3536 #[ cfg_attr(
3637 feature = "compat-empty-string-null" ,
3738 serde( default , deserialize_with = "ruma_common::serde::empty_string_as_none" )
3839 ) ]
3940 #[ ruma_api( query) ]
40- pub batch_token : Option < String > ,
41+ pub from : Option < String > ,
4142 }
4243
4344 /// Response type for the `mutual_rooms` endpoint.
@@ -46,32 +47,35 @@ pub mod unstable {
4647 /// A list of rooms the user is in together with the authenticated user.
4748 pub joined : Vec < OwnedRoomId > ,
4849
49- /// An opaque string, returned when the server paginates this response.
50+ /// The total number of shared rooms, even when this response is batched.
51+ pub count : UInt ,
52+
53+ /// An opaque token, returned when the server paginates this response.
5054 #[ serde( skip_serializing_if = "Option::is_none" ) ]
51- pub next_batch_token : Option < String > ,
55+ pub next_batch : Option < String > ,
5256 }
5357
5458 impl Request {
5559 /// Creates a new `Request` with the given user id.
5660 pub fn new ( user_id : OwnedUserId ) -> Self {
57- Self { user_id, batch_token : None }
61+ Self { user_id, from : None }
5862 }
5963
60- /// Creates a new `Request` with the given user id, together with a batch token.
61- pub fn with_token ( user_id : OwnedUserId , token : String ) -> Self {
62- Self { user_id, batch_token : Some ( token ) }
64+ /// Creates a new `Request` with the given user id, together with a pagination token.
65+ pub fn with_token ( user_id : OwnedUserId , from : String ) -> Self {
66+ Self { user_id, from : Some ( from ) }
6367 }
6468 }
6569
6670 impl Response {
67- /// Creates a `Response` with the given room ids.
68- pub fn new ( joined : Vec < OwnedRoomId > ) -> Self {
69- Self { joined, next_batch_token : None }
71+ /// Creates a `Response` with the given room ids and total count .
72+ pub fn new ( joined : Vec < OwnedRoomId > , count : UInt ) -> Self {
73+ Self { joined, count , next_batch : None }
7074 }
7175
72- /// Creates a `Response` with the given room ids, together with a batch token.
73- pub fn with_token ( joined : Vec < OwnedRoomId > , token : String ) -> Self {
74- Self { joined, next_batch_token : Some ( token ) }
76+ /// Creates a `Response` with the given room ids, total count and pagination token.
77+ pub fn with_token ( joined : Vec < OwnedRoomId > , count : UInt , next_batch : String ) -> Self {
78+ Self { joined, count , next_batch : Some ( next_batch ) }
7579 }
7680 }
7781}
0 commit comments