config option to block non-admin room invites

works just like block_non_admin_invites from synapse

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-03-02 21:45:08 -05:00 committed by June
parent c97483dbd3
commit ea66bff46b
5 changed files with 34 additions and 0 deletions

View file

@ -190,6 +190,17 @@ pub async fn invite_user_route(
) -> Result<invite_user::v3::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if !services().users.is_admin(sender_user)? && services().globals.block_non_admin_invites() {
info!(
"User {sender_user} is not an admin and attempted to send an invite to room {}",
&body.room_id
);
return Err(Error::BadRequest(
ErrorKind::Forbidden,
"Invites are not allowed on this server.",
));
}
if let invite_user::v3::InvitationRecipient::UserId { user_id } = &body.recipient {
invite_helper(
sender_user,

View file

@ -1845,6 +1845,13 @@ pub async fn create_invite_route(
.as_ref()
.expect("server is authenticated");
if services().globals.block_non_admin_invites() {
info!("Received remote invite from server {} for room {}, but \"block_non_admin_invites\" is enabled, rejecting.", &sender_servername, &body.room_id);
return Err(Error::BadRequest(
ErrorKind::Forbidden,
"This server does not allow room invites.",
));
}
services()
.rooms
.event_handler