Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions apps/meteor/server/lib/ldap/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,12 @@ export class LDAPManager {
},
},
...(homeServer && {
username: `${username}:${homeServer}`,
username: `@${username}:${homeServer}`,
federated: true,
federation: {
version: 1,
mui: `@${username}:${homeServer}`,
origin: homeServer,
},
}),
};
Expand Down Expand Up @@ -488,7 +490,7 @@ export class LDAPManager {
}

protected static getFederationHomeServer(ldapUser: ILDAPEntry): string | undefined {
if (!settings.get<boolean>('Federation_Matrix_enabled')) {
if (!settings.get<boolean>('Federation_Service_Enabled')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Setting key renamed from old Matrix federation system.

The federation enabled check now uses Federation_Service_Enabled instead of the deprecated Federation_Matrix_enabled setting. This aligns with the migration away from the old federation system.

Based on learnings: The old Matrix federation settings are being deprecated/removed.

Ensure that:

  1. The new Federation_Service_Enabled setting is properly defined in the settings registry
  2. There's documentation or migration guidance for users upgrading from the old federation system

🏁 Script executed:

#!/bin/bash
# Description: Verify the new federation setting is defined and check for any remaining references to the old setting

# Search for Federation_Service_Enabled setting definition
echo "=== Searching for Federation_Service_Enabled setting definition ==="
rg -n "Federation_Service_Enabled" --type ts -g '!**/node_modules/**' -C 2

echo -e "\n=== Checking for remaining references to old Federation_Matrix_enabled ==="
rg -n "Federation_Matrix_enabled" --type ts -g '!**/node_modules/**'

Length of output: 5354


🏁 Script executed:

#!/bin/bash
echo "=== Searching for documentation referencing Federation_Service_Enabled ==="
rg -n "Federation_Service_Enabled" -g "*.md"

Length of output: 74


Remove deprecated Federation_Matrix_enabled references and add migration guide

  • Update apps/meteor/server/services/federation/Settings.ts, apps/meteor/server/services/federation/infrastructure/rocket-chat/adapters/Statistics.ts, and apps/meteor/client/hooks/useIsFederationEnabled.ts to use only Federation_Service_Enabled.
  • Add documentation or upgrade notes for users migrating from the old Federation_Matrix_enabled setting.
🤖 Prompt for AI Agents
In apps/meteor/server/lib/ldap/Manager.ts around line 493, the code still checks
the deprecated Federation_Matrix_enabled setting; update references to use only
Federation_Service_Enabled and remove any legacy checks or fallbacks for
Federation_Matrix_enabled. Also update the three other files mentioned
(apps/meteor/server/services/federation/Settings.ts,
apps/meteor/server/services/federation/infrastructure/rocket-chat/adapters/Statistics.ts,
apps/meteor/client/hooks/useIsFederationEnabled.ts) to read exclusively from
Federation_Service_Enabled, remove any code paths that reference
Federation_Matrix_enabled, and add a short upgrade note or migration guide in
the repository docs/UPGRADE or CHANGELOG describing how to migrate existing
Federation_Matrix_enabled values to Federation_Service_Enabled (e.g., copy or
map old value to new key during upgrade).

return;
}

Expand All @@ -501,25 +503,14 @@ export class LDAPManager {

logger.debug({ msg: 'User has a federation home server', homeServer });

const localServer = settings.get<string>('Federation_Matrix_homeserver_domain');
const localServer = settings.get<string>('Federation_Service_Domain');
if (localServer === homeServer) {
return;
}

return homeServer;
}

protected static getFederatedUsername(ldapUser: ILDAPEntry, requestUsername: string): string {
const username = this.slugifyUsername(ldapUser, requestUsername);
const homeServer = this.getFederationHomeServer(ldapUser);

if (homeServer) {
return `${username}:${homeServer}`;
}

return username;
}

// This method will find existing users by LDAP id or by username.
private static async findExistingUser(ldapUser: ILDAPEntry, slugifiedUsername: string): Promise<IUser | undefined | null> {
const user = await this.findExistingLDAPUser(ldapUser);
Expand Down
Loading