Skip to content

Auto-join rooms when a knock is accepted#19958

Open
ara4n wants to merge 4 commits into
developfrom
matthew/auto-join-on-knock-accept
Open

Auto-join rooms when a knock is accepted#19958
ara4n wants to merge 4 commits into
developfrom
matthew/auto-join-on-knock-accept

Conversation

@ara4n

@ara4n ara4n commented Jul 14, 2026

Copy link
Copy Markdown
Member

When an invite arrives for a user who has a pending knock in that room (i.e. the knock was accepted), automatically join the user rather than making them accept the resulting invite by hand. Detected by the invited user's own knock membership event appearing in the invite's auth events, which holds for local and federated invites alike.

On by default (the user already asked to join by knocking); can be disabled with auto_accept_invites.enabled_for_accepted_knocks.

Fixes #16307

Implements MSC4509

Caveat: apparently when enabled this adds +3 db txns (db_txn_count) to every single event processed, because it uses the InviteAutoAccepter module which registers an on_new_event third-party-rules callback which in turn adds a state fetch per event.

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Code style is correct (run the linters)

When an invite arrives for a user who has a pending knock in that room
(i.e. the knock was accepted), automatically join the user rather than
making them accept the resulting invite by hand (#16307). Detected by
the invited user's own knock membership event appearing in the invite's
auth events, which holds for local and federated invites alike.

On by default (the user already asked to join by knocking); can be
disabled with auto_accept_invites.enabled_for_accepted_knocks.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uk8aPxHn3BHCe52L226jdG
@ara4n
ara4n requested a review from a team as a code owner July 14, 2026 16:04
ara4n and others added 2 commits July 14, 2026 17:04
…d events

Instantiating the InviteAutoAccepter by default registered a third-party-
rules on_new_event callback on every homeserver, which (a) added a state
fetch per new event, perturbing db txn counts and sliding-sync test
expectations, and (b) exposed a latent bug: the callback dispatcher
fetched events without allow_rejected=True, so a rejected federation
event raised NotFoundError out of the notifier and broke event
persistence. Make enabled_for_accepted_knocks default off (matching
auto_accept_invites.enabled) and fix the dispatcher to skip rejected
events, with a regression test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uk8aPxHn3BHCe52L226jdG
A server-initiated join lands on all the user's devices in the same
sync instant, so each would otherwise eagerly download the MSC4268 room
key bundle. Send the most recently active device an
org.matrix.msc4509.key_bundle_claim to-device hint (MSC4509) so exactly
one device claims eagerly; the rest defer until first needed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uk8aPxHn3BHCe52L226jdG
@ara4n
ara4n force-pushed the matthew/auto-join-on-knock-accept branch from 0950350 to b618cc4 Compare July 15, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-join rooms when knock accepted

2 participants