RocketChat / RocketChat/homeserver
Include banned and invited servers in event destination set
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 16
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
Problem
getServerSetInRoom (in StateService) only includes servers that have at least one user with membership: 'join'. When a user is banned, their membership changes from join to ban. If they were the only user from their server, that server is excluded from the destination set for subsequent events — including the unban event.
What happens today
- Server A bans a user from Server B
- Ban event is sent to Server B (user still had
joinwhen server set was computed) - Server B processes the ban, membership updates to
ban - Server A unbans the user (sends
membership: leaveviakickUser) sendEventToAllServersInRoomcomputes the server set — Server B has nojoinmembers → excluded from destinations- The leave (unban) event is never delivered to Server B
- Server A tries to re-invite the user — builds an invite whose
prev_eventsreference the leave event - Server A sends the invite to Server B via
/v2/invite - Server B has
m.room.create(user had previously joined), soprocessInvitecallshandlePdu handlePdu→_resolveStateAtEvent→ looks forstateIdofprev_events→ the leave event was never received → "no previous state for event" error- Invite processing fails, Server A gets a 500
Impact
- After a ban+unban cycle in a federated room, the user cannot be re-invited
- The state chain on the remote server becomes broken because intermediate events are missing
- Affects RC ↔ RC federation. RC ↔ Element (Synapse) works because Synapse handles server routing differently
Root cause
The Matrix spec states that servers should continue receiving events for rooms where they have any membership state (join, invite, ban, leave with prior membership). Our getServerSetInRoom only considers join membership, which is too restrictive.
Proposed fix
getServerSetInRoom should include servers that have users with ban or invite membership in addition to join. A banned user's server still needs to receive room events (at minimum the unban event) to maintain a consistent state chain.
From the spec perspective, the set of servers that should receive events ("resident servers") includes any server with at least one user with membership join or invite. For ban, the server should receive at minimum the events needed to transition out of the banned state.
Simpler alternative: when sending a ban-related event (membership: leave after ban), explicitly add the target user's server to the destination set regardless of their current membership.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at StateService.getServerSetInRoom and trace how sendEventToAllServersInRoom builds destinations for ban and unban events. Compare the current membership filtering with the Matrix resident-server behavior described here, then verify that a ban/unban cycle delivers the intermediate leave event and allows the subsequent invite to process without a missing-state error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100