mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-05 11:08:00 +00:00
When an admin accepts a knock, the knocker gets an invite and has to accept it by hand, though they already asked to join. With `experimental_features.msc4509_enabled` set, this server joins them itself. The flag defaults to off while MSC4509 is unstable. An invite accepts a knock when the invitee's own knock event is among the invite's auth events, as the MSC4509 "Auto-joining on accepted knocks" section specifies. The auth events show the invite was authorised against the knock, so an unrelated invite does not qualify. They also work for an invite received over federation, where this server holds the knock it created but no state for the room. The check runs from the two places that already hold the invite and its auth events: `RoomMemberHandler._local_membership_update` for a local invite and `FederationHandler.on_invite_request` for a remote one. A per-event module callback such as `on_new_event` would fetch the room's full current state for every persisted event, before any event-type filter. The join runs as a background process. The caller holds the per-room membership lock the join needs, and for a remote invite the `send_join` handshake must not block the inviting server's `/invite` request. A failed join is logged; the invite stays, so the user can still accept it by hand. MSC4509 requires the join to name the user who accepted the knock. Synapse already fills `unsigned.prev_sender` from the replaced invite, and the local test asserts it. The MSC4268 key bundle hint is left to a follow-up: sending to-device messages from an arbitrary worker needs a replication route to the `to_device` writer that does not exist yet. Co-authored-by: Matthew Hodgson <matthew@matrix.org> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>