diff --git a/synapse/visibility.py b/synapse/visibility.py index 737328056e3..17ec15f42cb 100644 --- a/synapse/visibility.py +++ b/synapse/visibility.py @@ -168,10 +168,11 @@ def allowed(event: EventBase) -> Optional[EventBase]: # we won't have such a state. The only outliers that are returned here are the # user's own membership event, so we can just inspect that. + user_membership_event: Optional[EventBase] if event.type == EventTypes.Member and event.state_key == user_id: user_membership_event = event elif state_after_event is not None: - user_membership_event = state_after_event[(EventTypes.Member, user_id)] + user_membership_event = state_after_event.get((EventTypes.Member, user_id)) else: # unreachable! raise Exception("Missing state for event that is not user's own membership")