Skip to content

Commit 56bddc9

Browse files
kilimnikzecakeh
authored andcommitted
feat: Add room members api
1 parent 05ce8bd commit 56bddc9

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Improvement:
99

1010
* The list_room response now includes the `room_type` field
1111
* Add room_details api
12+
* Add room_members api
1213

1314
# 0.7.0
1415

src/rooms.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
33
pub mod list_rooms;
44
pub mod room_details;
5+
pub mod room_members;

src/rooms/room_members.rs

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

src/rooms/room_members/v1.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//! [GET /_synapse/admin/v1/rooms/:room_id/members](https://github.com/element-hq/synapse/blob/master/docs/admin_api/rooms.md#room-members-api)
2+
use ruma::{
3+
api::{metadata, request, response, Metadata},
4+
OwnedRoomId, OwnedUserId, UInt,
5+
};
6+
7+
const METADATA: Metadata = metadata! {
8+
method: GET,
9+
rate_limited: false,
10+
authentication: AccessToken,
11+
history: {
12+
unstable => "/_synapse/admin/v1/rooms/:room_id/members",
13+
}
14+
};
15+
16+
#[request]
17+
pub struct Request {
18+
/// ID of the room to list the members of.
19+
#[ruma_api(path)]
20+
pub room_id: OwnedRoomId,
21+
}
22+
23+
#[response]
24+
pub struct Response {
25+
/// List of members that are present in the room
26+
pub members: Vec<OwnedUserId>,
27+
28+
/// Amount of members in the room.
29+
pub total: UInt,
30+
}
31+
32+
impl Request {
33+
/// Creates a `Request` with the given room ID.
34+
pub fn new(room_id: OwnedRoomId) -> Self {
35+
Self { room_id }
36+
}
37+
}
38+
39+
impl Response {
40+
/// Creates a `Response` with the given members and total count,
41+
pub fn new(members: Vec<OwnedUserId>, total: UInt) -> Self {
42+
Self { members, total }
43+
}
44+
}

0 commit comments

Comments
 (0)