mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-12-15 11:16:26 -05:00
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
This commit is contained in:
parent
c571dd4f0e
commit
a5b88c489e
4 changed files with 31 additions and 27 deletions
|
|
@ -56,17 +56,11 @@ class DirectoryHandler(BaseHandler):
|
|||
if not servers:
|
||||
raise SynapseError(400, "Failed to get server list")
|
||||
|
||||
try:
|
||||
yield self.store.create_room_alias_association(
|
||||
room_alias,
|
||||
room_id,
|
||||
servers
|
||||
)
|
||||
except sqlite3.IntegrityError:
|
||||
defer.returnValue("Already exists")
|
||||
|
||||
# TODO: Send the room event.
|
||||
yield self._update_room_alias_events(user_id, room_id)
|
||||
yield self.store.create_room_alias_association(
|
||||
room_alias,
|
||||
room_id,
|
||||
servers
|
||||
)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def delete_association(self, user_id, room_alias):
|
||||
|
|
@ -136,7 +130,7 @@ class DirectoryHandler(BaseHandler):
|
|||
})
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _update_room_alias_events(self, user_id, room_id):
|
||||
def send_room_alias_update_event(self, user_id, room_id):
|
||||
aliases = yield self.store.get_aliases_for_room(room_id)
|
||||
|
||||
event = self.event_factory.create_event(
|
||||
|
|
|
|||
|
|
@ -106,6 +106,15 @@ class RoomCreationHandler(BaseHandler):
|
|||
if not room_id:
|
||||
raise StoreError(500, "Couldn't generate a room ID.")
|
||||
|
||||
if room_alias:
|
||||
directory_handler = self.hs.get_handlers().directory_handler
|
||||
yield directory_handler.create_association(
|
||||
user_id=user_id,
|
||||
room_id=room_id,
|
||||
room_alias=room_alias,
|
||||
servers=[self.hs.hostname],
|
||||
)
|
||||
|
||||
user = self.hs.parse_userid(user_id)
|
||||
creation_events = self._create_events_for_new_room(
|
||||
user, room_id, is_public=is_public
|
||||
|
|
@ -180,13 +189,7 @@ class RoomCreationHandler(BaseHandler):
|
|||
|
||||
if room_alias:
|
||||
result["room_alias"] = room_alias.to_string()
|
||||
directory_handler = self.hs.get_handlers().directory_handler
|
||||
yield directory_handler.create_association(
|
||||
user_id=user_id,
|
||||
room_id=room_id,
|
||||
room_alias=room_alias,
|
||||
servers=[self.hs.hostname],
|
||||
)
|
||||
directory_handler.send_room_alias_update_event(user_id, room_id)
|
||||
|
||||
defer.returnValue(result)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue