-
Notifications
You must be signed in to change notification settings - Fork 429
Description
@AndrewFerr invited me to a v12 room that was restricted to the Element internal space. Upon trying to join it, I received the following error in Element Web:
Unable to find a user which could issue an invite
This appears to be due to this code:
synapse/synapse/handlers/event_auth.py
Lines 161 to 199 in d087fb6
| # Find the user with the highest power level (only interested in local | |
| # users). | |
| user_power_level = 0 | |
| chosen_user = None | |
| local_users_in_room = await self._store.get_local_users_in_room(room_id) | |
| if create_event.room_version.msc4289_creator_power_enabled: | |
| creators = set( | |
| create_event.content.get(EventContentFields.ADDITIONAL_CREATORS, []) | |
| ) | |
| creators.add(create_event.sender) | |
| local_creators = creators.intersection(set(local_users_in_room)) | |
| if len(local_creators) > 0: | |
| chosen_user = local_creators.pop() # random creator | |
| user_power_level = CREATOR_POWER_LEVEL | |
| else: | |
| chosen_user = max( | |
| local_users_in_room, | |
| key=lambda user: users.get(user, users_default_level), | |
| default=None, | |
| ) | |
| # Return the chosen if they can issue invites. | |
| if chosen_user: | |
| user_power_level = users.get(chosen_user, users_default_level) | |
| if chosen_user and user_power_level >= invite_level: | |
| logger.debug( | |
| "Found a user who can issue invites %s with power level %d >= invite level %d", | |
| chosen_user, | |
| user_power_level, | |
| invite_level, | |
| ) | |
| return chosen_user | |
| # No user was found. | |
| raise SynapseError( | |
| 400, | |
| "Unable to find a user which could issue an invite", | |
| Codes.UNABLE_TO_GRANT_JOIN, | |
| ) |
which checks to see if any of the room's creators are local users. In this case, the room creator was @fair:miscworks.net, which is not a local user.
Thus we drop out of the if create_event.room_version.msc4289_creator_power_enabled statement, past the if chosen_user and user_power_level >= invite_level as chosen_user is None, and hit the SynapseError.
It looks like in the case of v12+ rooms, this code should be re-worked to consider both room creators and any local user that has the power to invite other users.