Skip to content

Commit 3483bc1

Browse files
authored
Add room_membership api (#27)
1 parent 0a033da commit 3483bc1

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub mod account_validity;
1313
pub mod background_updates;
1414
pub mod experimental_features;
1515
pub mod register_users;
16+
pub mod room_membership;
1617
pub mod rooms;
1718
pub mod users;
1819
pub mod version;

src/room_membership.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//! Endpoints in the `/_synapse/admin/v<x>/join/` scope.
2+
3+
pub mod join_room;

src/room_membership/join_room.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 place users into rooms.
2+
3+
pub mod v1;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//! [POST /_synapse/admin/v1/join/:room_id_or_alias](https://github.com/element-hq/synapse/blob/master/docs/admin_api/room_membership.md)
2+
3+
use ruma::{
4+
api::{request, response, Metadata},
5+
metadata, OwnedRoomId, OwnedRoomOrAliasId, OwnedUserId,
6+
};
7+
8+
const METADATA: Metadata = metadata! {
9+
method: POST,
10+
rate_limited: false,
11+
authentication: AccessToken,
12+
history: {
13+
unstable => "/_synapse/admin/v1/join/:room_id_or_alias",
14+
}
15+
};
16+
17+
#[request]
18+
pub struct Request {
19+
/// Alias or ID of the room to join.
20+
#[ruma_api(path)]
21+
pub room_id_or_alias: OwnedRoomOrAliasId,
22+
23+
/// User to join the room.
24+
pub user_id: OwnedUserId,
25+
}
26+
27+
#[response]
28+
pub struct Response {
29+
/// Room ID of the joined room.
30+
pub room_id: OwnedRoomId,
31+
}
32+
33+
impl Request {
34+
/// Creates a new `Request` with the given room or alias ID and user id.
35+
pub fn new(room_id_or_alias: OwnedRoomOrAliasId, user_id: OwnedUserId) -> Self {
36+
Self { room_id_or_alias, user_id }
37+
}
38+
}
39+
40+
impl Response {
41+
/// Creates a new `Response` with the given room id
42+
pub fn new(room_id: OwnedRoomId) -> Self {
43+
Self { room_id }
44+
}
45+
}

0 commit comments

Comments
 (0)