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