synapse_admin_api/rooms/room_details/
v1.rs

1//! [GET /_synapse/admin/v1/rooms/:room_id](https://github.com/element-hq/synapse/blob/master/docs/admin_api/rooms.md#room-details-api)
2use ruma::{
3    api::{metadata, request, response, Metadata},
4    events::room::{guest_access::GuestAccess, history_visibility::HistoryVisibility},
5    room::{JoinRuleKind, RoomType},
6    uint, OwnedMxcUri, OwnedRoomAliasId, OwnedRoomId, OwnedUserId, UInt,
7};
8
9const METADATA: Metadata = metadata! {
10    method: GET,
11    rate_limited: false,
12    authentication: AccessToken,
13    history: {
14        unstable => "/_synapse/admin/v1/rooms/{room_id}",
15    }
16};
17
18#[request]
19pub struct Request {
20    /// ID of the room to show the details of.
21    #[ruma_api(path)]
22    pub room_id: OwnedRoomId,
23}
24
25#[response]
26pub struct Response {
27    /// Room ID
28    pub room_id: OwnedRoomId,
29
30    /// Room name
31    pub name: Option<String>,
32
33    /// Room topic
34    pub topic: Option<String>,
35
36    /// Room avatar
37    pub avatar: Option<OwnedMxcUri>,
38
39    /// Room alias ID
40    pub canonical_alias: Option<OwnedRoomAliasId>,
41
42    /// Amount of joined members.
43    pub joined_members: UInt,
44
45    /// Amount of local members.
46    pub joined_local_members: UInt,
47
48    /// Amount of local devices.
49    pub joined_local_devices: UInt,
50
51    /// Room version
52    pub version: Option<String>,
53
54    /// User ID of the room creator.
55    #[serde(deserialize_with = "ruma::serde::empty_string_as_none")]
56    pub creator: Option<OwnedUserId>,
57
58    /// Room encryption.
59    pub encryption: Option<String>,
60
61    /// Whether the room is federatable
62    #[serde(deserialize_with = "crate::serde::bool_or_uint")]
63    pub federatable: bool,
64
65    /// Whether the room is public.
66    #[serde(deserialize_with = "crate::serde::bool_or_uint")]
67    pub public: bool,
68
69    /// Join rules of the room.
70    pub join_rules: Option<JoinRuleKind>,
71
72    /// Guest access of the room
73    pub guest_access: Option<GuestAccess>,
74
75    /// History visibility of the room
76    pub history_visibility: Option<HistoryVisibility>,
77
78    /// State events of the room.
79    pub state_events: UInt,
80
81    /// Room type of the room.
82    pub room_type: Option<RoomType>,
83
84    /// Whether all local users have forgotten the room.
85    #[serde(deserialize_with = "crate::serde::bool_or_uint")]
86    pub forgotten: bool,
87}
88
89impl Request {
90    /// Creates a `Request` with the given room ID.
91    pub fn new(room_id: OwnedRoomId) -> Self {
92        Self { room_id }
93    }
94}
95
96impl Response {
97    /// Creates a `Response` with the given room ID and default values.
98    pub fn new(room_id: OwnedRoomId) -> Self {
99        Self {
100            room_id,
101            name: None,
102            topic: None,
103            avatar: None,
104            canonical_alias: None,
105            joined_members: uint!(0),
106            joined_local_members: uint!(0),
107            joined_local_devices: uint!(0),
108            version: None,
109            creator: None,
110            encryption: None,
111            federatable: false,
112            public: false,
113            join_rules: None,
114            guest_access: None,
115            history_visibility: None,
116            state_events: uint!(0),
117            room_type: None,
118            forgotten: false,
119        }
120    }
121}