Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add room members api #31

Merged
merged 1 commit into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
kilimnik marked this conversation as resolved.
Show resolved Hide resolved

# 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 {
kilimnik marked this conversation as resolved.
Show resolved Hide resolved
/// 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 }
}
}
Loading