diff options
author | Kegan Dougal <kegan@matrix.org> | 2015-02-06 10:57:14 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2015-02-06 10:57:14 +0000 |
commit | e426df8e106aef0b213928afb6189569474ac5d9 (patch) | |
tree | cc3d87ba7b4da572afe2f76c644b1330a6d82001 /synapse/rest/client/v1/directory.py | |
parent | Add m.login.application_service registration procedure. (diff) | |
download | synapse-e426df8e106aef0b213928afb6189569474ac5d9.tar.xz |
Grant ASes the ability to create alias in their own namespace.
Add a new errcode type M_EXCLUSIVE when users try to create aliases inside AS namespaces, and when ASes try to create aliases outside their own namespace.
Diffstat (limited to 'synapse/rest/client/v1/directory.py')
-rw-r--r-- | synapse/rest/client/v1/directory.py | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/synapse/rest/client/v1/directory.py b/synapse/rest/client/v1/directory.py index 8f65efec5f..f7e910bb40 100644 --- a/synapse/rest/client/v1/directory.py +++ b/synapse/rest/client/v1/directory.py @@ -45,8 +45,6 @@ class ClientDirectoryServer(ClientV1RestServlet): @defer.inlineCallbacks def on_PUT(self, request, room_alias): - user, client = yield self.auth.get_user_by_req(request) - content = _parse_json(request) if not "room_id" in content: raise SynapseError(400, "Missing room_id key", @@ -70,16 +68,25 @@ class ClientDirectoryServer(ClientV1RestServlet): dir_handler = self.handlers.directory_handler try: - user_id = user.to_string() - yield dir_handler.create_association( - user_id, room_alias, room_id, servers + # try to auth as a user + user, client = yield self.auth.get_user_by_req(request) + try: + user_id = user.to_string() + yield dir_handler.create_association( + user_id, room_alias, room_id, servers + ) + yield dir_handler.send_room_alias_update_event(user_id, room_id) + except SynapseError as e: + raise e + except: + logger.exception("Failed to create association") + raise + except AuthError: + # try to auth as an application service + service = yield self.auth.get_appservice_by_req(request) + yield dir_handler.create_appservice_association( + service, room_alias, room_id, servers ) - yield dir_handler.send_room_alias_update_event(user_id, room_id) - except SynapseError as e: - raise e - except: - logger.exception("Failed to create association") - raise defer.returnValue((200, {})) |