summary refs log tree commit diff
path: root/synapse/rest/directory.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-09-30 11:31:22 +0100
committerErik Johnston <erik@matrix.org>2014-09-30 11:31:42 +0100
commite06adc6d7e645e5116c28d2b5756a70bb8f4f240 (patch)
tree4c7f2d72fb6bd321411e013c7d9f20c2bd367488 /synapse/rest/directory.py
parentRe-wrap content after latest additions (diff)
downloadsynapse-e06adc6d7e645e5116c28d2b5756a70bb8f4f240.tar.xz
SYN-2: Allow server admins to delete room aliases
Diffstat (limited to 'synapse/rest/directory.py')
-rw-r--r--synapse/rest/directory.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/synapse/rest/directory.py b/synapse/rest/directory.py
index 31849246a1..6c260e7102 100644
--- a/synapse/rest/directory.py
+++ b/synapse/rest/directory.py
@@ -16,7 +16,7 @@
 
 from twisted.internet import defer
 
-from synapse.api.errors import SynapseError, Codes
+from synapse.api.errors import AuthError, SynapseError, Codes
 from base import RestServlet, client_path_pattern
 
 import json
@@ -81,6 +81,24 @@ class ClientDirectoryServer(RestServlet):
 
         defer.returnValue((200, {}))
 
+    @defer.inlineCallbacks
+    def on_DELETE(self, request, room_alias):
+        user = 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 = self.hs.parse_roomalias(urllib.unquote(room_alias))
+
+        yield dir_handler.delete_association(
+            user.to_string(), room_alias
+        )
+
+        defer.returnValue((200, {}))
+
 
 def _parse_json(request):
     try: