snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s

This commit is contained in:
upstream-mirror
2026-09-16 01:21:02 +05:00
commit 30810eecd7
10161 changed files with 987110 additions and 0 deletions

View File

@@ -0,0 +1,156 @@
import crypto from 'node:crypto';
import { settings, settingsRegistry } from '../../settings';
export const addMatrixBridgeFederationSettings = async (): Promise<void> => {
await settingsRegistry.add('Federation_Matrix_enabled', false, {
readonly: true,
type: 'boolean',
i18nLabel: 'Federation_Matrix_enabled',
i18nDescription: 'Federation_Matrix_enabled_desc',
alert: 'Old_Federation_Alert',
public: true,
group: 'Federation',
section: 'Matrix Bridge',
});
await settingsRegistry.add('Federation_Matrix_serve_well_known', true, {
readonly: true,
type: 'boolean',
i18nLabel: 'Federation_Matrix_serve_well_known',
alert: 'Federation_Matrix_serve_well_known_Alert',
group: 'Federation',
section: 'Matrix Bridge',
});
await settingsRegistry.add('Federation_Matrix_enable_ephemeral_events', false, {
readonly: true,
type: 'boolean',
i18nLabel: 'Federation_Matrix_enable_ephemeral_events',
i18nDescription: 'Federation_Matrix_enable_ephemeral_events_desc',
alert: 'Federation_Matrix_enable_ephemeral_events_Alert',
public: true,
group: 'Federation',
section: 'Matrix Bridge',
});
const uniqueId = settings.get('uniqueID') || crypto.randomUUID().slice(0, 15).replaceAll('-', '_');
const homeserverToken = crypto.createHash('sha256').update(`hs_${uniqueId}`).digest('hex');
const applicationServiceToken = crypto.createHash('sha256').update(`as_${uniqueId}`).digest('hex');
const siteUrl = settings.get<string>('Site_Url');
await settingsRegistry.add('Federation_Matrix_id', `rocketchat_${uniqueId}`, {
readonly: true,
type: 'string',
i18nLabel: 'Federation_Matrix_id',
i18nDescription: 'Federation_Matrix_id_desc',
group: 'Federation',
section: 'Matrix Bridge',
});
await settingsRegistry.add('Federation_Matrix_hs_token', homeserverToken, {
readonly: true,
type: 'string',
i18nLabel: 'Federation_Matrix_hs_token',
i18nDescription: 'Federation_Matrix_hs_token_desc',
group: 'Federation',
section: 'Matrix Bridge',
});
await settingsRegistry.add('Federation_Matrix_as_token', applicationServiceToken, {
readonly: true,
type: 'string',
i18nLabel: 'Federation_Matrix_as_token',
i18nDescription: 'Federation_Matrix_as_token_desc',
group: 'Federation',
section: 'Matrix Bridge',
});
await settingsRegistry.add('Federation_Matrix_homeserver_url', 'http://localhost:8008', {
readonly: true,
type: 'string',
i18nLabel: 'Federation_Matrix_homeserver_url',
i18nDescription: 'Federation_Matrix_homeserver_url_desc',
alert: 'Federation_Matrix_homeserver_url_alert',
group: 'Federation',
section: 'Matrix Bridge',
});
await settingsRegistry.add('Federation_Matrix_homeserver_domain', siteUrl, {
readonly: true,
type: 'string',
i18nLabel: 'Federation_Matrix_homeserver_domain',
i18nDescription: 'Federation_Matrix_homeserver_domain_desc',
alert: 'Federation_Matrix_homeserver_domain_alert',
group: 'Federation',
section: 'Matrix Bridge',
});
await settingsRegistry.add('Federation_Matrix_bridge_url', 'http://localhost:3300', {
readonly: true,
type: 'string',
i18nLabel: 'Federation_Matrix_bridge_url',
i18nDescription: 'Federation_Matrix_bridge_url_desc',
group: 'Federation',
section: 'Matrix Bridge',
});
await settingsRegistry.add('Federation_Matrix_bridge_localpart', 'rocket.cat', {
readonly: true,
type: 'string',
i18nLabel: 'Federation_Matrix_bridge_localpart',
i18nDescription: 'Federation_Matrix_bridge_localpart_desc',
group: 'Federation',
section: 'Matrix Bridge',
});
await settingsRegistry.add('Federation_Matrix_registration_file', '', {
readonly: true,
type: 'code',
i18nLabel: 'Federation_Matrix_registration_file',
i18nDescription: 'Federation_Matrix_registration_file_desc',
alert: 'Federation_Matrix_registration_file_Alert',
group: 'Federation',
section: 'Matrix Bridge',
});
await settingsRegistry.add('Federation_Matrix_max_size_of_public_rooms_users', 100, {
readonly: true,
type: 'int',
i18nLabel: 'Federation_Matrix_max_size_of_public_rooms_users',
i18nDescription: 'Federation_Matrix_max_size_of_public_rooms_users_desc',
alert: 'Federation_Matrix_max_size_of_public_rooms_users_Alert',
modules: ['federation'],
public: true,
enterprise: true,
invalidValue: false,
group: 'Federation',
section: 'Matrix Bridge',
});
await settingsRegistry.add('Federation_Matrix_configuration_status', 'Invalid', {
readonly: true,
hidden: true,
type: 'string',
i18nLabel: 'Federation_Matrix_configuration_status',
i18nDescription: 'Federation_Matrix_configuration_status_desc',
public: false,
enterprise: false,
invalidValue: '',
group: 'Federation',
section: 'Matrix Bridge',
});
await settingsRegistry.add('Federation_Matrix_check_configuration_button', 'checkFederationConfiguration', {
readonly: true,
hidden: true,
type: 'action',
actionText: 'Federation_Matrix_check_configuration',
public: false,
enterprise: false,
invalidValue: '',
group: 'Federation',
section: 'Matrix Bridge',
});
};

View File

@@ -0,0 +1,69 @@
import type { IMatrixFederationStatistics } from '@rocket.chat/core-typings';
import { Rooms, Users } from '@rocket.chat/models';
import { settings } from '../../../../../settings';
class RocketChatStatisticsAdapter {
async getBiggestRoomAvailable(): Promise<{
_id: string;
name: string;
usersCount: number;
} | null> {
const room = await Rooms.findBiggestFederatedRoomInNumberOfUsers({ projection: { usersCount: 1, fname: 1, name: 1 } });
if (!room) {
return null;
}
return {
_id: room._id,
name: room.fname || room.name || '',
usersCount: room.usersCount,
};
}
async getSmallestRoomAvailable(): Promise<{
_id: string;
name: string;
usersCount: number;
} | null> {
const room = await Rooms.findSmallestFederatedRoomInNumberOfUsers({ projection: { usersCount: 1, fname: 1, name: 1 } });
if (!room) {
return null;
}
return {
_id: room._id,
name: room.fname || room.name || '',
usersCount: room.usersCount,
};
}
async getAmountOfExternalUsers(): Promise<number> {
return Users.countFederatedExternalUsers();
}
async getAmountOfExternalRooms(): Promise<number> {
return Rooms.countFederatedRooms();
}
async getAmountOfConnectedExternalServers(): Promise<{ quantity: number; servers: string[] }> {
const externalServers = await Rooms.countDistinctFederationRoomsExcluding(settings.get('Federation_Matrix_homeserver_domain'));
return {
quantity: externalServers.length,
servers: externalServers,
};
}
}
export const getMatrixFederationStatistics = async (): Promise<IMatrixFederationStatistics> => {
const statisticsService = new RocketChatStatisticsAdapter();
return {
enabled: settings.get('Federation_Matrix_enabled'),
maximumSizeOfPublicRoomsUsers: settings.get('Federation_Matrix_max_size_of_public_rooms_users'),
biggestRoom: await statisticsService.getBiggestRoomAvailable(),
smallestRoom: await statisticsService.getSmallestRoomAvailable(),
amountOfExternalUsers: await statisticsService.getAmountOfExternalUsers(),
amountOfFederatedRooms: await statisticsService.getAmountOfExternalRooms(),
externalConnectedServers: await statisticsService.getAmountOfConnectedExternalServers(),
};
};

View File

@@ -0,0 +1,22 @@
import { settings } from '../../settings';
export function isFederationEnabled(): boolean {
return settings.get<boolean>('Federation_Service_Enabled');
}
export function throwIfFederationNotEnabled(): void {
if (!isFederationEnabled()) {
throw new Error('Federation is not enabled');
}
}
export class FederationMatrixInvalidConfigurationError extends Error {
constructor(cause?: string) {
// eslint-disable-next-line prefer-template
const message = 'Federation configuration is invalid' + (cause ? ',' + cause[0].toLowerCase() + cause.slice(1) : '');
super(message);
this.name = 'FederationMatrixInvalidConfiguration';
}
}