From a5b88c489ebf23e076a99306e7c95e9b60e83864 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Tue, 18 Nov 2014 15:03:01 +0000 Subject: 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 --- synapse/storage/directory.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'synapse/storage') 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 -- cgit 1.5.1