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 committed Jan 18, 2025
1 parent 07c7a1c commit 79318aa
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/rooms.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Endpoints in the `/_synapse/admin/v<x>/rooms/` scope.
pub mod list_rooms;
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 {
/// Alias or ID of the room to join.
#[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 79318aa

Please sign in to comment.