Skip to content

Commit e846725

Browse files
committed
feat: Add room details api
1 parent 07c7a1c commit e846725

File tree

3 files changed

+99
-0
lines changed

3 files changed

+99
-0
lines changed

src/rooms.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
//! Endpoints in the `/_synapse/admin/v<x>/rooms/` scope.
22
33
pub mod list_rooms;
4+
pub mod room_details;

src/rooms/room_details.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//! Different versions of the room details endpoint.
2+
3+
pub mod v1;

src/rooms/room_details/v1.rs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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+
/// Alias or ID of the room to join.
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+
///A mount 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 an empty `Request`.
92+
pub fn new(room_id: OwnedRoomId) -> Self {
93+
Self { room_id }
94+
}
95+
}

0 commit comments

Comments
 (0)