summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2014-11-18 15:03:01 +0000
committerMark Haines <mark.haines@matrix.org>2014-11-18 15:03:13 +0000
commita5b88c489ebf23e076a99306e7c95e9b60e83864 (patch)
tree9e6d493cec26f95f3e92bc83e447589a638f81f7 /synapse/storage
parentwarn about memory (diff)
downloadsynapse-a5b88c489ebf23e076a99306e7c95e9b60e83864.tar.xz
Split out sending the room alias events from creating the alias so that we can do them in the right point when creating a room
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/directory.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/synapse/storage/directory.py b/synapse/storage/directory.py
index d6a7113b9c..f2e895a5c2 100644
--- a/synapse/storage/directory.py
+++ b/synapse/storage/directory.py
@@ -75,13 +75,18 @@ class DirectoryStore(SQLBaseStore):
         Returns:
             Deferred
         """
-        yield self._simple_insert(
-            "room_aliases",
-            {
-                "room_alias": room_alias.to_string(),
-                "room_id": room_id,
-            },
-        )
+        try:
+            yield self._simple_insert(
+                "room_aliases",
+                {
+                    "room_alias": room_alias.to_string(),
+                    "room_id": room_id,
+                },
+            )
+        except sqlite3.IntegrityError:
+            raise SynapseError(
+                409, "Room alias %s already exists" % room_alias.to_string()
+            )
 
         for server in servers:
             # TODO(erikj): Fix this to bulk insert