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: room_membership api #27

Merged
merged 1 commit into from
Jan 9, 2025
Merged
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 src/lib.rs
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ pub mod account_validity;
pub mod background_updates;
pub mod experimental_features;
pub mod register_users;
pub mod room_membership;
pub mod rooms;
pub mod users;
pub mod version;
3 changes: 3 additions & 0 deletions src/room_membership.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//! Endpoints in the `/_synapse/admin/v<x>/join/` scope.

pub mod join_room;
3 changes: 3 additions & 0 deletions src/room_membership/join_room.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//! Different versions of the endpoint to place users into rooms.

pub mod v1;
45 changes: 45 additions & 0 deletions src/room_membership/join_room/v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//! [POST /_synapse/admin/v1/join/:room_id_or_alias](https://github.com/element-hq/synapse/blob/master/docs/admin_api/room_membership.md)

use ruma::{
api::{request, response, Metadata},
metadata, OwnedRoomId, OwnedRoomOrAliasId, OwnedUserId,
};

const METADATA: Metadata = metadata! {
method: POST,
rate_limited: false,
authentication: AccessToken,
history: {
unstable => "/_synapse/admin/v1/join/:room_id_or_alias",
}
};

#[request]
pub struct Request {
/// Alias or ID of the room to join.
#[ruma_api(path)]
pub room_id_or_alias: OwnedRoomOrAliasId,

/// User to join the room.
pub user_id: OwnedUserId,
}

#[response]
pub struct Response {
/// Room ID of the joined room.
pub room_id: OwnedRoomId,
}

impl Request {
/// Creates a new `Request` with the given room or alias ID and user id.
pub fn new(room_id_or_alias: OwnedRoomOrAliasId, user_id: OwnedUserId) -> Self {
Self { room_id_or_alias, user_id }
}
}

impl Response {
/// Creates a new `Response` with the given room id
pub fn new(room_id: OwnedRoomId) -> Self {
Self { room_id }
}
}
Loading