ruma_client_api/room/upgrade_room.rs
1//! `POST /_matrix/client/*/rooms/{roomId}/upgrade`
2//!
3//! Upgrades a room to a particular version.
4
5pub mod v3 {
6 //! `/v3/` ([spec])
7 //!
8 //! [spec]: https://spec.matrix.org/v1.18/client-server-api/#post_matrixclientv3roomsroomidupgrade
9
10 use ruma_common::{
11 OwnedRoomId, OwnedUserId, RoomVersionId,
12 api::{auth_scheme::AccessToken, request, response},
13 metadata,
14 };
15
16 metadata! {
17 method: POST,
18 rate_limited: false,
19 authentication: AccessToken,
20 history: {
21 1.0 => "/_matrix/client/r0/rooms/{room_id}/upgrade",
22 1.1 => "/_matrix/client/v3/rooms/{room_id}/upgrade",
23 }
24 }
25
26 /// Request type for the `upgrade_room` endpoint.
27 #[request]
28 pub struct Request {
29 /// A list of user IDs to consider as additional creators, and hence grant an "infinite"
30 /// immutable power level, from room version 12 onwards.
31 #[serde(default, skip_serializing_if = "<[_]>::is_empty")]
32 pub additional_creators: Vec<OwnedUserId>,
33
34 /// ID of the room to be upgraded.
35 #[ruma_api(path)]
36 pub room_id: OwnedRoomId,
37
38 /// New version for the room.
39 pub new_version: RoomVersionId,
40 }
41
42 /// Response type for the `upgrade_room` endpoint.
43 #[response]
44 pub struct Response {
45 /// ID of the new room.
46 pub replacement_room: OwnedRoomId,
47 }
48
49 impl Request {
50 /// Creates a new `Request` with the given room ID and new room version.
51 pub fn new(room_id: OwnedRoomId, new_version: RoomVersionId) -> Self {
52 Self { room_id, new_version, additional_creators: Vec::new() }
53 }
54 }
55
56 impl Response {
57 /// Creates a new `Response` with the given room ID.
58 pub fn new(replacement_room: OwnedRoomId) -> Self {
59 Self { replacement_room }
60 }
61 }
62}