Skip to content

Commit 1a911eb

Browse files
committed
client-api: Stabilize the mutual_rooms endpoint (MSC2666).
Move the mutual_rooms module from `unstable` to `v1`, add the required `count` field, and retain the unstable endpoint sharing the v1 types. Add `MatrixVersion::V1_19` for the stable endpoint's history. Signed-off-by: Jason Volk <jason@zemos.net>
1 parent c8684a4 commit 1a911eb

3 files changed

Lines changed: 41 additions & 21 deletions

File tree

crates/ruma-client-api/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ Improvements:
1414
field on `discovery::get_supported_versions::Response` carries the
1515
homeserver implementation name and version, mirroring the federation
1616
`/version` payload.
17+
- Stabilize the `GET /_matrix/client/v1/mutual_rooms` endpoint (MSC2666),
18+
adding the required `count` field. The `mutual_rooms` module moves from
19+
`unstable` to `v1`, and the retained unstable endpoint shares the v1
20+
request and response types; the response fields are now `joined`, `count`
21+
and `next_batch`.
1722

1823
[MSC4383]: https://github.com/matrix-org/matrix-spec-proposals/pull/4383
1924

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
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
}

crates/ruma-common/src/api/metadata.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,11 @@ pub enum MatrixVersion {
388388
///
389389
/// See <https://spec.matrix.org/v1.18/>.
390390
V1_18,
391+
392+
/// Version 1.19 of the Matrix specification, released in Q2 2026.
393+
///
394+
/// See <https://spec.matrix.org/v1.19/>.
395+
V1_19,
391396
}
392397

393398
impl TryFrom<&str> for MatrixVersion {
@@ -420,6 +425,7 @@ impl TryFrom<&str> for MatrixVersion {
420425
"v1.16" => V1_16,
421426
"v1.17" => V1_17,
422427
"v1.18" => V1_18,
428+
"v1.19" => V1_19,
423429
_ => return Err(UnknownVersionError),
424430
})
425431
}
@@ -474,6 +480,7 @@ impl MatrixVersion {
474480
MatrixVersion::V1_16 => "v1.16",
475481
MatrixVersion::V1_17 => "v1.17",
476482
MatrixVersion::V1_18 => "v1.18",
483+
MatrixVersion::V1_19 => "v1.19",
477484
};
478485

479486
Some(string)
@@ -501,6 +508,7 @@ impl MatrixVersion {
501508
MatrixVersion::V1_16 => (1, 16),
502509
MatrixVersion::V1_17 => (1, 17),
503510
MatrixVersion::V1_18 => (1, 18),
511+
MatrixVersion::V1_19 => (1, 19),
504512
}
505513
}
506514

@@ -526,6 +534,7 @@ impl MatrixVersion {
526534
(1, 16) => Ok(MatrixVersion::V1_16),
527535
(1, 17) => Ok(MatrixVersion::V1_17),
528536
(1, 18) => Ok(MatrixVersion::V1_18),
537+
(1, 19) => Ok(MatrixVersion::V1_19),
529538
_ => Err(UnknownVersionError),
530539
}
531540
}
@@ -620,7 +629,9 @@ impl MatrixVersion {
620629
// <https://spec.matrix.org/v1.17/rooms/#complete-list-of-room-versions>
621630
| MatrixVersion::V1_17
622631
// <https://spec.matrix.org/v1.18/rooms/#complete-list-of-room-versions>
623-
| MatrixVersion::V1_18 => RoomVersionId::V12,
632+
| MatrixVersion::V1_18
633+
// <https://spec.matrix.org/v1.19/rooms/#complete-list-of-room-versions>
634+
| MatrixVersion::V1_19 => RoomVersionId::V12,
624635
}
625636
}
626637
}

0 commit comments

Comments
 (0)