mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 12:36:02 -04:00
Add a spamchecker callback to allow or deny room creation based on invites (#10898)
This is in the context of creating new module callbacks that modules in https://github.com/matrix-org/synapse-dinsic can use, in an effort to reconcile the spam checker API in synapse-dinsic with the one in mainline. This adds a callback that's fairly similar to user_may_create_room except it also allows processing based on the invites sent at room creation.
This commit is contained in:
parent
ea01d4c2de
commit
b10257e879
5 changed files with 199 additions and 6 deletions
|
@ -649,8 +649,16 @@ class RoomCreationHandler(BaseHandler):
|
|||
requester, config, is_requester_admin=is_requester_admin
|
||||
)
|
||||
|
||||
if not is_requester_admin and not await self.spam_checker.user_may_create_room(
|
||||
user_id
|
||||
invite_3pid_list = config.get("invite_3pid", [])
|
||||
invite_list = config.get("invite", [])
|
||||
|
||||
if not is_requester_admin and not (
|
||||
await self.spam_checker.user_may_create_room(user_id)
|
||||
and await self.spam_checker.user_may_create_room_with_invites(
|
||||
user_id,
|
||||
invite_list,
|
||||
invite_3pid_list,
|
||||
)
|
||||
):
|
||||
raise SynapseError(403, "You are not permitted to create rooms")
|
||||
|
||||
|
@ -684,8 +692,6 @@ class RoomCreationHandler(BaseHandler):
|
|||
if mapping:
|
||||
raise SynapseError(400, "Room alias already taken", Codes.ROOM_IN_USE)
|
||||
|
||||
invite_3pid_list = config.get("invite_3pid", [])
|
||||
invite_list = config.get("invite", [])
|
||||
for i in invite_list:
|
||||
try:
|
||||
uid = UserID.from_string(i)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue