mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-08-01 17:38:36 +00:00
add command to set the allow registration status
Co-Authored-By: Matthias Ahouansou <matthias@ahouansou.cz>
This commit is contained in:
parent
817f382c5f
commit
6bcc2f80b8
3 changed files with 33 additions and 3 deletions
|
@ -160,6 +160,9 @@ enum AdminCommand {
|
|||
password: Option<String>,
|
||||
},
|
||||
|
||||
/// Temporarily toggle user registration by passing either true or false as an argument, does not persist between restarts
|
||||
AllowRegistration { status: Option<bool> },
|
||||
|
||||
/// Disables incoming federation handling for a room.
|
||||
DisableRoom { room_id: Box<RoomId> },
|
||||
/// Enables incoming federation handling for a room again.
|
||||
|
@ -656,6 +659,24 @@ impl Service {
|
|||
"Created user with user_id: {user_id} and password: {password}"
|
||||
))
|
||||
}
|
||||
AdminCommand::AllowRegistration { status } => {
|
||||
if let Some(status) = status {
|
||||
services().globals.set_registration(status).await;
|
||||
RoomMessageEventContent::text_plain(if status {
|
||||
"Registration is now enabled"
|
||||
} else {
|
||||
"Registration is now disabled"
|
||||
})
|
||||
} else {
|
||||
RoomMessageEventContent::text_plain(
|
||||
if services().globals.allow_registration().await {
|
||||
"Registration is currently enabled"
|
||||
} else {
|
||||
"Registration is currently disabled"
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
AdminCommand::DisableRoom { room_id } => {
|
||||
services().rooms.metadata.disable_room(&room_id, true)?;
|
||||
RoomMessageEventContent::text_plain("Room disabled.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue