-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } | ||
} | ||
} |