Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
2 changes: 0 additions & 2 deletions apps/meteor/app/assets/server/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,6 @@ void (async () => {
}
})();

settings.watchByRegex(/^Assets_/, (key, value) => RocketChatAssets.processAsset(key, value));

Meteor.startup(() => {
setTimeout(() => {
process.emit('message', {
Expand Down
18 changes: 7 additions & 11 deletions apps/meteor/app/cors/server/cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,17 @@ type NextFunction = (err?: any) => void;

const logger = new Logger('CORS');

let templatePromise: Promise<void> | void;

declare module 'meteor/webapp' {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace WebApp {
function setInlineScriptsAllowed(allowed: boolean): Promise<void>;
}
}

settings.watch<boolean>(
'Enable_CSP',
Meteor.bindEnvironment(async (enabled) => {
templatePromise = WebAppInternals.setInlineScriptsAllowed(!enabled);
}),
);
let templatePromise: Promise<void> | void;
export async function setInlineScriptsAllowed(allowed: boolean): Promise<void> {
templatePromise = WebAppInternals.setInlineScriptsAllowed(allowed);
}

WebApp.rawConnectHandlers.use(async (_req: http.IncomingMessage, res: http.ServerResponse, next: NextFunction) => {
if (templatePromise) {
Expand Down Expand Up @@ -109,9 +105,9 @@ declare module 'meteor/webapp' {
}

let cachingVersion = '';
settings.watch<string>('Troubleshoot_Force_Caching_Version', (value) => {
cachingVersion = String(value).trim();
});
export function setCachingVersion(value: string): void {
cachingVersion = value.trim();
}

// @ts-expect-error - accessing internal property of webapp
WebAppInternals.staticFilesMiddleware = function (
Expand Down
1 change: 0 additions & 1 deletion apps/meteor/app/federation/server/startup/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
import './generateKeys';
import './settings';
import './registerCallbacks';
49 changes: 0 additions & 49 deletions apps/meteor/app/federation/server/startup/settings.ts

This file was deleted.

1 change: 0 additions & 1 deletion apps/meteor/app/irc/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
import './irc';
import './methods/resetIrcConnection';
1 change: 0 additions & 1 deletion apps/meteor/app/lib/server/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import './notifyUsersOnMessage';
import './meteorFixes';

export { sendNotification } from './sendNotificationsOnMessage';
export { hostname } from '../startup/settingsOnLoadSiteUrl';
export { passwordPolicy } from './passwordPolicy';
export { validateEmailDomain } from './validateEmailDomain';
export { RateLimiterClass as RateLimiter } from './RateLimiter';
Expand Down
3 changes: 0 additions & 3 deletions apps/meteor/app/lib/server/startup/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
import './rateLimiter';
import './robots';
import './settingsOnLoadCdnPrefix';
import './settingsOnLoadDirectReply';
import './settingsOnLoadSMTP';
35 changes: 0 additions & 35 deletions apps/meteor/app/lib/server/startup/settingsOnLoadCdnPrefix.js

This file was deleted.

43 changes: 0 additions & 43 deletions apps/meteor/app/lib/server/startup/settingsOnLoadDirectReply.ts

This file was deleted.

29 changes: 0 additions & 29 deletions apps/meteor/app/lib/server/startup/settingsOnLoadSMTP.ts

This file was deleted.

35 changes: 0 additions & 35 deletions apps/meteor/app/lib/server/startup/settingsOnLoadSiteUrl.ts

This file was deleted.

4 changes: 2 additions & 2 deletions apps/meteor/server/configuration/cas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import debounce from 'lodash.debounce';
import { RoutePolicy } from 'meteor/routepolicy';
import { WebApp } from 'meteor/webapp';

import { settings } from '../../app/settings/server/cached';
import type { ICachedSettings } from '../../app/settings/server/CachedSettings';
import { loginHandlerCAS } from '../lib/cas/loginHandler';
import { middlewareCAS } from '../lib/cas/middleware';
import { updateCasServices } from '../lib/cas/updateCasService';

export async function configureCAS() {
export async function configureCAS(settings: ICachedSettings) {
const _updateCasServices = debounce(updateCasServices, 2000);

settings.watchByRegex(/^CAS_.+/, async () => {
Expand Down
6 changes: 6 additions & 0 deletions apps/meteor/server/configuration/configureAssets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { RocketChatAssets } from '../../app/assets/server';
import type { ICachedSettings } from '../../app/settings/server/CachedSettings';

export async function configureAssets(settings: ICachedSettings): Promise<void> {
settings.watchByRegex(/^Assets_/, (key, value) => RocketChatAssets.processAsset(key, value));
}
35 changes: 35 additions & 0 deletions apps/meteor/server/configuration/configureBoilerplate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Meteor } from 'meteor/meteor';
import { WebAppInternals } from 'meteor/webapp';

import type { ICachedSettings } from '../../app/settings/server/CachedSettings';

export function configureBoilerplate(settings: ICachedSettings): void {
settings.watch<string>(
'Site_Url',
// Needed as WebAppInternals.generateBoilerplate needs to be called in a fiber
Meteor.bindEnvironment((value) => {
if (value == null || value.trim() === '') {
return;
}
let host = value.replace(/\/$/, '');
// let prefix = '';
const match = value.match(/([^\/]+\/{2}[^\/]+)(\/.+)/);
if (match != null) {
host = match[1];
// prefix = match[2].replace(/\/$/, '');
}
(global as any).__meteor_runtime_config__.ROOT_URL = value;

if (Meteor.absoluteUrl.defaultOptions?.rootUrl) {
Meteor.absoluteUrl.defaultOptions.rootUrl = value;
}

// hostname = host.replace(/^https?:\/\//, '');
process.env.MOBILE_ROOT_URL = host;
process.env.MOBILE_DDP_URL = host;
if (typeof WebAppInternals !== 'undefined' && WebAppInternals.generateBoilerplate) {
return WebAppInternals.generateBoilerplate();
}
}),
);
}
32 changes: 32 additions & 0 deletions apps/meteor/server/configuration/configureCDN.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { WebAppInternals } from 'meteor/webapp';

import type { ICachedSettings } from '../../app/settings/server/CachedSettings';

export async function configureCDN(settings: ICachedSettings): Promise<void> {
settings.change<string>('CDN_PREFIX', (value) => {
const useForAll = settings.get('CDN_PREFIX_ALL');
if (value && useForAll) {
WebAppInternals.setBundledJsCssPrefix(value);
}
});

settings.change<string>('CDN_JSCSS_PREFIX', (value) => {
const useForAll = settings.get('CDN_PREFIX_ALL');
if (value && typeof value === 'string' && value.trim() && !useForAll) {
WebAppInternals.setBundledJsCssPrefix(value);
}
});

const cdnValue = settings.get('CDN_PREFIX');
const useForAll = settings.get('CDN_PREFIX_ALL');
const cdnJsCss = settings.get('CDN_JSCSS_PREFIX');
if (cdnValue && typeof cdnValue === 'string' && cdnValue.trim()) {
if (useForAll) {
WebAppInternals.setBundledJsCssPrefix(cdnValue);
return;
}
if (cdnJsCss && typeof cdnJsCss === 'string' && cdnJsCss.trim()) {
WebAppInternals.setBundledJsCssPrefix(cdnJsCss);
}
}
}
11 changes: 11 additions & 0 deletions apps/meteor/server/configuration/configureCORS.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { setCachingVersion, setInlineScriptsAllowed } from '../../app/cors/server/cors';
import type { ICachedSettings } from '../../app/settings/server/CachedSettings';

export async function configureCORS(settings: ICachedSettings): Promise<void> {
settings.watch<boolean>('Enable_CSP', async (enabled) => {
await setInlineScriptsAllowed(!enabled);
});
settings.watch<string>('Troubleshoot_Force_Caching_Version', (value) => {
setCachingVersion(value);
});
}
Loading
Loading