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

Auto-joining a remote autojoin room doesn't work reliably #10233

Closed
benbz opened this issue Jun 23, 2021 · 1 comment · Fixed by #10237
Closed

Auto-joining a remote autojoin room doesn't work reliably #10233

benbz opened this issue Jun 23, 2021 · 1 comment · Fixed by #10237

Comments

@benbz
Copy link
Contributor

benbz commented Jun 23, 2021

Description

Users registering on HS B can't auto-join a room on HS A that's listed in auto_join_rooms if they are either the 1st user on HS B or if there are no users on HS B that are in the room on HS A.

Steps to reproduce

  • HS A has a public, federatable room with an alias
  • HS B sets auto_join_rooms to include the room on HS A
  • If there are no existing users on HS B:
    • 1st user registers
    • Auto-joining skipped with Cannot create room alias #HS-A:room-alias it does not match server domain
  • If there are existing users on HS B and no-one on HS B is in this room

The expectation is that auto_join_rooms works with any public room local or federated.

Version information

  • Homeserver: Any 2 publicly federated servers
  • Version: 1.36.0
  • Install method: Docker
  • Platform: Linux
@erikjohnston
Copy link
Member

I think

state = await self.store.get_filtered_current_state_ids(
room_id, StateFilter.from_types([(EventTypes.JoinRules, "")])
)
event_id = state.get((EventTypes.JoinRules, ""))
if event_id:
join_rules_event = await self.store.get_event(
event_id, allow_none=True
)
if join_rules_event:
join_rule = join_rules_event.content.get("join_rule", None)
requires_invite = join_rule and join_rule != JoinRules.PUBLIC
# Send the invite, if necessary.
if requires_invite:
is the problematic logic here. I think we can fix it by adding a check to see if the host is in the room and the alias is remote.

We also need to handle the case where auto creating auto join is enabled but the alias is remote:

if self.hs.hostname != room_alias.domain:
logger.warning(
"Cannot create room alias %s, "
"it does not match server domain",
r,
)

babolivier added a commit that referenced this issue Jun 23, 2021
If a room is remote and we don't have a user in it, always try to join it. It might fail if the room is invite-only, but we don't have a user to invite with, so at this point it's the best we can do.

Fixes #10233 (at least to some extent)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants