Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix error when sending message into deleted room.
Browse files Browse the repository at this point in the history
When a room is deleted in Synapse we remove the event forward
extremities in the room, so if (say a bot) tries to send a message into
the room we error out due to not being able to calculate prev events for
the new event *before* we check if the sender is in the room.

Fixes #8094
  • Loading branch information
erikjohnston committed Mar 9, 2023
1 parent caf43c3 commit e65da2d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,17 @@ async def create_new_client_event(
len(prev_event_ids),
)
else:
# If we don't have any prev event IDs specified then we need to
# check that the host is in the room (as otherwise populating the
# prev events will fail), at which point we may as well check the
# local user is in the room.
user_id = requester.user.to_string()
is_user_in_room = await self.store.check_local_user_in_room(
requester.user.to_string(), builder.room_id
)
if not is_user_in_room:
raise AuthError(403, f"User {user_id} not in room {builder.room_id}")

prev_event_ids = await self.store.get_prev_events_for_room(builder.room_id)

# Do a quick sanity check here, rather than waiting until we've created the
Expand Down

0 comments on commit e65da2d

Please sign in to comment.