summary refs log tree commit diff
path: root/synapse/handlers/directory.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-03-09 14:25:06 +0000
committerErik Johnston <erik@matrix.org>2015-03-09 14:25:06 +0000
commitd5174065af7bf0f5ce0bf608c28d835bd8f6ddab (patch)
treeb0bfcbe05c92427c307095971f52e92b9ec48ee0 /synapse/handlers/directory.py
parentMerge pull request #98 from matrix-org/hotfixes-v0.7.1-r4 (diff)
parentD'oh: underscore, not hyphen (diff)
downloadsynapse-d5174065af7bf0f5ce0bf608c28d835bd8f6ddab.tar.xz
Merge branch 'release-v0.8.0' of github.com:matrix-org/synapse v0.8.0
Diffstat (limited to 'synapse/handlers/directory.py')
-rw-r--r--synapse/handlers/directory.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/synapse/handlers/directory.py b/synapse/handlers/directory.py
index 20ab9e269c..f76febee8f 100644
--- a/synapse/handlers/directory.py
+++ b/synapse/handlers/directory.py
@@ -160,7 +160,7 @@ class DirectoryHandler(BaseHandler):
         if not room_id:
             raise SynapseError(
                 404,
-                "Room alias %r not found" % (room_alias.to_string(),),
+                "Room alias %s not found" % (room_alias.to_string(),),
                 Codes.NOT_FOUND
             )
 
@@ -232,13 +232,23 @@ class DirectoryHandler(BaseHandler):
 
     @defer.inlineCallbacks
     def can_modify_alias(self, alias, user_id=None):
+        # Any application service "interested" in an alias they are regexing on
+        # can modify the alias.
+        # Users can only modify the alias if ALL the interested services have
+        # non-exclusive locks on the alias (or there are no interested services)
         services = yield self.store.get_app_services()
         interested_services = [
             s for s in services if s.is_interested_in_alias(alias.to_string())
         ]
+
         for service in interested_services:
             if user_id == service.sender:
-                # this user IS the app service
+                # this user IS the app service so they can do whatever they like
                 defer.returnValue(True)
                 return
-        defer.returnValue(len(interested_services) == 0)
+            elif service.is_exclusive_alias(alias.to_string()):
+                # another service has an exclusive lock on this alias.
+                defer.returnValue(False)
+                return
+        # either no interested services, or no service with an exclusive lock
+        defer.returnValue(True)