summary refs log tree commit diff
path: root/synapse/handlers/directory.py
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/handlers/directory.py
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/handlers/directory.py')
-rw-r--r--synapse/handlers/directory.py28
1 files changed, 23 insertions, 5 deletions
diff --git a/synapse/handlers/directory.py b/synapse/handlers/directory.py
index 4c15e57fa6..c3c95996e7 100644
--- a/synapse/handlers/directory.py
+++ b/synapse/handlers/directory.py
@@ -87,10 +87,9 @@ class DirectoryHandler(BaseHandler):
 
     @defer.inlineCallbacks
     def delete_association(self, user_id, room_alias):
-        # TODO Check if server admin
+        # association deletion for human users
 
-        if not self.hs.is_mine(room_alias):
-            raise SynapseError(400, "Room alias must be local")
+        # TODO Check if server admin
 
         is_claimed = yield self.is_alias_exclusive_to_appservices(room_alias)
         if is_claimed:
@@ -99,10 +98,29 @@ class DirectoryHandler(BaseHandler):
                 errcode=Codes.EXCLUSIVE
             )
 
+        yield self._delete_association(room_alias)
+
+    @defer.inlineCallbacks
+    def delete_appservice_association(self, service, room_alias):
+        if not service.is_interested_in_alias(room_alias.to_string()):
+            raise SynapseError(
+                400,
+                "This application service has not reserved this kind of alias",
+                errcode=Codes.EXCLUSIVE
+            )
+        yield self._delete_association(room_alias)
+
+    @defer.inlineCallbacks
+    def _delete_association(self, room_alias):
+        if not self.hs.is_mine(room_alias):
+            raise SynapseError(400, "Room alias must be local")
+
         room_id = yield self.store.delete_room_alias(room_alias)
 
-        if room_id:
-            yield self._update_room_alias_events(user_id, room_id)
+        # TODO - Looks like _update_room_alias_event has never been implemented
+        # if room_id:
+        #    yield self._update_room_alias_events(user_id, room_id)
+
 
     @defer.inlineCallbacks
     def get_association(self, room_alias):