ruma_client_api/appservice/
set_room_visibility.rs

1//! `PUT /_matrix/client/*/directory/list/appservice/{networkId}/{roomId}`
2//!
3//! Updates the visibility of a given room on the application service's room directory.
4
5pub mod v3 {
6    //! `/v3/` ([spec])
7    //!
8    //! [spec]: https://spec.matrix.org/latest/application-service-api/#put_matrixclientv3directorylistappservicenetworkidroomid
9
10    use ruma_common::{
11        OwnedRoomId,
12        api::{auth_scheme::AppserviceToken, request, response},
13        metadata,
14    };
15
16    use crate::room::Visibility;
17
18    metadata! {
19        method: PUT,
20        rate_limited: false,
21        authentication: AppserviceToken,
22        history: {
23            1.0 => "/_matrix/client/r0/directory/list/appservice/{network_id}/{room_id}",
24            1.1 => "/_matrix/client/v3/directory/list/appservice/{network_id}/{room_id}",
25        }
26    }
27
28    /// Request type for the `set_room_visibility` endpoint.
29    #[request(error = crate::Error)]
30    pub struct Request {
31        /// The protocol (network) ID to update the room list for.
32        #[ruma_api(path)]
33        pub network_id: String,
34
35        /// The room ID to add to the directory.
36        #[ruma_api(path)]
37        pub room_id: OwnedRoomId,
38
39        /// Whether the room should be visible (public) in the directory or not (private).
40        pub visibility: Visibility,
41    }
42
43    /// Response type for the `set_room_visibility` endpoint.
44    #[response(error = crate::Error)]
45    #[derive(Default)]
46    pub struct Response {}
47
48    impl Request {
49        /// Creates a new `Request` with the given network ID, room ID and visibility.
50        pub fn new(network_id: String, room_id: OwnedRoomId, visibility: Visibility) -> Self {
51            Self { network_id, room_id, visibility }
52        }
53    }
54
55    impl Response {
56        /// Creates an empty `Response`.
57        pub fn new() -> Self {
58            Self {}
59        }
60    }
61}