Skip to content

Commit

Permalink
feat: Add room members api
Browse files Browse the repository at this point in the history
  • Loading branch information
kilimnik authored and zecakeh committed Jan 18, 2025
1 parent 05ce8bd commit 56bddc9
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Improvement:

* The list_room response now includes the `room_type` field
* Add room_details api
* Add room_members api

# 0.7.0

Expand Down
1 change: 1 addition & 0 deletions src/rooms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
pub mod list_rooms;
pub mod room_details;
pub mod room_members;
3 changes: 3 additions & 0 deletions src/rooms/room_members.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//! Different versions of the endpoint to list room members.
pub mod v1;
44 changes: 44 additions & 0 deletions src/rooms/room_members/v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//! [GET /_synapse/admin/v1/rooms/:room_id/members](https://github.com/element-hq/synapse/blob/master/docs/admin_api/rooms.md#room-members-api)
use ruma::{
api::{metadata, request, response, Metadata},
OwnedRoomId, OwnedUserId, UInt,
};

const METADATA: Metadata = metadata! {
method: GET,
rate_limited: false,
authentication: AccessToken,
history: {
unstable => "/_synapse/admin/v1/rooms/:room_id/members",
}
};

#[request]
pub struct Request {
/// ID of the room to list the members of.
#[ruma_api(path)]
pub room_id: OwnedRoomId,
}

#[response]
pub struct Response {
/// List of members that are present in the room
pub members: Vec<OwnedUserId>,

/// Amount of members in the room.
pub total: UInt,
}

impl Request {
/// Creates a `Request` with the given room ID.
pub fn new(room_id: OwnedRoomId) -> Self {
Self { room_id }
}
}

impl Response {
/// Creates a `Response` with the given members and total count,
pub fn new(members: Vec<OwnedUserId>, total: UInt) -> Self {
Self { members, total }
}
}

0 comments on commit 56bddc9

Please sign in to comment.