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

Commit

Permalink
Merge commit '0a7fb2471' into anoa/dinsic_release_1_21_x
Browse files Browse the repository at this point in the history
* commit '0a7fb2471':
  Fix invite rejection when we have no forward-extremeties (#7980)
  • Loading branch information
anoadragon453 committed Oct 16, 2020
2 parents aa81899 + 0a7fb24 commit 17826f4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog.d/7980.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix "no create event in auth events" when trying to reject invitation after inviter leaves. Bug introduced in Synapse v1.10.0.
29 changes: 21 additions & 8 deletions synapse/handlers/room_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,26 +500,39 @@ async def _update_membership(
user_id=target.to_string(), room_id=room_id
) # type: Optional[RoomsForUser]
if not invite:
logger.info(
"%s sent a leave request to %s, but that is not an active room "
"on this server, and there is no pending invite",
target,
room_id,
)

raise SynapseError(404, "Not a known room")

logger.info(
"%s rejects invite to %s from %s", target, room_id, invite.sender
)

if self.hs.is_mine_id(invite.sender):
# the inviter was on our server, but has now left. Carry on
# with the normal rejection codepath.
#
# This is a bit of a hack, because the room might still be
# active on other servers.
pass
else:
if not self.hs.is_mine_id(invite.sender):
# send the rejection to the inviter's HS (with fallback to
# local event)
return await self.remote_reject_invite(
invite.event_id, txn_id, requester, content,
)

# the inviter was on our server, but has now left. Carry on
# with the normal rejection codepath, which will also send the
# rejection out to any other servers we believe are still in the room.

# thanks to overzealous cleaning up of event_forward_extremities in
# `delete_old_current_state_events`, it's possible to end up with no
# forward extremities here. If that happens, let's just hang the
# rejection off the invite event.
#
# see: https://github.com/matrix-org/synapse/issues/7139
if len(latest_event_ids) == 0:
latest_event_ids = [invite.event_id]

return await self._local_membership_update(
requester=requester,
target=target,
Expand Down

0 comments on commit 17826f4

Please sign in to comment.