Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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 @@ -15,21 +15,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 @@ -104,9 +100,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.

67 changes: 0 additions & 67 deletions apps/meteor/server/lib/pushConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Meteor } from 'meteor/meteor';

import { i18n } from './i18n';
import { hasPermissionAsync } from '../../app/authorization/server/functions/hasPermission';
import { getWorkspaceAccessToken } from '../../app/cloud/server';
import { RateLimiter } from '../../app/lib/server/lib';
import { Push } from '../../app/push/server';
import { settings } from '../../app/settings/server';
Expand Down Expand Up @@ -70,69 +69,3 @@ Meteor.methods<ServerMethods>({
RateLimiter.limitMethod('push_test', 1, 1000, {
userId: () => true,
});

settings.watch<boolean>('Push_enable', async (enabled) => {
if (!enabled) {
return;
}
const gateways =
settings.get('Push_enable_gateway') && settings.get('Register_Server') && settings.get('Cloud_Service_Agree_PrivacyTerms')
? settings.get<string>('Push_gateway').split('\n')
: undefined;

let apn:
| {
passphrase: string;
key: string;
cert: string;
gateway?: string;
}
| undefined;
let gcm:
| {
apiKey: string;
projectNumber: string;
}
| undefined;

if (!gateways) {
gcm = {
apiKey: settings.get('Push_gcm_api_key'),
projectNumber: settings.get('Push_gcm_project_number'),
};

apn = {
passphrase: settings.get('Push_apn_passphrase'),
key: settings.get('Push_apn_key'),
cert: settings.get('Push_apn_cert'),
};

if (settings.get('Push_production') !== true) {
apn = {
passphrase: settings.get('Push_apn_dev_passphrase'),
key: settings.get('Push_apn_dev_key'),
cert: settings.get('Push_apn_dev_cert'),
gateway: 'gateway.sandbox.push.apple.com',
};
}

if (!apn.key || apn.key.trim() === '' || !apn.cert || apn.cert.trim() === '') {
apn = undefined;
}

if (!gcm.apiKey || gcm.apiKey.trim() === '' || !gcm.projectNumber || gcm.projectNumber.trim() === '') {
gcm = undefined;
}
}

Push.configure({
apn,
gcm,
production: settings.get('Push_production'),
gateways,
uniqueId: settings.get('uniqueID'),
async getAuthorization() {
return `Bearer ${await getWorkspaceAccessToken()}`;
},
});
});
24 changes: 23 additions & 1 deletion apps/meteor/server/main.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
import './tracing';
import './models/startup';

/**
* ./settings uses top level await, in theory the settings creation
* and the startup should be done in parallel
*/
import './settings';
import '../app/settings/server';

import { configureLoginServices } from './configuration';
import { configureLogLevel } from './configureLogLevel';
import { registerServices } from './services/startup';
import { startup } from './startup';
import { configureBoilerplate } from './startup/configureBoilerplate';
Comment thread
pierre-lehnen-rc marked this conversation as resolved.
Outdated
import { configureCDN } from './startup/configureCDN';
import { configureCORS } from './startup/configureCORS';
import { configureDirectReply } from './startup/configureDirectReply';
import { configureIRC } from './startup/configureIRC';
import { configureFederation } from './startup/settings';
import { startLicense } from '../ee/app/license/server/startup';
import { registerEEBroker } from '../ee/server';
import { configureAssets } from './startup/configureAssets';
import { configureSMTP } from './startup/configureSMTP';
import { configurePushNotifications } from './startup/pushNotification';
import { settings } from '../app/settings/server';
import { startFederationService } from '../ee/server/startup/services';

import './routes';
Expand All @@ -30,3 +40,15 @@ await Promise.all([configureLogLevel(), registerServices(), registerEEBroker(),
await startLicense();

await Promise.all([configureLoginServices(), startFederationService()]);

await Promise.all([
configureAssets(settings),
configureCORS(settings),
configureCDN(settings),
configurePushNotifications(settings),
configureBoilerplate(settings),
configureDirectReply(settings),
configureSMTP(settings),
configureFederation(settings),
configureIRC(settings),
]);
6 changes: 6 additions & 0 deletions apps/meteor/server/startup/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));
}
Loading