mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 13:46:02 -04:00
Add room creation checks to spam checker
Lets the spam checker deny attempts to create rooms and add aliases to them.
This commit is contained in:
parent
5f20a91fa1
commit
197c14dbcf
3 changed files with 47 additions and 0 deletions
|
@ -40,6 +40,8 @@ class DirectoryHandler(BaseHandler):
|
|||
"directory", self.on_directory_query
|
||||
)
|
||||
|
||||
self.spam_checker = hs.get_spam_checker()
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _create_association(self, room_alias, room_id, servers=None, creator=None):
|
||||
# general association creation for both human users and app services
|
||||
|
@ -73,6 +75,11 @@ class DirectoryHandler(BaseHandler):
|
|||
# association creation for human users
|
||||
# TODO(erikj): Do user auth.
|
||||
|
||||
if not self.spam_checker.user_may_create_room_alias(user_id, room_alias):
|
||||
raise SynapseError(
|
||||
403, "This user is not permitted to create this alias",
|
||||
)
|
||||
|
||||
can_create = yield self.can_modify_alias(
|
||||
room_alias,
|
||||
user_id=user_id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue