Skip to content

federation: require current membership on send_join retries - #718

Open
basnijholt wants to merge 1 commit into
matrix-construct:mainfrom
mindroom-ai:upstream-send-join-membership
Open

basnijholt wants to merge 1 commit into
matrix-construct:mainfrom
mindroom-ai:upstream-send-join-membership

Conversation

@basnijholt

Copy link
Copy Markdown
Contributor

What does this PR do?

/send_join returns the room state when the join event is accepted. When the submitted join had already been handled before (a retry), the handler returned the state on the strength of that stored event alone. A join the server accepted earlier for a user who has since left therefore still returned the room's current state.

The event handler already tells a newly appended join from one it handled before. A retry now succeeds only while its user is still joined; a new join needs no second lookup. Membership lookup errors propagate instead of counting as an answer.

Found through MindRoom. Fork change: mindroom-ai/mindroom-tuwunel#114.

Tests:

  • send_join::tests::only_join_retries_require_current_membership: a new join skips the membership lookup, a retry for a joined user succeeds, a retry for a user who left is refused. It fails without the fix (the retry for the departed user succeeds).

Validation:

  • Nightly rustfmt (nightly-2026-11-03, the formatter upstream uses since e754d6cdd): cargo fmt --all -- --check passes.
  • cargo clippy --offline --locked -p tuwunel_api_federation --all-targets --all-features -- -D warnings passes.
  • cargo test -p tuwunel_api_federation -p tuwunel --lib --test federation_membership_refusal: 45 passed.
  • Complement was not run. Retries of a still-valid join behave as before, so no baseline change is expected; this was not measured.

Checklist

  • Code is formatted with nightly cargo fmt and satisfies clippy and rustc lints; any allowed lint is justified by an obvious reason or a comment.
  • Complement compliance changes (new passes or new failures), if any, are noted in the description above.
  • Config option changes were made in src/core/config/mod.rs doc comments and the regenerated tuwunel-example.toml is committed. (No config changes.)
  • User-facing changes are reflected in docs/. (No user-facing docs change.)
  • I agree that my changes may be licensed under the Apache-2.0 licence and my conduct is in line with the Contributor's Covenant and Tuwunel's Code of Conduct.

The event handler distinguishes a newly appended join from a join it
already handled. Use that distinction before returning the room state:
a retry still succeeds while its user is joined, but an old join alone
no longer establishes membership. Do not look up membership again for a
newly appended join.

Assisted-by: MindRoom DevAgent:openai/gpt-6.2-astra <https://github.com/mindroom-ai/mindroom>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant