RocketChat / RocketChat/Rocket.Chat

[Feature Request] [Federation] Allow users to self-join federated rooms with proper homeserver registration

Open
#38,239 7 comments 0 reactions 1 assignee View on GitHub

@ggazzo is already working on this.

Since Feb 13, 2026.

type: feature
Dominant language
TypeScript
Stars
46.1k
Forks
13.9k
Avg merge
3d 3h
Merged PRs (30d)
130

Description

Description

Currently, when a user self-joins a federated room via channels.join API (without being explicitly invited), they are not registered on the Matrix homeserver. This means:

Their local subscription is created
They can see messages from federated users
But messages they send are NOT visible to users on remote Matrix servers
This creates a confusing user experience where the user appears to be in the room but their messages don't federate.

rc ss
Image
element
Image
Use Case

This issue primarily affects embedded chat scenarios (e.g., EmbeddedChat) where:

  1. A federated room is embedded on a website
  2. Users authenticate and access the room via the embedded widget
  3. Users expect to be able to send messages that are visible to all participants, including those on remote Matrix servers
    Currently, an admin must manually invite each user before they can participate in federated conversations, which doesn't scale for embedded/public room scenarios.
Technical Analysis

Root Cause
In apps/meteor/app/lib/server/functions/addUserToRoom.ts:


// for federation rooms we stop here since everything else will be handled by the federation invite flow
if (isRoomNativeFederated(room)) {
  return;  // Returns early without creating subscription or registering on homeserver
}

And in apps/meteor/ee/server/hooks/federation/index.ts :

beforeAddUserToRoom.add(
  async ({ user, inviter }, room) => {
    if (!user.username || !inviter) {  // Requires an inviter
      return;
    }
    // ... federation invite logic that registers user on homeserver
    await FederationMatrix.inviteUsersToRoom(room, [user.username], inviter);
  }
);

When a user self-joins (no inviter), the federation callback exits early and the user is never registered on the Matrix homeserver.

Current Flow (Self-Join)
User calls channels.join API
→ addUserToRoom() called without inviter
→ beforeAddUserToRoom callback checks for inviter → undefined, returns early
→ Function returns early for federated room
→ User gets local subscription but NO homeserver registration
→ Messages sent by user are NOT federated

Expected Flow
User calls channels.join API
→ addUserToRoom() called
→ User is registered on Matrix homeserver
→ Local subscription created
→ Messages sent by user ARE federated

Proposed Solutions

Option 1: Auto-register on self-join (Recommended)
Modify the federation callback to handle the case when inviter is undefined by using the room owner or a system user:

beforeAddUserToRoom.add(
  async ({ user, inviter }, room) => {
    if (!user.username) {
      return;
    }
    
    // For self-join, use room owner as the inviter
    const effectiveInviter = inviter || await getFirstRoomOwner(room._id);
    if (!effectiveInviter) {
      return;
    }
    
    await FederationMatrix.inviteUsersToRoom(room, [user.username], effectiveInviter);
  }
);

Option 2: New API endpoint
Add a dedicated endpoint like federation.joinRoom that explicitly handles the self-join case for federated rooms.

Option 3: Modify Room.join service
Update the Room.join service to pass the room owner as the inviter when joining federated rooms.

Questions for Maintainers

Was the invite-only requirement for federated rooms intentional (given the 100-user limit in beta)?
Is there a concern about resource usage if users can self-register on the homeserver?
Would you prefer Option 1 (minimal change) or a more explicit new endpoint?

Related

EmbeddedChat integration: https://github.com/RocketChat/EmbeddedChat

I'm happy to contribute a PR for whichever approach the team prefers. Thanks!

Task: FEDCORE-46

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.