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