summary refs log tree commit diff
path: root/synapse/rest/client
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2015-02-06 11:32:07 +0000
committerKegan Dougal <kegan@matrix.org>2015-02-06 11:32:07 +0000
commitc3ae8def755a043283e945e6653970599d227a43 (patch)
tree21bf9a02ac7eef5010bfcea45b8da54ee9b9955d /synapse/rest/client
parentGrant ASes the ability to create alias in their own namespace. (diff)
downloadsynapse-c3ae8def755a043283e945e6653970599d227a43.tar.xz
Grant ASes the ability to delete aliases in their own namespace.
Diffstat (limited to 'synapse/rest/client')
-rw-r--r--synapse/rest/client/v1/directory.py31
1 files changed, 29 insertions, 2 deletions
diff --git a/synapse/rest/client/v1/directory.py b/synapse/rest/client/v1/directory.py
index f7e910bb40..8e83548bbf 100644
--- a/synapse/rest/client/v1/directory.py
+++ b/synapse/rest/client/v1/directory.py
@@ -87,24 +87,51 @@ class ClientDirectoryServer(ClientV1RestServlet):
             yield dir_handler.create_appservice_association(
                 service, room_alias, room_id, servers
             )
+            logger.info(
+                "Application service at %s created alias %s pointing to %s",
+                service.url,
+                room_alias.to_string(),
+                room_id
+            )
 
         defer.returnValue((200, {}))
 
     @defer.inlineCallbacks
     def on_DELETE(self, request, room_alias):
+        dir_handler = self.handlers.directory_handler
+
+        try:
+            service = yield self.auth.get_appservice_by_req(request)
+            room_alias = RoomAlias.from_string(room_alias)
+            yield dir_handler.delete_appservice_association(
+                service, room_alias
+            )
+            logger.info(
+                "Application service at %s deleted alias %s",
+                service.url,
+                room_alias.to_string()
+            )
+            defer.returnValue((200, {}))
+        except AuthError:
+            # fallback to default user behaviour if they aren't an AS
+            pass
+
         user, client = yield self.auth.get_user_by_req(request)
 
         is_admin = yield self.auth.is_server_admin(user)
         if not is_admin:
             raise AuthError(403, "You need to be a server admin")
 
-        dir_handler = self.handlers.directory_handler
-
         room_alias = RoomAlias.from_string(room_alias)
 
         yield dir_handler.delete_association(
             user.to_string(), room_alias
         )
+        logger.info(
+            "User %s deleted alias %s",
+            user.to_string(),
+            room_alias.to_string()
+        )
 
         defer.returnValue((200, {}))