diff options
author | Erik Johnston <erik@matrix.org> | 2018-10-17 16:14:04 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2018-10-19 10:22:45 +0100 |
commit | 084046456ec88588779a62f9378c1a8e911bfc7c (patch) | |
tree | 12403c9d27e5cb8906be070ac54fb8f667233b2e /synapse/handlers/directory.py | |
parent | Newsfile (diff) | |
download | synapse-084046456ec88588779a62f9378c1a8e911bfc7c.tar.xz |
Add config option to control alias creation
Diffstat (limited to 'synapse/handlers/directory.py')
-rw-r--r-- | synapse/handlers/directory.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/synapse/handlers/directory.py b/synapse/handlers/directory.py index 02f12f6645..7d67bf803a 100644 --- a/synapse/handlers/directory.py +++ b/synapse/handlers/directory.py @@ -43,6 +43,7 @@ class DirectoryHandler(BaseHandler): self.state = hs.get_state_handler() self.appservice_handler = hs.get_application_service_handler() self.event_creation_handler = hs.get_event_creation_handler() + self.config = hs.config self.federation = hs.get_federation_client() hs.get_federation_registry().register_query_handler( @@ -111,6 +112,14 @@ class DirectoryHandler(BaseHandler): 403, "This user is not permitted to create this alias", ) + if not self.config.is_alias_creation_allowed(user_id, room_alias.to_string()): + # Lets just return a generic message, as there may be all sorts of + # reasons why we said no. TODO: Allow configurable error messages + # per alias creation rule? + raise SynapseError( + 403, "Not allowed to create alias", + ) + can_create = yield self.can_modify_alias( room_alias, user_id=user_id |