Chore: Startup Time (#23210)

Co-authored-by: Diego Sampaio <chinello@gmail.com>
pull/23505/head
Guilherme Gazzo 4 years ago committed by GitHub
parent c5fbcfc902
commit ba15ba725a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/2fa/server/lib/totp.js
  2. 4
      app/2fa/server/startup/settings.ts
  3. 4
      app/analytics/server/settings.ts
  4. 10
      app/api/server/api.js
  5. 2
      app/api/server/helpers/getPaginationItems.js
  6. 6
      app/api/server/helpers/getUserInfo.js
  7. 4
      app/api/server/settings.ts
  8. 2
      app/api/server/v1/autotranslate.js
  9. 2
      app/api/server/v1/chat.js
  10. 2
      app/api/server/v1/ldap.ts
  11. 5
      app/api/server/v1/settings.js
  12. 2
      app/api/server/v1/users.js
  13. 2
      app/apple/server/index.js
  14. 17
      app/apple/server/startup.ts
  15. 4
      app/apps/client/orchestrator.js
  16. 2
      app/apps/server/communication/rest.js
  17. 4
      app/apps/server/communication/uikit.js
  18. 23
      app/apps/server/orchestrator.js
  19. 28
      app/assets/server/assets.js
  20. 13
      app/authentication/server/startup/index.js
  21. 4
      app/authentication/server/startup/settings.ts
  22. 32
      app/authorization/server/functions/upsertPermissions.js
  23. 1
      app/authorization/server/index.js
  24. 20
      app/autolinker/server/settings.js
  25. 20
      app/autolinker/server/settings.ts
  26. 33
      app/autotranslate/server/autotranslate.js
  27. 2
      app/autotranslate/server/deeplTranslate.js
  28. 4
      app/autotranslate/server/googleTranslate.js
  29. 4
      app/autotranslate/server/msTranslate.js
  30. 12
      app/autotranslate/server/settings.ts
  31. 2
      app/blockstack/server/loginHandler.js
  32. 2
      app/blockstack/server/routes.js
  33. 19
      app/blockstack/server/settings.js
  34. 4
      app/bot-helpers/server/index.js
  35. 4
      app/bot-helpers/server/settings.ts
  36. 6
      app/cas/server/cas_rocketchat.js
  37. 1
      app/channel-settings/server/index.js
  38. 9
      app/channel-settings/server/startup.js
  39. 4
      app/cloud/server/functions/startRegisterWorkspace.js
  40. 7
      app/cloud/server/index.js
  41. 9
      app/colors/server/settings.js
  42. 9
      app/colors/server/settings.ts
  43. 12
      app/cors/client/index.js
  44. 9
      app/cors/lib/common.js
  45. 5
      app/cors/server/cors.js
  46. 10
      app/cors/server/index.js
  47. 46
      app/crowd/server/crowd.js
  48. 4
      app/crowd/server/settings.ts
  49. 1
      app/custom-sounds/server/index.js
  50. 9
      app/custom-sounds/server/startup/permissions.js
  51. 4
      app/custom-sounds/server/startup/settings.ts
  52. 41
      app/discussion/server/config.js
  53. 37
      app/discussion/server/config.ts
  54. 10
      app/dolphin/server/startup.js
  55. 10
      app/dolphin/server/startup.ts
  56. 6
      app/drupal/server/startup.ts
  57. 4
      app/e2e/server/settings.ts
  58. 4
      app/emoji-custom/server/startup/settings.ts
  59. 4
      app/error-handler/server/lib/RocketChat.ErrorHandler.js
  60. 5
      app/error-handler/server/startup/settings.js
  61. 5
      app/error-handler/server/startup/settings.ts
  62. 21
      app/federation/server/startup/settings.ts
  63. 2
      app/file-upload/server/config/AmazonS3.js
  64. 9
      app/file-upload/server/config/FileSystem.js
  65. 2
      app/file-upload/server/config/GoogleStorage.js
  66. 2
      app/file-upload/server/config/Webdav.js
  67. 2
      app/file-upload/server/config/_configUploadStorage.js
  68. 2
      app/file-upload/server/lib/FileUpload.js
  69. 4
      app/file-upload/server/methods/getS3FileUrl.js
  70. 4
      app/file-upload/server/startup/settings.ts
  71. 6
      app/github-enterprise/server/startup.ts
  72. 6
      app/gitlab/server/startup.ts
  73. 4
      app/iframe-login/server/iframe_rocketchat.ts
  74. 42
      app/importer-hipchat-enterprise/server/importer.js
  75. 4
      app/irc/server/irc-settings.ts
  76. 6
      app/issuelinks/server/settings.ts
  77. 10
      app/katex/server/settings.ts
  78. 6
      app/lib/README.md
  79. 2
      app/lib/client/index.js
  80. 18
      app/lib/client/startup/settingsOnLoadSiteUrl.ts
  81. 63
      app/lib/server/functions/addOAuthService.js
  82. 63
      app/lib/server/functions/addOAuthService.ts
  83. 4
      app/lib/server/functions/checkUsernameAvailability.js
  84. 4
      app/lib/server/functions/getFullUserData.js
  85. 4
      app/lib/server/functions/notifications/email.js
  86. 2
      app/lib/server/lib/bugsnag.ts
  87. 8
      app/lib/server/lib/debug.js
  88. 2
      app/lib/server/lib/getHiddenSystemMessages.ts
  89. 2
      app/lib/server/lib/index.js
  90. 20
      app/lib/server/lib/passwordPolicy.js
  91. 4
      app/lib/server/lib/sendNotificationsOnMessage.js
  92. 16
      app/lib/server/lib/validateEmailDomain.js
  93. 2
      app/lib/server/methods/filterBadWords.ts
  94. 58
      app/lib/server/methods/removeOAuthService.js
  95. 3
      app/lib/server/methods/saveSetting.js
  96. 3
      app/lib/server/methods/saveSettings.js
  97. 4
      app/lib/server/startup/email.ts
  98. 80
      app/lib/server/startup/oAuthServicesUpdate.js
  99. 12
      app/lib/server/startup/rateLimiter.js
  100. 45
      app/lib/server/startup/settings.ts
  101. Some files were not shown because too many files have changed in this diff Show More

@ -3,7 +3,7 @@ import { Random } from 'meteor/random';
import speakeasy from 'speakeasy';
import { Users } from '../../../models';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
export const TOTP = {
generateSecret() {

@ -1,6 +1,6 @@
import { settings } from '../../../settings';
import { settingsRegistry } from '../../../settings/server';
settings.addGroup('Accounts', function() {
settingsRegistry.addGroup('Accounts', function() {
this.section('Two Factor Authentication', function() {
const enable2FA = {
_id: 'Accounts_TwoFactorAuthentication_Enabled',

@ -1,6 +1,6 @@
import { settings } from '../../settings';
import { settingsRegistry } from '../../settings/server';
settings.addGroup('Analytics', function addSettings() {
settingsRegistry.addGroup('Analytics', function addSettings() {
this.section('Piwik', function() {
const enableQuery = { _id: 'PiwikAnalytics_enabled', value: true };
this.add('PiwikAnalytics_enabled', false, {

@ -744,11 +744,11 @@ const createApis = function _createApis() {
createApis();
// register the API to be re-created once the CORS-setting changes.
settings.get(/^(API_Enable_CORS|API_CORS_Origin)$/, () => {
settings.watchMultiple(['API_Enable_CORS', 'API_CORS_Origin'], () => {
createApis();
});
settings.get('Accounts_CustomFields', (key, value) => {
settings.watch('Accounts_CustomFields', (value) => {
if (!value) {
return API.v1.setLimitedCustomFields([]);
}
@ -761,16 +761,16 @@ settings.get('Accounts_CustomFields', (key, value) => {
}
});
settings.get('API_Enable_Rate_Limiter_Limit_Time_Default', (key, value) => {
settings.watch('API_Enable_Rate_Limiter_Limit_Time_Default', (value) => {
defaultRateLimiterOptions.intervalTimeInMS = value;
API.v1.reloadRoutesToRefreshRateLimiter();
});
settings.get('API_Enable_Rate_Limiter_Limit_Calls_Default', (key, value) => {
settings.watch('API_Enable_Rate_Limiter_Limit_Calls_Default', (value) => {
defaultRateLimiterOptions.numRequestsAllowed = value;
API.v1.reloadRoutesToRefreshRateLimiter();
});
settings.get('Prometheus_API_User_Agent', (key, value) => {
settings.watch('Prometheus_API_User_Agent', (value) => {
prometheusAPIUserAgent = value;
});

@ -1,7 +1,7 @@
// If the count query param is higher than the "API_Upper_Count_Limit" setting, then we limit that
// If the count query param isn't defined, then we set it to the "API_Default_Count" setting
// If the count is zero, then that means unlimited and is only allowed if the setting "API_Allow_Infinite_Count" is true
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
import { API } from '../api';
API.helperMethods.set('getPaginationItems', function _getPaginationItems() {

@ -11,10 +11,10 @@ API.helperMethods.set('getUserInfo', function _getUserInfo(me) {
};
const getUserPreferences = () => {
const defaultUserSettingPrefix = 'Accounts_Default_User_Preferences_';
const allDefaultUserSettings = settings.get(new RegExp(`^${ defaultUserSettingPrefix }.*$`));
const allDefaultUserSettings = settings.getByRegexp(new RegExp(`^${ defaultUserSettingPrefix }.*$`));
return allDefaultUserSettings.reduce((accumulator, setting) => {
const settingWithoutPrefix = setting.key.replace(defaultUserSettingPrefix, ' ').trim();
return allDefaultUserSettings.reduce((accumulator, [key]) => {
const settingWithoutPrefix = key.replace(defaultUserSettingPrefix, ' ').trim();
accumulator[settingWithoutPrefix] = getUserPreference(me, settingWithoutPrefix);
return accumulator;
}, {});

@ -1,6 +1,6 @@
import { settings } from '../../settings';
import { settingsRegistry } from '../../settings/server';
settings.addGroup('General', function() {
settingsRegistry.addGroup('General', function() {
this.section('REST API', function() {
this.add('API_Upper_Count_Limit', 100, { type: 'int', public: false });
this.add('API_Default_Count', 50, { type: 'int', public: false });

@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { API } from '../api';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
import { Messages } from '../../../models/server';
API.v1.addRoute('autotranslate.getSupportedLanguages', { authRequired: true }, {

@ -12,7 +12,7 @@ import { API } from '../api';
import Rooms from '../../../models/server/models/Rooms';
import Users from '../../../models/server/models/Users';
import Subscriptions from '../../../models/server/models/Subscriptions';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
import { findMentionedMessages, findStarredMessages, findSnippetedMessageById, findSnippetedMessages, findDiscussionsFromRoom } from '../lib/messages';
API.v1.addRoute('chat.delete', { authRequired: true }, {

@ -16,7 +16,7 @@ API.v1.addRoute('ldap.testConnection', { authRequired: true }, {
throw new Error('error-not-authorized');
}
if (settings.get('LDAP_Enable') !== true) {
if (settings.get<boolean>('LDAP_Enable') !== true) {
throw new Error('LDAP_disabled');
}

@ -147,10 +147,7 @@ API.v1.addRoute('settings/:_id', { authRequired: true }, {
value: Match.Any,
});
if (Settings.updateValueNotHiddenById(this.urlParams._id, this.bodyParams.value)) {
settings.storeSettingValue({
_id: this.urlParams._id,
value: this.bodyParams.value,
});
settings.set(Settings.findOneNotHiddenById(this.urlParams._id));
setValue(this.urlParams._id, this.bodyParams.value);
return API.v1.success();
}

@ -6,7 +6,7 @@ import _ from 'underscore';
import { Users, Subscriptions } from '../../../models/server';
import { Users as UsersRaw } from '../../../models/server/raw';
import { hasPermission } from '../../../authorization';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
import { getURL } from '../../../utils';
import {
validateCustomFields,

@ -1,2 +1,2 @@
import './startup.js';
import './startup';
import './loginHandler.js';

@ -1,17 +1,16 @@
import _ from 'underscore';
import { Meteor } from 'meteor/meteor';
import { ServiceConfiguration } from 'meteor/service-configuration';
import { settings } from '../../settings';
import { settings, settingsRegistry } from '../../settings/server';
settings.addGroup('OAuth', function() {
settingsRegistry.addGroup('OAuth', function() {
this.section('Apple', function() {
this.add('Accounts_OAuth_Apple', false, { type: 'boolean', public: true });
});
});
const configureService = _.debounce(Meteor.bindEnvironment(() => {
if (!settings.get('Accounts_OAuth_Apple')) {
settings.watch('Accounts_OAuth_Apple', (enabled) => {
if (!enabled) {
return ServiceConfiguration.configurations.remove({
service: 'apple',
});
@ -26,10 +25,4 @@ const configureService = _.debounce(Meteor.bindEnvironment(() => {
enabled: settings.get('Accounts_OAuth_Apple'),
},
});
}), 1000);
Meteor.startup(() => {
settings.get('Accounts_OAuth_Apple', () => {
configureService();
});
});

@ -1,5 +1,6 @@
import { AppClientManager } from '@rocket.chat/apps-engine/client/AppClientManager';
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { dispatchToastMessage } from '../../../client/lib/toast';
import { hasAtLeastOnePermission } from '../../authorization';
@ -192,7 +193,8 @@ Meteor.startup(() => {
});
});
settings.get('Apps_Framework_enabled', (isEnabled) => {
Tracker.autorun(() => {
const isEnabled = settings.get('Apps_Framework_enabled');
Apps.load(isEnabled);
});
});

@ -4,7 +4,7 @@ import { HTTP } from 'meteor/http';
import { API } from '../../../api/server';
import { getUploadFormData } from '../../../api/server/lib/getUploadFormData';
import { getWorkspaceAccessToken, getUserCloudAccessToken } from '../../../cloud/server';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
import { Info } from '../../../utils';
import { Settings, Users } from '../../../models/server';
import { Apps } from '../orchestrator';

@ -18,9 +18,9 @@ apiServer.disable('x-powered-by');
let corsEnabled = false;
let allowListOrigins = [];
settings.get('API_Enable_CORS', (_, value) => { corsEnabled = value; });
settings.watch('API_Enable_CORS', (value) => { corsEnabled = value; });
settings.get('API_CORS_Origin', (_, value) => {
settings.watch('API_CORS_Origin', (value) => {
allowListOrigins = value ? value.trim().split(',').map((origin) => String(origin).trim().toLocaleLowerCase()) : [];
});

@ -3,9 +3,9 @@ import { AppInterface } from '@rocket.chat/apps-engine/definition/metadata';
import { AppManager } from '@rocket.chat/apps-engine/server/AppManager';
import { Meteor } from 'meteor/meteor';
import { Logger } from '../../logger';
import { AppsLogsModel, AppsModel, AppsPersistenceModel, Permissions } from '../../models';
import { settings } from '../../settings';
import { Logger } from '../../../server/lib/logger/Logger';
import { AppsLogsModel, AppsModel, AppsPersistenceModel } from '../../models/server';
import { settings, settingsRegistry } from '../../settings/server';
import { RealAppBridges } from './bridges';
import { AppMethods, AppServerNotifier, AppsRestApi, AppUIKitInteractionApi } from './communication';
import { AppMessagesConverter, AppRoomsConverter, AppSettingsConverter, AppUsersConverter } from './converters';
@ -32,7 +32,6 @@ export class AppServerOrchestrator {
}
this._rocketchatLogger = new Logger('Rocket.Chat Apps');
Permissions.create('manage-apps', ['admin']);
if (typeof process.env.OVERWRITE_INTERNAL_MARKETPLACE_URL === 'string' && process.env.OVERWRITE_INTERNAL_MARKETPLACE_URL !== '') {
this._marketplaceUrl = process.env.OVERWRITE_INTERNAL_MARKETPLACE_URL;
@ -78,6 +77,9 @@ export class AppServerOrchestrator {
return this._model;
}
/**
* @returns {AppsPersistenceModel}
*/
getPersistenceModel() {
return this._persistModel;
}
@ -130,6 +132,9 @@ export class AppServerOrchestrator {
return settings.get('Apps_Framework_Development_Mode') && !isTesting();
}
/**
* @returns {Logger}
*/
getRocketChatLogger() {
return this._rocketchatLogger;
}
@ -195,7 +200,7 @@ export class AppServerOrchestrator {
export const AppEvents = AppInterface;
export const Apps = new AppServerOrchestrator();
settings.addGroup('General', function() {
settingsRegistry.addGroup('General', function() {
this.section('Apps', function() {
this.add('Apps_Logs_TTL', '30_days', {
type: 'select',
@ -259,7 +264,7 @@ settings.addGroup('General', function() {
});
});
settings.get('Apps_Framework_Source_Package_Storage_Type', (_, value) => {
settings.watch('Apps_Framework_Source_Package_Storage_Type', (value) => {
if (!Apps.isInitialized()) {
appsSourceStorageType = value;
} else {
@ -267,7 +272,7 @@ settings.get('Apps_Framework_Source_Package_Storage_Type', (_, value) => {
}
});
settings.get('Apps_Framework_Source_Package_Storage_FileSystem_Path', (_, value) => {
settings.watch('Apps_Framework_Source_Package_Storage_FileSystem_Path', (value) => {
if (!Apps.isInitialized()) {
appsSourceStorageFilesystemPath = value;
} else {
@ -275,7 +280,7 @@ settings.get('Apps_Framework_Source_Package_Storage_FileSystem_Path', (_, value)
}
});
settings.get('Apps_Framework_enabled', (key, isEnabled) => {
settings.watch('Apps_Framework_enabled', (isEnabled) => {
// In case this gets called before `Meteor.startup`
if (!Apps.isInitialized()) {
return;
@ -288,7 +293,7 @@ settings.get('Apps_Framework_enabled', (key, isEnabled) => {
}
});
settings.get('Apps_Logs_TTL', (key, value) => {
settings.watch('Apps_Logs_TTL', (value) => {
if (!Apps.isInitialized()) {
return;
}

@ -7,11 +7,12 @@ import _ from 'underscore';
import sizeOf from 'image-size';
import sharp from 'sharp';
import { settings } from '../../settings/server';
import { settings, settingsRegistry } from '../../settings/server';
import { getURL } from '../../utils/lib/getURL';
import { mime } from '../../utils/lib/mimeTypes';
import { hasPermission } from '../../authorization';
import { RocketChatFile } from '../../file';
import { Settings } from '../../models/server';
const RocketChatAssetsInstance = new RocketChatFile.GridFS({
@ -25,8 +26,6 @@ const assets = {
constraints: {
type: 'image',
extensions: ['svg', 'png', 'jpg', 'jpeg'],
width: undefined,
height: undefined,
},
wizard: {
step: 3,
@ -35,12 +34,9 @@ const assets = {
},
background: {
label: 'login background (svg, png, jpg)',
defaultUrl: undefined,
constraints: {
type: 'image',
extensions: ['svg', 'png', 'jpg', 'jpeg'],
width: undefined,
height: undefined,
},
},
favicon_ico: {
@ -49,8 +45,6 @@ const assets = {
constraints: {
type: 'image',
extensions: ['ico'],
width: undefined,
height: undefined,
},
},
favicon: {
@ -59,8 +53,6 @@ const assets = {
constraints: {
type: 'image',
extensions: ['svg'],
width: undefined,
height: undefined,
},
},
favicon_16: {
@ -179,8 +171,6 @@ const assets = {
constraints: {
type: 'image',
extensions: ['svg'],
width: undefined,
height: undefined,
},
},
};
@ -234,7 +224,7 @@ export const RocketChatAssets = new class {
defaultUrl: assets[asset].defaultUrl,
};
settings.updateById(key, value);
Settings.updateValueById(key, value);
return RocketChatAssets.processAsset(key, value);
}, 200);
}));
@ -255,7 +245,7 @@ export const RocketChatAssets = new class {
defaultUrl: assets[asset].defaultUrl,
};
settings.updateById(key, value);
Settings.updateValueById(key, value);
RocketChatAssets.processAsset(key, value);
}
@ -317,9 +307,9 @@ export const RocketChatAssets = new class {
}
}();
settings.addGroup('Assets');
settingsRegistry.addGroup('Assets');
settings.add('Assets_SvgFavicon_Enable', true, {
settingsRegistry.add('Assets_SvgFavicon_Enable', true, {
type: 'boolean',
group: 'Assets',
i18nLabel: 'Enable_Svg_Favicon',
@ -328,7 +318,7 @@ settings.add('Assets_SvgFavicon_Enable', true, {
function addAssetToSetting(asset, value) {
const key = `Assets_${ asset }`;
settings.add(key, {
settingsRegistry.add(key, {
defaultUrl: value.defaultUrl,
}, {
type: 'asset',
@ -344,7 +334,7 @@ function addAssetToSetting(asset, value) {
if (typeof currentValue === 'object' && currentValue.defaultUrl !== assets[asset].defaultUrl) {
currentValue.defaultUrl = assets[asset].defaultUrl;
settings.updateById(key, currentValue);
Settings.updateValueById(key, currentValue);
}
}
@ -353,7 +343,7 @@ for (const key of Object.keys(assets)) {
addAssetToSetting(key, value);
}
settings.get(/^Assets_/, (key, value) => RocketChatAssets.processAsset(key, value));
settings.watchByRegex(/^Assets_/, (key, value) => RocketChatAssets.processAsset(key, value));
Meteor.startup(function() {
return Meteor.setTimeout(function() {

@ -25,16 +25,15 @@ Accounts.config({
forbidClientAccountCreation: true,
});
const updateMailConfig = _.debounce(() => {
Accounts._options.loginExpirationInDays = settings.get('Accounts_LoginExpiration');
Accounts.emailTemplates.siteName = settings.get('Site_Name');
Meteor.startup(() => {
settings.watchMultiple(['Accounts_LoginExpiration', 'Site_Name', 'From_Email'], () => {
Accounts._options.loginExpirationInDays = settings.get('Accounts_LoginExpiration');
Accounts.emailTemplates.from = `${ settings.get('Site_Name') } <${ settings.get('From_Email') }>`;
}, 1000);
Accounts.emailTemplates.siteName = settings.get('Site_Name');
Meteor.startup(() => {
settings.get(/^(Accounts_LoginExpiration|Site_Name|From_Email)$/, updateMailConfig);
Accounts.emailTemplates.from = `${ settings.get('Site_Name') } <${ settings.get('From_Email') }>`;
});
});
Accounts.emailTemplates.userToActivate = {

@ -1,9 +1,9 @@
import { Meteor } from 'meteor/meteor';
import { settings } from '../../../settings/server';
import { settingsRegistry } from '../../../settings/server';
Meteor.startup(function() {
settings.addGroup('Accounts', function() {
settingsRegistry.addGroup('Accounts', function() {
const enableQueryCollectData = { _id: 'Block_Multiple_Failed_Logins_Enabled', value: true };
this.section('Login_Attempts', function() {

@ -1,11 +1,11 @@
/* eslint no-multi-spaces: 0 */
import { Meteor } from 'meteor/meteor';
import Roles from '../../../models/server/models/Roles';
import Permissions from '../../../models/server/models/Permissions';
import Settings from '../../../models/server/models/Settings';
import { settings } from '../../../settings/server';
import { getSettingPermissionId, CONSTANTS } from '../../lib';
import { Roles, Permissions, Settings } from '../../models/server';
import { settings } from '../../settings/server';
import { getSettingPermissionId, CONSTANTS } from '../lib';
Meteor.startup(function() {
export const upsertPermissions = () => {
// Note:
// 1.if we need to create a role that can only edit channel message, but not edit group message
// then we can define edit-<type>-message instead of edit-message
@ -140,8 +140,18 @@ Meteor.startup(function() {
{ _id: 'view-all-teams', roles: ['admin'] },
{ _id: 'remove-closed-livechat-room', roles: ['livechat-manager', 'admin'] },
{ _id: 'remove-livechat-department', roles: ['livechat-manager', 'admin'] },
{ _id: 'manage-apps', roles: ['admin'] },
{ _id: 'post-readonly', roles: ['admin', 'owner', 'moderator'] },
{ _id: 'set-readonly', roles: ['admin', 'owner'] },
{ _id: 'set-react-when-readonly', roles: ['admin', 'owner'] },
{ _id: 'manage-cloud', roles: ['admin'] },
{ _id: 'manage-sounds', roles: ['admin'] },
{ _id: 'access-mailer', roles: ['admin'] },
{ _id: 'pin-message', roles: ['owner', 'moderator', 'admin'] },
{ _id: 'snippet-message', roles: ['owner', 'moderator', 'admin'] },
];
for (const permission of permissions) {
Permissions.create(permission._id, permission.roles);
}
@ -172,7 +182,7 @@ Meteor.startup(function() {
selector.settingId = settingId;
}
Permissions.find(selector).fetch().forEach(
Permissions.find(selector).forEach(
function(permission) {
previousSettingPermissions[permission._id] = permission;
});
@ -240,7 +250,7 @@ Meteor.startup(function() {
createPermissionsForExistingSettings();
// register a callback for settings for be create in higher-level-packages
const createPermissionForAddedSetting = function(settingId) {
settings.on('*', function([settingId]) {
const previousSettingPermissions = getPreviousPermissions(settingId);
const setting = Settings.findOneById(settingId);
if (setting) {
@ -248,7 +258,5 @@ Meteor.startup(function() {
createSettingPermission(setting, previousSettingPermissions);
}
}
};
settings.onload('*', createPermissionForAddedSetting);
});
});
};

@ -21,7 +21,6 @@ import './methods/removeRoleFromPermission';
import './methods/removeUserFromRole';
import './methods/saveRole';
import './streamer/permissions';
import './startup';
export {
getRoles,

@ -1,20 +0,0 @@
import { Meteor } from 'meteor/meteor';
import { settings } from '../../settings';
Meteor.startup(function() {
const enableQuery = {
_id: 'AutoLinker',
value: true,
};
settings.add('AutoLinker', true, { type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, i18nLabel: 'Enabled' });
settings.add('AutoLinker_StripPrefix', false, { type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, i18nDescription: 'AutoLinker_StripPrefix_Description', enableQuery });
settings.add('AutoLinker_Urls_Scheme', true, { type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, enableQuery });
settings.add('AutoLinker_Urls_www', true, { type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, enableQuery });
settings.add('AutoLinker_Urls_TLD', true, { type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, enableQuery });
settings.add('AutoLinker_UrlsRegExp', '(://|www\\.).+', { type: 'string', group: 'Message', section: 'AutoLinker', public: true, enableQuery });
settings.add('AutoLinker_Email', true, { type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, enableQuery });
settings.add('AutoLinker_Phone', true, { type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, i18nDescription: 'AutoLinker_Phone_Description', enableQuery });
});

@ -0,0 +1,20 @@
import { Meteor } from 'meteor/meteor';
import { settingsRegistry } from '../../settings/server';
Meteor.startup(function() {
const enableQuery = {
_id: 'AutoLinker',
value: true,
};
settingsRegistry.add('AutoLinker', true, { type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, i18nLabel: 'Enabled' });
settingsRegistry.add('AutoLinker_StripPrefix', false, { type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, i18nDescription: 'AutoLinker_StripPrefix_Description', enableQuery });
settingsRegistry.add('AutoLinker_Urls_Scheme', true, { type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, enableQuery });
settingsRegistry.add('AutoLinker_Urls_www', true, { type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, enableQuery });
settingsRegistry.add('AutoLinker_Urls_TLD', true, { type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, enableQuery });
settingsRegistry.add('AutoLinker_UrlsRegExp', '(://|www\\.).+', { type: 'string', group: 'Message', section: 'AutoLinker', public: true, enableQuery });
settingsRegistry.add('AutoLinker_Email', true, { type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, enableQuery });
settingsRegistry.add('AutoLinker_Phone', true, { type: 'boolean', group: 'Message', section: 'AutoLinker', public: true, i18nDescription: 'AutoLinker_Phone_Description', enableQuery });
});

@ -2,7 +2,7 @@ import { Meteor } from 'meteor/meteor';
import _ from 'underscore';
import { escapeHTML } from '@rocket.chat/string-helpers';
import { settings } from '../../settings';
import { settings } from '../../settings/server';
import { callbacks } from '../../callbacks';
import { Subscriptions, Messages } from '../../models';
import { Markdown } from '../../markdown/server';
@ -80,24 +80,6 @@ export class TranslationProviderRegistry {
callbacks.add('afterSaveMessage', provider.translateMessage.bind(provider), callbacks.priority.MEDIUM, 'autotranslate');
}
/**
* Make the activated provider by setting as the active.
*/
static loadActiveServiceProvider() {
/** Register the active service provider on the 'AfterSaveMessage' callback.
* So the registered provider will be invoked when a message is saved.
* All the other inactive service provider must be deactivated.
*/
settings.get('AutoTranslate_ServiceProvider', (key, providerName) => {
TranslationProviderRegistry.setCurrentProvider(providerName);
});
// Get Auto Translate Active flag
settings.get('AutoTranslate_Enabled', (key, value) => {
TranslationProviderRegistry.setEnable(value);
});
}
}
/**
@ -352,5 +334,16 @@ export class AutoTranslate {
}
Meteor.startup(() => {
TranslationProviderRegistry.loadActiveServiceProvider();
/** Register the active service provider on the 'AfterSaveMessage' callback.
* So the registered provider will be invoked when a message is saved.
* All the other inactive service provider must be deactivated.
*/
settings.watch('AutoTranslate_ServiceProvider', (providerName) => {
TranslationProviderRegistry.setCurrentProvider(providerName);
});
// Get Auto Translate Active flag
settings.watch('AutoTranslate_Enabled', (value) => {
TranslationProviderRegistry.setEnable(value);
});
});

@ -28,7 +28,7 @@ class DeeplAutoTranslate extends AutoTranslate {
this.name = 'deepl-translate';
this.apiEndPointUrl = 'https://api.deepl.com/v2/translate';
// Get the service provide API key.
settings.get('AutoTranslate_DeepLAPIKey', (key, value) => {
settings.watch('AutoTranslate_DeepLAPIKey', (value) => {
this.apiKey = value;
});
}

@ -8,7 +8,7 @@ import _ from 'underscore';
import { AutoTranslate, TranslationProviderRegistry } from './autotranslate';
import { SystemLogger } from '../../../server/lib/logger/system';
import { settings } from '../../settings';
import { settings } from '../../settings/server';
/**
* Represents google translate class
@ -26,7 +26,7 @@ class GoogleAutoTranslate extends AutoTranslate {
this.name = 'google-translate';
this.apiEndPointUrl = 'https://translation.googleapis.com/language/translate/v2';
// Get the service provide API key.
settings.get('AutoTranslate_GoogleAPIKey', (key, value) => {
settings.watch('AutoTranslate_GoogleAPIKey', (value) => {
this.apiKey = value;
});
}

@ -8,7 +8,7 @@ import _ from 'underscore';
import { TranslationProviderRegistry, AutoTranslate } from './autotranslate';
import { msLogger } from './logger';
import { settings } from '../../settings';
import { settings } from '../../settings/server';
/**
* Microsoft translation service provider class representation.
@ -31,7 +31,7 @@ class MsAutoTranslate extends AutoTranslate {
this.apiGetLanguages = 'https://api.cognitive.microsofttranslator.com/languages?api-version=3.0';
this.breakSentence = 'https://api.cognitive.microsofttranslator.com/breaksentence?api-version=3.0';
// Get the service provide API key.
settings.get('AutoTranslate_MicrosoftAPIKey', (key, value) => {
settings.watch('AutoTranslate_MicrosoftAPIKey', (value) => {
this.apiKey = value;
});
}

@ -1,16 +1,16 @@
import { Meteor } from 'meteor/meteor';
import { settings } from '../../settings';
import { settingsRegistry } from '../../settings/server';
Meteor.startup(function() {
settings.add('AutoTranslate_Enabled', false, {
settingsRegistry.add('AutoTranslate_Enabled', false, {
type: 'boolean',
group: 'Message',
section: 'AutoTranslate',
public: true,
});
settings.add('AutoTranslate_ServiceProvider', 'google-translate', {
settingsRegistry.add('AutoTranslate_ServiceProvider', 'google-translate', {
type: 'select',
group: 'Message',
section: 'AutoTranslate',
@ -29,7 +29,7 @@ Meteor.startup(function() {
public: true,
});
settings.add('AutoTranslate_GoogleAPIKey', '', {
settingsRegistry.add('AutoTranslate_GoogleAPIKey', '', {
type: 'string',
group: 'Message',
section: 'AutoTranslate_Google',
@ -44,7 +44,7 @@ Meteor.startup(function() {
}],
});
settings.add('AutoTranslate_DeepLAPIKey', '', {
settingsRegistry.add('AutoTranslate_DeepLAPIKey', '', {
type: 'string',
group: 'Message',
section: 'AutoTranslate_DeepL',
@ -58,7 +58,7 @@ Meteor.startup(function() {
}],
});
settings.add('AutoTranslate_MicrosoftAPIKey', '', {
settingsRegistry.add('AutoTranslate_MicrosoftAPIKey', '', {
type: 'string',
group: 'Message',
section: 'AutoTranslate_Microsoft',

@ -4,7 +4,7 @@ import { Accounts } from 'meteor/accounts-base';
import { updateOrCreateUser } from './userHandler';
import { handleAccessToken } from './tokenHandler';
import { logger } from './logger';
import { settings } from '../../settings';
import { settings } from '../../settings/server';
import { Users } from '../../models';
import { setUserAvatar } from '../../lib';

@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { WebApp } from 'meteor/webapp';
import { settings } from '../../settings';
import { settings } from '../../settings/server';
import { RocketChatAssets } from '../../assets/server';
WebApp.connectHandlers.use('/_blockstack/manifest', Meteor.bindEnvironment(function(req, res) {

@ -1,9 +1,8 @@
import _ from 'underscore';
import { Meteor } from 'meteor/meteor';
import { ServiceConfiguration } from 'meteor/service-configuration';
import { logger } from './logger';
import { settings } from '../../settings';
import { settings, settingsRegistry } from '../../settings/server';
const defaults = {
enable: false,
@ -18,7 +17,7 @@ const defaults = {
};
Meteor.startup(() => {
settings.addGroup('Blockstack', function() {
settingsRegistry.addGroup('Blockstack', function() {
this.add('Blockstack_Enable', defaults.enable, {
type: 'boolean',
i18nLabel: 'Enable',
@ -43,7 +42,12 @@ const getSettings = () => Object.assign({}, defaults, {
generateUsername: settings.get('Blockstack_Generate_Username'),
});
const configureService = _.debounce(Meteor.bindEnvironment(() => {
// Add settings to auth provider configs on startup
settings.watchMultiple(['Blockstack_Enable',
'Blockstack_Auth_Description',
'Blockstack_ButtonLabelText',
'Blockstack_Generate_Username'], () => {
const serviceConfig = getSettings();
if (!serviceConfig.enable) {
@ -60,11 +64,4 @@ const configureService = _.debounce(Meteor.bindEnvironment(() => {
});
logger.debug('Init Blockstack auth', serviceConfig);
}), 1000);
// Add settings to auth provider configs on startup
Meteor.startup(() => {
settings.get(/^Blockstack_.+/, () => {
configureService();
});
});

@ -3,7 +3,7 @@ import { Meteor } from 'meteor/meteor';
import _ from 'underscore';
import { Users, Rooms } from '../../models';
import { settings } from '../../settings';
import { settings } from '../../settings/server';
import { hasRole } from '../../authorization';
/**
@ -151,7 +151,7 @@ class BotHelpers {
const botHelpers = new BotHelpers();
// init cursors with fields setting and update on setting change
settings.get('BotHelpers_userFields', function(settingKey, settingValue) {
settings.watch('BotHelpers_userFields', function(settingValue) {
botHelpers.setupCursors(settingValue);
});

@ -1,9 +1,9 @@
import { Meteor } from 'meteor/meteor';
import { settings } from '../../settings';
import { settingsRegistry } from '../../settings/server';
Meteor.startup(function() {
settings.addGroup('Bots', function() {
settingsRegistry.addGroup('Bots', function() {
this.add('BotHelpers_userFields', '_id, name, username, emails, language, utcOffset', {
type: 'string',
section: 'Helpers',

@ -2,12 +2,12 @@ import { Meteor } from 'meteor/meteor';
import { ServiceConfiguration } from 'meteor/service-configuration';
import { Logger } from '../../logger';
import { settings } from '../../settings';
import { settings, settingsRegistry } from '../../settings/server';
export const logger = new Logger('CAS');
Meteor.startup(function() {
settings.addGroup('CAS', function() {
settingsRegistry.addGroup('CAS', function() {
this.add('CAS_enabled', false, { type: 'boolean', group: 'CAS', public: true });
this.add('CAS_base_url', '', { type: 'string', group: 'CAS', public: true });
this.add('CAS_login_url', '', { type: 'string', group: 'CAS', public: true });
@ -67,6 +67,6 @@ function updateServices(/* record*/) {
}, 2000);
}
settings.get(/^CAS_.+/, (key, value) => {
settings.watchByRegex(/^CAS_.+/, (key, value) => {
updateServices(value);
});

@ -1,4 +1,3 @@
import './startup';
import './methods/saveRoomSettings';
export { saveRoomTopic } from './functions/saveRoomTopic';

@ -1,9 +0,0 @@
import { Meteor } from 'meteor/meteor';
import { Permissions } from '../../models';
Meteor.startup(function() {
Permissions.create('post-readonly', ['admin', 'owner', 'moderator']);
Permissions.create('set-readonly', ['admin', 'owner']);
Permissions.create('set-react-when-readonly', ['admin', 'owner']);
});

@ -2,7 +2,7 @@ import { HTTP } from 'meteor/http';
import { retrieveRegistrationStatus } from './retrieveRegistrationStatus';
import { syncWorkspace } from './syncWorkspace';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
import { Settings } from '../../../models';
import { buildWorkspaceRegistrationData } from './buildRegistrationData';
import { SystemLogger } from '../../../../server/lib/logger/system';
@ -16,7 +16,7 @@ export function startRegisterWorkspace(resend = false) {
return true;
}
settings.updateById('Register_Server', true);
Settings.updateValueById('Register_Server', true);
const regInfo = buildWorkspaceRegistrationData();

@ -8,19 +8,14 @@ import { getWorkspaceLicense } from './functions/getWorkspaceLicense';
import { getUserCloudAccessToken } from './functions/getUserCloudAccessToken';
import { getWorkspaceKey } from './functions/getWorkspaceKey';
import { syncWorkspace } from './functions/syncWorkspace';
import { Permissions } from '../../models';
import { settings } from '../../settings/server';
if (Permissions) {
Permissions.create('manage-cloud', ['admin']);
}
const licenseCronName = 'Cloud Workspace Sync';
Meteor.startup(function() {
// run token/license sync if registered
let TroubleshootDisableWorkspaceSync;
settings.get('Troubleshoot_Disable_Workspace_Sync', (key, value) => {
settings.watch('Troubleshoot_Disable_Workspace_Sync', (value) => {
if (TroubleshootDisableWorkspaceSync === value) { return; }
TroubleshootDisableWorkspaceSync = value;

@ -1,9 +0,0 @@
import { settings } from '../../settings';
settings.add('HexColorPreview_Enabled', true, {
type: 'boolean',
i18nLabel: 'Enabled',
group: 'Message',
section: 'Hex_Color_Preview',
public: true,
});

@ -0,0 +1,9 @@
import { settingsRegistry } from '../../settings/server';
settingsRegistry.add('HexColorPreview_Enabled', true, {
type: 'boolean',
i18nLabel: 'Enabled',
group: 'Message',
section: 'Hex_Color_Preview',
public: true,
});

@ -1 +1,11 @@
import '../lib/common';
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { settings } from '../../settings/client';
Meteor.startup(function() {
Tracker.autorun(function() {
Meteor.absoluteUrl.defaultOptions.secure = Boolean(settings.get('Force_SSL'));
});
});

@ -1,9 +0,0 @@
import { Meteor } from 'meteor/meteor';
import { settings } from '../../settings';
Meteor.startup(function() {
settings.onload('Force_SSL', function(key, value) {
Meteor.absoluteUrl.defaultOptions.secure = value;
});
});

@ -4,14 +4,13 @@ import { Meteor } from 'meteor/meteor';
import { WebApp, WebAppInternals } from 'meteor/webapp';
import _ from 'underscore';
import { settings } from '../../settings';
import { settings } from '../../settings/server';
import { Logger } from '../../logger';
const logger = new Logger('CORS');
settings.get('Enable_CSP', (_, enabled) => {
settings.watch('Enable_CSP', (enabled) => {
WebAppInternals.setInlineScriptsAllowed(!enabled);
});

@ -1,2 +1,10 @@
import './cors';
import '../lib/common';
import { Meteor } from 'meteor/meteor';
import { settings } from '../../settings/server';
Meteor.startup(function() {
settings.watch('Force_SSL', (value) => {
Meteor.absoluteUrl.defaultOptions.secure = Boolean(value);
});
});

@ -2,7 +2,6 @@ import { Meteor } from 'meteor/meteor';
import { SHA256 } from 'meteor/sha';
import { SyncedCron } from 'meteor/littledata:synced-cron';
import { Accounts } from 'meteor/accounts-base';
import _ from 'underscore';
import { Logger } from '../../logger';
import { _setRealName } from '../../lib';
@ -312,33 +311,26 @@ Accounts.registerLoginHandler('crowd', function(loginRequest) {
const jobName = 'CROWD_Sync';
const addCronJob = _.debounce(Meteor.bindEnvironment(function addCronJobDebounced() {
if (settings.get('CROWD_Sync_User_Data') !== true) {
logger.info('Disabling CROWD Background Sync');
if (SyncedCron.nextScheduledAtDate(jobName)) {
SyncedCron.remove(jobName);
}
return;
}
const crowd = new CROWD();
if (settings.get('CROWD_Sync_Interval')) {
logger.info('Enabling CROWD Background Sync');
SyncedCron.add({
name: jobName,
schedule: (parser) => parser.text(settings.get('CROWD_Sync_Interval')),
job() {
crowd.sync();
},
});
}
}), 500);
Meteor.startup(() => {
Meteor.defer(() => {
settings.get('CROWD_Sync_Interval', addCronJob);
settings.get('CROWD_Sync_User_Data', addCronJob);
settings.watchMultiple(['CROWD_Sync_User_Data', 'CROWD_Sync_Interval'], function addCronJobDebounced([data, interval]) {
if (data !== true) {
logger.info('Disabling CROWD Background Sync');
if (SyncedCron.nextScheduledAtDate(jobName)) {
SyncedCron.remove(jobName);
}
return;
}
const crowd = new CROWD();
if (interval) {
logger.info('Enabling CROWD Background Sync');
SyncedCron.add({
name: jobName,
schedule: (parser) => parser.text(interval),
job() {
crowd.sync();
},
});
}
});
});

@ -1,9 +1,9 @@
import { Meteor } from 'meteor/meteor';
import { settings } from '../../settings';
import { settingsRegistry } from '../../settings/server';
Meteor.startup(function() {
settings.addGroup('AtlassianCrowd', function() {
settingsRegistry.addGroup('AtlassianCrowd', function() {
const enableQuery = { _id: 'CROWD_Enable', value: true };
const enableSyncQuery = [enableQuery, { _id: 'CROWD_Sync_User_Data', value: true }];

@ -1,5 +1,4 @@
import './startup/custom-sounds';
import './startup/permissions';
import './startup/settings';
import './methods/deleteCustomSound';
import './methods/insertOrUpdateSound';

@ -1,9 +0,0 @@
import { Meteor } from 'meteor/meteor';
import { Permissions } from '../../../models';
Meteor.startup(() => {
if (Permissions) {
Permissions.create('manage-sounds', ['admin']);
}
});

@ -1,6 +1,6 @@
import { settings } from '../../../settings';
import { settingsRegistry } from '../../../settings/server';
settings.addGroup('CustomSoundsFilesystem', function() {
settingsRegistry.addGroup('CustomSoundsFilesystem', function() {
this.add('CustomSounds_Storage_Type', 'GridFS', {
type: 'select',
values: [{

@ -1,41 +0,0 @@
import { Meteor } from 'meteor/meteor';
import { settings } from '../../settings';
Meteor.startup(() => {
settings.addGroup('Discussion', function() {
// the channel for which discussions are created if none is explicitly chosen
this.add('Discussion_enabled', true, {
group: 'Discussion',
i18nLabel: 'Enable',
type: 'boolean',
public: true,
});
});
const globalQuery = {
_id: 'RetentionPolicy_Enabled',
value: true,
};
settings.add('RetentionPolicy_DoNotPruneDiscussion', true, {
group: 'RetentionPolicy',
section: 'Global Policy',
type: 'boolean',
public: true,
i18nLabel: 'RetentionPolicy_DoNotPruneDiscussion',
i18nDescription: 'RetentionPolicy_DoNotPruneDiscussion_Description',
enableQuery: globalQuery,
});
settings.add('RetentionPolicy_DoNotPruneThreads', true, {
group: 'RetentionPolicy',
section: 'Global Policy',
type: 'boolean',
public: true,
i18nLabel: 'RetentionPolicy_DoNotPruneThreads',
i18nDescription: 'RetentionPolicy_DoNotPruneThreads_Description',
enableQuery: globalQuery,
});
});

@ -0,0 +1,37 @@
import { settingsRegistry } from '../../settings/server';
settingsRegistry.addGroup('Discussion', function() {
// the channel for which discussions are created if none is explicitly chosen
this.add('Discussion_enabled', true, {
group: 'Discussion',
i18nLabel: 'Enable',
type: 'boolean',
public: true,
});
});
const globalQuery = {
_id: 'RetentionPolicy_Enabled',
value: true,
};
settingsRegistry.add('RetentionPolicy_DoNotPruneDiscussion', true, {
group: 'RetentionPolicy',
section: 'Global Policy',
type: 'boolean',
public: true,
i18nLabel: 'RetentionPolicy_DoNotPruneDiscussion',
i18nDescription: 'RetentionPolicy_DoNotPruneDiscussion_Description',
enableQuery: globalQuery,
});
settingsRegistry.add('RetentionPolicy_DoNotPruneThreads', true, {
group: 'RetentionPolicy',
section: 'Global Policy',
type: 'boolean',
public: true,
i18nLabel: 'RetentionPolicy_DoNotPruneThreads',
i18nDescription: 'RetentionPolicy_DoNotPruneThreads_Description',
enableQuery: globalQuery,
});

@ -1,10 +0,0 @@
import { settings } from '../../settings';
settings.add('Accounts_OAuth_Dolphin_URL', '', { type: 'string', group: 'OAuth', public: true, section: 'Dolphin', i18nLabel: 'URL' });
settings.add('Accounts_OAuth_Dolphin', false, { type: 'boolean', group: 'OAuth', section: 'Dolphin', i18nLabel: 'Accounts_OAuth_Custom_Enable' });
settings.add('Accounts_OAuth_Dolphin_id', '', { type: 'string', group: 'OAuth', section: 'Dolphin', i18nLabel: 'Accounts_OAuth_Custom_id' });
settings.add('Accounts_OAuth_Dolphin_secret', '', { type: 'string', group: 'OAuth', section: 'Dolphin', i18nLabel: 'Accounts_OAuth_Custom_Secret', secret: true });
settings.add('Accounts_OAuth_Dolphin_login_style', 'redirect', { type: 'select', group: 'OAuth', section: 'Dolphin', i18nLabel: 'Accounts_OAuth_Custom_Login_Style', persistent: true, values: [{ key: 'redirect', i18nLabel: 'Redirect' }, { key: 'popup', i18nLabel: 'Popup' }, { key: '', i18nLabel: 'Default' }] });
settings.add('Accounts_OAuth_Dolphin_button_label_text', '', { type: 'string', group: 'OAuth', section: 'Dolphin', i18nLabel: 'Accounts_OAuth_Custom_Button_Label_Text', persistent: true });
settings.add('Accounts_OAuth_Dolphin_button_label_color', '#FFFFFF', { type: 'string', group: 'OAuth', section: 'Dolphin', i18nLabel: 'Accounts_OAuth_Custom_Button_Label_Color', persistent: true });
settings.add('Accounts_OAuth_Dolphin_button_color', '#1d74f5', { type: 'string', group: 'OAuth', section: 'Dolphin', i18nLabel: 'Accounts_OAuth_Custom_Button_Color', persistent: true });

@ -0,0 +1,10 @@
import { settingsRegistry } from '../../settings/server';
settingsRegistry.add('Accounts_OAuth_Dolphin_URL', '', { type: 'string', group: 'OAuth', public: true, section: 'Dolphin', i18nLabel: 'URL' });
settingsRegistry.add('Accounts_OAuth_Dolphin', false, { type: 'boolean', group: 'OAuth', section: 'Dolphin', i18nLabel: 'Accounts_OAuth_Custom_Enable' });
settingsRegistry.add('Accounts_OAuth_Dolphin_id', '', { type: 'string', group: 'OAuth', section: 'Dolphin', i18nLabel: 'Accounts_OAuth_Custom_id' });
settingsRegistry.add('Accounts_OAuth_Dolphin_secret', '', { type: 'string', group: 'OAuth', section: 'Dolphin', i18nLabel: 'Accounts_OAuth_Custom_Secret', secret: true });
settingsRegistry.add('Accounts_OAuth_Dolphin_login_style', 'redirect', { type: 'select', group: 'OAuth', section: 'Dolphin', i18nLabel: 'Accounts_OAuth_Custom_Login_Style', persistent: true, values: [{ key: 'redirect', i18nLabel: 'Redirect' }, { key: 'popup', i18nLabel: 'Popup' }, { key: '', i18nLabel: 'Default' }] });
settingsRegistry.add('Accounts_OAuth_Dolphin_button_label_text', '', { type: 'string', group: 'OAuth', section: 'Dolphin', i18nLabel: 'Accounts_OAuth_Custom_Button_Label_Text', persistent: true });
settingsRegistry.add('Accounts_OAuth_Dolphin_button_label_color', '#FFFFFF', { type: 'string', group: 'OAuth', section: 'Dolphin', i18nLabel: 'Accounts_OAuth_Custom_Button_Label_Color', persistent: true });
settingsRegistry.add('Accounts_OAuth_Dolphin_button_color', '#1d74f5', { type: 'string', group: 'OAuth', section: 'Dolphin', i18nLabel: 'Accounts_OAuth_Custom_Button_Color', persistent: true });

@ -1,6 +1,6 @@
import { settings } from '../../settings';
import { settingsRegistry } from '../../settings/server';
settings.addGroup('OAuth', function() {
settingsRegistry.addGroup('OAuth', function() {
this.section('Drupal', function() {
const enableQuery = {
_id: 'Accounts_OAuth_Drupal',
@ -11,6 +11,6 @@ settings.addGroup('OAuth', function() {
this.add('API_Drupal_URL', '', { type: 'string', public: true, enableQuery, i18nDescription: 'API_Drupal_URL_Description' });
this.add('Accounts_OAuth_Drupal_id', '', { type: 'string', enableQuery });
this.add('Accounts_OAuth_Drupal_secret', '', { type: 'string', enableQuery, secret: true });
this.add('Accounts_OAuth_Drupal_callback_url', '_oauth/drupal', { type: 'relativeUrl', readonly: true, force: true, enableQuery });
this.add('Accounts_OAuth_Drupal_callback_url', '_oauth/drupal', { type: 'relativeUrl', readonly: true, enableQuery });
});
});

@ -1,6 +1,6 @@
import { settings } from '../../settings';
import { settingsRegistry } from '../../settings/server';
settings.addGroup('E2E Encryption', function() {
settingsRegistry.addGroup('E2E Encryption', function() {
this.add('E2E_Enable', false, {
type: 'boolean',
i18nLabel: 'Enabled',

@ -1,6 +1,6 @@
import { settings } from '../../../settings';
import { settingsRegistry } from '../../../settings/server';
settings.addGroup('EmojiCustomFilesystem', function() {
settingsRegistry.addGroup('EmojiCustomFilesystem', function() {
this.add('EmojiUpload_Storage_Type', 'GridFS', {
type: 'select',
values: [{

@ -1,6 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
import { Users, Rooms } from '../../../models';
import { sendMessage } from '../../../lib';
@ -13,7 +13,7 @@ class ErrorHandler {
Meteor.startup(() => {
this.registerHandlers();
settings.get('Log_Exceptions_to_Channel', (key, value) => {
settings.watch('Log_Exceptions_to_Channel', (value) => {
this.rid = null;
const roomName = value.trim();
if (roomName) {

@ -1,5 +0,0 @@
import { settings } from '../../../settings';
settings.addGroup('Logs', function() {
this.add('Log_Exceptions_to_Channel', '', { type: 'string' });
});

@ -0,0 +1,5 @@
import { settingsRegistry } from '../../../settings/server';
settingsRegistry.addGroup('Logs', function() {
this.add('Log_Exceptions_to_Channel', '', { type: 'string' });
});

@ -1,7 +1,6 @@
import { debounce } from 'underscore';
import { Meteor } from 'meteor/meteor';
import { settings } from '../../../settings/server';
import { settingsRegistry, settings } from '../../../settings/server';
import { updateStatus, updateEnabled, isRegisteringOrEnabled } from '../functions/helpers';
import { getFederationDomain } from '../lib/getFederationDomain';
import { getFederationDiscoveryMethod } from '../lib/getFederationDiscoveryMethod';
@ -14,7 +13,7 @@ import { STATUS_ENABLED, STATUS_REGISTERING, STATUS_ERROR_REGISTERING, STATUS_DI
Meteor.startup(function() {
const federationPublicKey = FederationKeys.getPublicKeyString();
settings.addGroup('Federation', function() {
settingsRegistry.addGroup('Federation', function() {
this.add('FEDERATION_Enabled', false, {
type: 'boolean',
i18nLabel: 'Enabled',
@ -34,7 +33,7 @@ Meteor.startup(function() {
i18nLabel: 'FEDERATION_Domain',
i18nDescription: 'FEDERATION_Domain_Description',
alert: 'FEDERATION_Domain_Alert',
disableReset: true,
// disableReset: true,
});
this.add('FEDERATION_Public_Key', federationPublicKey, {
@ -66,7 +65,7 @@ Meteor.startup(function() {
});
});
const updateSettings = debounce(Meteor.bindEnvironment(function() {
const updateSettings = function() {
// Get the key pair
if (getFederationDiscoveryMethod() === 'hub' && !isRegisteringOrEnabled()) {
@ -86,9 +85,10 @@ const updateSettings = debounce(Meteor.bindEnvironment(function() {
} else {
updateStatus(STATUS_ENABLED);
}
}), 150);
};
function enableOrDisable(key, value) {
// Add settings listeners
settings.watch('FEDERATION_Enabled', function enableOrDisable(value) {
setupLogger.info(`Federation is ${ value ? 'enabled' : 'disabled' }`);
if (value) {
@ -102,9 +102,6 @@ function enableOrDisable(key, value) {
}
value && updateSettings();
}
});
// Add settings listeners
settings.get('FEDERATION_Enabled', enableOrDisable);
settings.get('FEDERATION_Domain', updateSettings);
settings.get('FEDERATION_Discovery_Method', updateSettings);
settings.watchMultiple(['FEDERATION_Discovery_Method', 'FEDERATION_Domain'], updateSettings);

@ -109,4 +109,4 @@ const configure = _.debounce(function() {
AmazonS3UserDataFiles.store = FileUpload.configureUploadsStore('AmazonS3', AmazonS3UserDataFiles.name, config);
}, 500);
settings.get(/^FileUpload_S3_/, configure);
settings.watchByRegex(/^FileUpload_S3_/, configure);

@ -2,9 +2,8 @@ import fs from 'fs';
import { Meteor } from 'meteor/meteor';
import { UploadFS } from 'meteor/jalik:ufs';
import _ from 'underscore';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
import { FileUploadClass, FileUpload } from '../lib/FileUpload';
import { getFileRange, setRangeHeaders } from '../lib/ranges';
@ -120,7 +119,7 @@ const FileSystemUserDataFiles = new FileUploadClass({
},
});
const createFileSystemStore = _.debounce(function() {
settings.watch('FileUpload_FileSystemPath', function() {
const options = {
path: settings.get('FileUpload_FileSystemPath'), // '/tmp/uploads/photos',
};
@ -131,6 +130,4 @@ const createFileSystemStore = _.debounce(function() {
// DEPRECATED backwards compatibililty (remove)
UploadFS.getStores().fileSystem = UploadFS.getStores()[FileSystemUploads.name];
}, 500);
settings.get('FileUpload_FileSystemPath', createFileSystemStore);
});

@ -93,4 +93,4 @@ const configure = _.debounce(function() {
GoogleCloudStorageUserDataFiles.store = FileUpload.configureUploadsStore('GoogleStorage', GoogleCloudStorageUserDataFiles.name, config);
}, 500);
settings.get(/^FileUpload_GoogleStorage_/, configure);
settings.watchByRegex(/^FileUpload_GoogleStorage_/, configure);

@ -69,4 +69,4 @@ const configure = _.debounce(function() {
WebdavUserDataFiles.store = FileUpload.configureUploadsStore('Webdav', WebdavUserDataFiles.name, config);
}, 500);
settings.get(/^FileUpload_Webdav_/, configure);
settings.watchByRegex(/^FileUpload_Webdav_/, configure);

@ -20,4 +20,4 @@ const configStore = _.debounce(() => {
}
}, 1000);
settings.get(/^FileUpload_/, configStore);
settings.watchByRegex(/^FileUpload_/, configStore);

@ -33,7 +33,7 @@ import { SystemLogger } from '../../../../server/lib/logger/system';
const cookie = new Cookies();
let maxFileSize = 0;
settings.get('FileUpload_MaxFileSize', function(key, value) {
settings.watch('FileUpload_MaxFileSize', function(value) {
try {
maxFileSize = parseInt(value);
} catch (e) {

@ -1,12 +1,12 @@
import { Meteor } from 'meteor/meteor';
import { UploadFS } from 'meteor/jalik:ufs';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
import { Uploads } from '../../../models';
let protectedFiles;
settings.get('FileUpload_ProtectFiles', function(key, value) {
settings.watch('FileUpload_ProtectFiles', function(value) {
protectedFiles = value;
});

@ -1,6 +1,6 @@
import { settings } from '../../../settings';
import { settingsRegistry } from '../../../settings/server';
settings.addGroup('FileUpload', function() {
settingsRegistry.addGroup('FileUpload', function() {
this.add('FileUpload_Enabled', true, {
type: 'boolean',
public: true,

@ -1,6 +1,6 @@
import { settings } from '../../settings';
import { settingsRegistry } from '../../settings/server';
settings.addGroup('OAuth', function() {
settingsRegistry.addGroup('OAuth', function() {
this.section('GitHub Enterprise', function() {
const enableQuery = {
_id: 'Accounts_OAuth_GitHub_Enterprise',
@ -11,6 +11,6 @@ settings.addGroup('OAuth', function() {
this.add('API_GitHub_Enterprise_URL', '', { type: 'string', public: true, enableQuery, i18nDescription: 'API_GitHub_Enterprise_URL_Description' });
this.add('Accounts_OAuth_GitHub_Enterprise_id', '', { type: 'string', enableQuery, secret: true });
this.add('Accounts_OAuth_GitHub_Enterprise_secret', '', { type: 'string', enableQuery, secret: true });
this.add('Accounts_OAuth_GitHub_Enterprise_callback_url', '_oauth/github_enterprise', { type: 'relativeUrl', readonly: true, force: true, enableQuery });
this.add('Accounts_OAuth_GitHub_Enterprise_callback_url', '_oauth/github_enterprise', { type: 'relativeUrl', readonly: true, enableQuery });
});
});

@ -1,6 +1,6 @@
import { settings } from '../../settings';
import { settingsRegistry } from '../../settings/server';
settings.addGroup('OAuth', function() {
settingsRegistry.addGroup('OAuth', function() {
this.section('GitLab', function() {
const enableQuery = {
_id: 'Accounts_OAuth_Gitlab',
@ -13,6 +13,6 @@ settings.addGroup('OAuth', function() {
this.add('Accounts_OAuth_Gitlab_secret', '', { type: 'string', enableQuery, secret: true });
this.add('Accounts_OAuth_Gitlab_identity_path', '/api/v4/user', { type: 'string', public: true, enableQuery });
this.add('Accounts_OAuth_Gitlab_merge_users', false, { type: 'boolean', public: true, enableQuery });
this.add('Accounts_OAuth_Gitlab_callback_url', '_oauth/gitlab', { type: 'relativeUrl', readonly: true, force: true, enableQuery });
this.add('Accounts_OAuth_Gitlab_callback_url', '_oauth/gitlab', { type: 'relativeUrl', readonly: true, enableQuery });
});
});

@ -1,9 +1,9 @@
import { Meteor } from 'meteor/meteor';
import { settings } from '../../settings';
import { settingsRegistry } from '../../settings/server';
Meteor.startup(function() {
settings.addGroup('Accounts', function() {
settingsRegistry.addGroup('Accounts', function() {
this.section('Iframe', function() {
this.add('Accounts_iframe_enabled', false, { type: 'boolean', public: true });
this.add('Accounts_iframe_url', '', { type: 'string', public: true });

@ -3,28 +3,12 @@ import path from 'path';
import fs from 'fs';
import { Meteor } from 'meteor/meteor';
import TurndownService from 'turndown';
import {
Base,
ProgressStep,
} from '../../importer/server';
const turndownService = new TurndownService({
strongDelimiter: '*',
hr: '',
br: '\n',
});
turndownService.addRule('strikethrough', {
filter: 'img',
replacement(content, node) {
const src = node.getAttribute('src') || '';
const alt = node.alt || node.title || src;
return src ? `[${ alt }](${ src })` : '';
},
});
export class HipChatEnterpriseImporter extends Base {
constructor(info, importRecord) {
@ -151,6 +135,30 @@ export class HipChatEnterpriseImporter extends Base {
return count;
}
get turndownService() {
const TurndownService = Promise.await(import('turndown')).default;
const turndownService = new TurndownService({
strongDelimiter: '*',
hr: '',
br: '\n',
});
turndownService.addRule('strikethrough', {
filter: 'img',
replacement(content, node) {
const src = node.getAttribute('src') || '';
const alt = node.alt || node.title || src;
return src ? `[${ alt }](${ src })` : '';
},
});
this.turndownService = turndownService;
return turndownService;
}
convertImportedMessage(importedMessage, rid, type) {
const idType = type === 'private' ? type : `${ rid }-${ type }`;
const newId = `hipchatenterprise-${ idType }-${ importedMessage.id }`;
@ -167,7 +175,7 @@ export class HipChatEnterpriseImporter extends Base {
const text = importedMessage.message;
if (importedMessage.message_format === 'html') {
newMessage.msg = turndownService.turndown(text);
newMessage.msg = this.turndownService.turndown(text);
} else if (text.startsWith('/me ')) {
newMessage.msg = `${ text.replace(/\/me /, '_') }_`;
} else {

@ -1,9 +1,9 @@
import { Meteor } from 'meteor/meteor';
import { settings } from '../../settings';
import { settingsRegistry } from '../../settings/server';
Meteor.startup(function() {
settings.addGroup('IRC_Federation', function() {
settingsRegistry.addGroup('IRC_Federation', function() {
this.add('IRC_Enabled', false, {
type: 'boolean',
i18nLabel: 'Enabled',

@ -1,6 +1,6 @@
import { settings } from '../../settings';
import { settingsRegistry } from '../../settings/server';
settings.add('IssueLinks_Enabled', false, {
settingsRegistry.add('IssueLinks_Enabled', false, {
type: 'boolean',
i18nLabel: 'Enabled',
i18nDescription: 'IssueLinks_Incompatible',
@ -9,7 +9,7 @@ settings.add('IssueLinks_Enabled', false, {
public: true,
});
settings.add('IssueLinks_Template', '', {
settingsRegistry.add('IssueLinks_Template', '', {
type: 'string',
i18nLabel: 'IssueLinks_LinkTemplate',
i18nDescription: 'IssueLinks_LinkTemplate_Description',

@ -1,20 +1,20 @@
import { Meteor } from 'meteor/meteor';
import { settings } from '../../settings';
import { settingsRegistry } from '../../settings/server';
Meteor.startup(function() {
const enableQuery = {
_id: 'Katex_Enabled',
value: true,
};
settings.add('Katex_Enabled', true, {
settingsRegistry.add('Katex_Enabled', true, {
type: 'boolean',
group: 'Message',
section: 'Katex',
public: true,
i18n: 'Katex_Enabled_Description',
i18nDescription: 'Katex_Enabled_Description',
});
settings.add('Katex_Parenthesis_Syntax', true, {
settingsRegistry.add('Katex_Parenthesis_Syntax', true, {
type: 'boolean',
group: 'Message',
section: 'Katex',
@ -22,7 +22,7 @@ Meteor.startup(function() {
enableQuery,
i18nDescription: 'Katex_Parenthesis_Syntax_Description',
});
return settings.add('Katex_Dollar_Syntax', false, {
return settingsRegistry.add('Katex_Dollar_Syntax', false, {
type: 'boolean',
group: 'Message',
section: 'Katex',

@ -8,7 +8,7 @@ This package contains the main libraries of Rocket.Chat.
This is an example to create settings:
```javascript
RocketChat.settings.addGroup('Settings_Group', function() {
settingsRegistry.addGroup('Settings_Group', function() {
this.add('SettingInGroup', 'default_value', { type: 'boolean', public: true });
this.section('Group_Section', function() {
@ -24,7 +24,7 @@ RocketChat.settings.addGroup('Settings_Group', function() {
});
```
`RocketChat.settings.add` type:
`settingsRegistry.add` type:
* `string` - Stores a string value
* Additional options:
@ -40,7 +40,7 @@ RocketChat.settings.addGroup('Settings_Group', function() {
* `actionText`: Translatable value of the button
* `asset` - Creates an upload field
`RocketChat.settings.add` options:
`settingsRegistry.add` options:
* `description` - Description of the setting
* `public` - Boolean to set if the setting should be sent to client or not

@ -1,4 +1,4 @@
import '../lib/startup/settingsOnLoadSiteUrl';
import './startup/settingsOnLoadSiteUrl';
import '../lib/MessageTypes';
import './OAuthProxy';
import './methods/sendMessage';

@ -0,0 +1,18 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { settings } from '../../../settings/client';
Meteor.startup(() => {
Tracker.autorun(() => {
const value = settings.get('Site_Url');
if (value == null || value.trim() === '') {
return;
}
(window as any).__meteor_runtime_config__.ROOT_URL = value;
if (Meteor.absoluteUrl.defaultOptions && Meteor.absoluteUrl.defaultOptions.rootUrl) {
Meteor.absoluteUrl.defaultOptions.rootUrl = value;
}
});
});

@ -1,63 +0,0 @@
/* eslint no-multi-spaces: 0 */
/* eslint comma-spacing: 0 */
import { capitalize } from '@rocket.chat/string-helpers';
import { settings } from '../../../settings';
export function addOAuthService(name, values = {}) {
name = name.toLowerCase().replace(/[^a-z0-9_]/g, '');
name = capitalize(name);
settings.add(`Accounts_OAuth_Custom-${ name }` , values.enabled || false , { type: 'boolean', group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Enable', persistent: true });
settings.add(`Accounts_OAuth_Custom-${ name }-url` , values.serverURL || '' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'URL', persistent: true });
settings.add(`Accounts_OAuth_Custom-${ name }-token_path` , values.tokenPath || '/oauth/token' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Token_Path', persistent: true });
settings.add(`Accounts_OAuth_Custom-${ name }-token_sent_via` , values.tokenSentVia || 'payload' , { type: 'select' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Token_Sent_Via', persistent: true, values: [{ key: 'header', i18nLabel: 'Header' }, { key: 'payload', i18nLabel: 'Payload' }] });
settings.add(`Accounts_OAuth_Custom-${ name }-identity_token_sent_via`, values.identityTokenSentVia || 'default' , { type: 'select' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Identity_Token_Sent_Via', persistent: true, values: [{ key: 'default', i18nLabel: 'Same_As_Token_Sent_Via' }, { key: 'header', i18nLabel: 'Header' }, { key: 'payload', i18nLabel: 'Payload' }] });
settings.add(`Accounts_OAuth_Custom-${ name }-identity_path` , values.identityPath || '/me' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Identity_Path', persistent: true });
settings.add(`Accounts_OAuth_Custom-${ name }-authorize_path` , values.authorizePath || '/oauth/authorize' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Authorize_Path', persistent: true });
settings.add(`Accounts_OAuth_Custom-${ name }-scope` , values.scope || 'openid' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Scope', persistent: true });
settings.add(`Accounts_OAuth_Custom-${ name }-access_token_param` , values.accessTokenParam || 'access_token' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Access_Token_Param', persistent: true });
settings.add(`Accounts_OAuth_Custom-${ name }-id` , values.clientId || '' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_id', persistent: true });
settings.add(`Accounts_OAuth_Custom-${ name }-secret` , values.clientSecret || '' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Secret', persistent: true });
settings.add(`Accounts_OAuth_Custom-${ name }-login_style` , values.loginStyle || 'popup' , { type: 'select' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Login_Style', persistent: true, values: [{ key: 'redirect', i18nLabel: 'Redirect' }, { key: 'popup', i18nLabel: 'Popup' }, { key: '', i18nLabel: 'Default' }] });
settings.add(`Accounts_OAuth_Custom-${ name }-button_label_text` , values.buttonLabelText || '' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Button_Label_Text', persistent: true });
settings.add(`Accounts_OAuth_Custom-${ name }-button_label_color` , values.buttonLabelColor || '#FFFFFF' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Button_Label_Color', persistent: true });
settings.add(`Accounts_OAuth_Custom-${ name }-button_color` , values.buttonColor || '#1d74f5' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Button_Color', persistent: true });
settings.add(`Accounts_OAuth_Custom-${ name }-key_field` , values.keyField || 'username' , { type: 'select' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Key_Field', persistent: true, values: [{ key: 'username', i18nLabel: 'Username' }, { key: 'email', i18nLabel: 'Email' }] });
settings.add(`Accounts_OAuth_Custom-${ name }-username_field` , values.usernameField || '' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Username_Field', persistent: true });
settings.add(`Accounts_OAuth_Custom-${ name }-email_field` , values.emailField || '' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Email_Field', persistent: true });
settings.add(`Accounts_OAuth_Custom-${ name }-name_field` , values.nameField || '' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Name_Field', persistent: true });
settings.add(`Accounts_OAuth_Custom-${ name }-avatar_field` , values.avatarField || '' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Avatar_Field', persistent: true });
settings.add(`Accounts_OAuth_Custom-${ name }-roles_claim` , values.rolesClaim || 'roles', { type: 'string',
group: 'OAuth',
section: `Custom OAuth: ${ name }`,
i18nLabel: 'Accounts_OAuth_Custom_Roles_Claim',
enterprise: true,
invalidValue: 'roles',
modules: ['oauth-enterprise'] });
settings.add(`Accounts_OAuth_Custom-${ name }-groups_claim` , values.groupsClaim || 'groups', { type: 'string',
group: 'OAuth',
section: `Custom OAuth: ${ name }`,
i18nLabel: 'Accounts_OAuth_Custom_Groups_Claim',
enterprise: true,
invalidValue: 'groups',
modules: ['oauth-enterprise'] });
settings.add(`Accounts_OAuth_Custom-${ name }-channels_admin` , values.channelsAdmin || 'rocket.cat' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Channel_Admin', persistent: true });
settings.add(`Accounts_OAuth_Custom-${ name }-map_channels` , values.mapChannels || false, { type: 'boolean',
group: 'OAuth',
section: `Custom OAuth: ${ name }`,
i18nLabel: 'Accounts_OAuth_Custom_Map_Channels',
enterprise: true,
invalidValue: false,
modules: ['oauth-enterprise'] });
settings.add(`Accounts_OAuth_Custom-${ name }-merge_roles` , values.mergeRoles || false, { type: 'boolean',
group: 'OAuth',
section: `Custom OAuth: ${ name }`,
i18nLabel: 'Accounts_OAuth_Custom_Merge_Roles',
enterprise: true,
invalidValue: false,
modules: ['oauth-enterprise'] });
settings.add(`Accounts_OAuth_Custom-${ name }-merge_users`, values.mergeUsers || false, { type: 'boolean', group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Merge_Users', persistent: true });
settings.add(`Accounts_OAuth_Custom-${ name }-show_button` , values.showButton || true , { type: 'boolean', group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Show_Button_On_Login_Page', persistent: true });
settings.add(`Accounts_OAuth_Custom-${ name }-groups_channel_map` , values.channelsMap || '{\n\t"rocket-admin": "admin",\n\t"tech-support": "support"\n}' , { type: 'code' , multiline: true, code: 'application/json', group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Channel_Map', persistent: true });
}

@ -0,0 +1,63 @@
/* eslint no-multi-spaces: 0 */
/* eslint comma-spacing: 0 */
import { capitalize } from '@rocket.chat/string-helpers';
import { settingsRegistry } from '../../../settings/server';
export function addOAuthService(name: string, values: { [k: string]: string | boolean| undefined } = {}): void {
name = name.toLowerCase().replace(/[^a-z0-9_]/g, '');
name = capitalize(name);
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }` , values.enabled || false , { type: 'boolean', group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Enable', persistent: true });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-url` , values.serverURL || '' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'URL', persistent: true });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-token_path` , values.tokenPath || '/oauth/token' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Token_Path', persistent: true });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-token_sent_via` , values.tokenSentVia || 'payload' , { type: 'select' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Token_Sent_Via', persistent: true, values: [{ key: 'header', i18nLabel: 'Header' }, { key: 'payload', i18nLabel: 'Payload' }] });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-identity_token_sent_via`, values.identityTokenSentVia || 'default' , { type: 'select' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Identity_Token_Sent_Via', persistent: true, values: [{ key: 'default', i18nLabel: 'Same_As_Token_Sent_Via' }, { key: 'header', i18nLabel: 'Header' }, { key: 'payload', i18nLabel: 'Payload' }] });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-identity_path` , values.identityPath || '/me' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Identity_Path', persistent: true });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-authorize_path` , values.authorizePath || '/oauth/authorize' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Authorize_Path', persistent: true });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-scope` , values.scope || 'openid' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Scope', persistent: true });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-access_token_param` , values.accessTokenParam || 'access_token' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Access_Token_Param', persistent: true });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-id` , values.clientId || '' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_id', persistent: true });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-secret` , values.clientSecret || '' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Secret', persistent: true });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-login_style` , values.loginStyle || 'popup' , { type: 'select' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Login_Style', persistent: true, values: [{ key: 'redirect', i18nLabel: 'Redirect' }, { key: 'popup', i18nLabel: 'Popup' }, { key: '', i18nLabel: 'Default' }] });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-button_label_text` , values.buttonLabelText || '' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Button_Label_Text', persistent: true });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-button_label_color` , values.buttonLabelColor || '#FFFFFF' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Button_Label_Color', persistent: true });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-button_color` , values.buttonColor || '#1d74f5' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Button_Color', persistent: true });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-key_field` , values.keyField || 'username' , { type: 'select' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Key_Field', persistent: true, values: [{ key: 'username', i18nLabel: 'Username' }, { key: 'email', i18nLabel: 'Email' }] });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-username_field` , values.usernameField || '' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Username_Field', persistent: true });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-email_field` , values.emailField || '' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Email_Field', persistent: true });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-name_field` , values.nameField || '' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Name_Field', persistent: true });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-avatar_field` , values.avatarField || '' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Avatar_Field', persistent: true });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-roles_claim` , values.rolesClaim || 'roles', { type: 'string',
group: 'OAuth',
section: `Custom OAuth: ${ name }`,
i18nLabel: 'Accounts_OAuth_Custom_Roles_Claim',
enterprise: true,
invalidValue: 'roles',
modules: ['oauth-enterprise'] });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-groups_claim` , values.groupsClaim || 'groups', { type: 'string',
group: 'OAuth',
section: `Custom OAuth: ${ name }`,
i18nLabel: 'Accounts_OAuth_Custom_Groups_Claim',
enterprise: true,
invalidValue: 'groups',
modules: ['oauth-enterprise'] });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-channels_admin` , values.channelsAdmin || 'rocket.cat' , { type: 'string' , group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Channel_Admin', persistent: true });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-map_channels` , values.mapChannels || false, { type: 'boolean',
group: 'OAuth',
section: `Custom OAuth: ${ name }`,
i18nLabel: 'Accounts_OAuth_Custom_Map_Channels',
enterprise: true,
invalidValue: false,
modules: ['oauth-enterprise'] });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-merge_roles` , values.mergeRoles || false, { type: 'boolean',
group: 'OAuth',
section: `Custom OAuth: ${ name }`,
i18nLabel: 'Accounts_OAuth_Custom_Merge_Roles',
enterprise: true,
invalidValue: false,
modules: ['oauth-enterprise'] });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-merge_users`, values.mergeUsers || false, { type: 'boolean', group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Merge_Users', persistent: true });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-show_button` , values.showButton || true , { type: 'boolean', group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Show_Button_On_Login_Page', persistent: true });
settingsRegistry.add(`Accounts_OAuth_Custom-${ name }-groups_channel_map` , values.channelsMap || '{\n\t"rocket-admin": "admin",\n\t"tech-support": "support"\n}' , { type: 'code' , multiline: true, code: 'application/json', group: 'OAuth', section: `Custom OAuth: ${ name }`, i18nLabel: 'Accounts_OAuth_Custom_Channel_Map', persistent: true });
}

@ -3,7 +3,7 @@ import s from 'underscore.string';
import _ from 'underscore';
import { escapeRegExp } from '@rocket.chat/string-helpers';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
import { Team } from '../../../../server/sdk';
import { validateName } from './validateName';
@ -11,7 +11,7 @@ let usernameBlackList = [];
const toRegExp = (username) => new RegExp(`^${ escapeRegExp(username).trim() }$`, 'i');
settings.get('Accounts_BlockedUsernameList', (key, value) => {
settings.watch('Accounts_BlockedUsernameList', (value) => {
usernameBlackList = ['all', 'here'].concat(value.split(',')).map(toRegExp);
});

@ -1,5 +1,5 @@
import { Logger } from '../../../logger';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
import { Users } from '../../../models/server';
import { hasPermission } from '../../../authorization';
@ -35,7 +35,7 @@ const fullFields = {
let publicCustomFields = {};
let customFields = {};
settings.get('Accounts_CustomFields', (key, value) => {
settings.watch('Accounts_CustomFields', (value) => {
publicCustomFields = {};
customFields = {};

@ -4,7 +4,7 @@ import s from 'underscore.string';
import { escapeHTML } from '@rocket.chat/string-helpers';
import * as Mailer from '../../../../mailer';
import { settings } from '../../../../settings';
import { settings } from '../../../../settings/server';
import { roomTypes } from '../../../../utils';
import { metrics } from '../../../../metrics';
import { callbacks } from '../../../../callbacks';
@ -13,7 +13,7 @@ import { getURL } from '../../../../utils/server';
let advice = '';
let goToMessage = '';
Meteor.startup(() => {
settings.get('email_style', function() {
settings.watch('email_style', function() {
goToMessage = Mailer.inlinecss('<p><a class=\'btn\' href="[room_path]">{Offline_Link_Message}</a></p>');
});
Mailer.getTemplate('Email_Footer_Direct_Reply', (value) => {

@ -27,7 +27,7 @@ function _bugsnagDebug(message: any, stack: any, ...args: any): void {
return originalMeteorDebug(message, stack, ...args);
}
settings.get('Bugsnag_api_key', (_key, value) => {
settings.watch('Bugsnag_api_key', (value) => {
if (!value) {
return;
}

@ -12,13 +12,13 @@ const logger = new Logger('Meteor');
let Log_Trace_Methods;
let Log_Trace_Subscriptions;
settings.get('Log_Trace_Methods', (key, value) => { Log_Trace_Methods = value; });
settings.get('Log_Trace_Subscriptions', (key, value) => { Log_Trace_Subscriptions = value; });
settings.watch('Log_Trace_Methods', (value) => { Log_Trace_Methods = value; });
settings.watch('Log_Trace_Subscriptions', (value) => { Log_Trace_Subscriptions = value; });
let Log_Trace_Methods_Filter;
let Log_Trace_Subscriptions_Filter;
settings.get('Log_Trace_Methods_Filter', (key, value) => { Log_Trace_Methods_Filter = value ? new RegExp(value) : undefined; });
settings.get('Log_Trace_Subscriptions_Filter', (key, value) => { Log_Trace_Subscriptions_Filter = value ? new RegExp(value) : undefined; });
settings.watch('Log_Trace_Methods_Filter', (value) => { Log_Trace_Methods_Filter = value ? new RegExp(value) : undefined; });
settings.watch('Log_Trace_Subscriptions_Filter', (value) => { Log_Trace_Subscriptions_Filter = value ? new RegExp(value) : undefined; });
const traceConnection = (enable, filter, prefix, name, connection, userId) => {
if (!enable) {

@ -3,7 +3,7 @@ import { IRoom } from '../../../../definition/IRoom';
const hideMessagesOfTypeServer = new Set<string>();
settings.get('Hide_System_Messages', function(_key, values) {
settings.watch<string[]>('Hide_System_Messages', function(values) {
if (!values || !Array.isArray(values)) {
return;
}

@ -9,7 +9,7 @@ import './notifyUsersOnMessage';
import './meteorFixes';
export { sendNotification } from './sendNotificationsOnMessage';
export { hostname } from '../../lib/startup/settingsOnLoadSiteUrl';
export { hostname } from '../startup/settingsOnLoadSiteUrl';
export { passwordPolicy } from './passwordPolicy';
export { validateEmailDomain } from './validateEmailDomain';
export { RateLimiterClass as RateLimiter } from './RateLimiter';

@ -1,14 +1,14 @@
import PasswordPolicy from './PasswordPolicyClass';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
export const passwordPolicy = new PasswordPolicy();
settings.get('Accounts_Password_Policy_Enabled', (key, value) => { passwordPolicy.enabled = value; });
settings.get('Accounts_Password_Policy_MinLength', (key, value) => { passwordPolicy.minLength = value; });
settings.get('Accounts_Password_Policy_MaxLength', (key, value) => { passwordPolicy.maxLength = value; });
settings.get('Accounts_Password_Policy_ForbidRepeatingCharacters', (key, value) => { passwordPolicy.forbidRepeatingCharacters = value; });
settings.get('Accounts_Password_Policy_ForbidRepeatingCharactersCount', (key, value) => { passwordPolicy.forbidRepeatingCharactersCount = value; });
settings.get('Accounts_Password_Policy_AtLeastOneLowercase', (key, value) => { passwordPolicy.mustContainAtLeastOneLowercase = value; });
settings.get('Accounts_Password_Policy_AtLeastOneUppercase', (key, value) => { passwordPolicy.mustContainAtLeastOneUppercase = value; });
settings.get('Accounts_Password_Policy_AtLeastOneNumber', (key, value) => { passwordPolicy.mustContainAtLeastOneNumber = value; });
settings.get('Accounts_Password_Policy_AtLeastOneSpecialCharacter', (key, value) => { passwordPolicy.mustContainAtLeastOneSpecialCharacter = value; });
settings.watch('Accounts_Password_Policy_Enabled', (value) => { passwordPolicy.enabled = value; });
settings.watch('Accounts_Password_Policy_MinLength', (value) => { passwordPolicy.minLength = value; });
settings.watch('Accounts_Password_Policy_MaxLength', (value) => { passwordPolicy.maxLength = value; });
settings.watch('Accounts_Password_Policy_ForbidRepeatingCharacters', (value) => { passwordPolicy.forbidRepeatingCharacters = value; });
settings.watch('Accounts_Password_Policy_ForbidRepeatingCharactersCount', (value) => { passwordPolicy.forbidRepeatingCharactersCount = value; });
settings.watch('Accounts_Password_Policy_AtLeastOneLowercase', (value) => { passwordPolicy.mustContainAtLeastOneLowercase = value; });
settings.watch('Accounts_Password_Policy_AtLeastOneUppercase', (value) => { passwordPolicy.mustContainAtLeastOneUppercase = value; });
settings.watch('Accounts_Password_Policy_AtLeastOneNumber', (value) => { passwordPolicy.mustContainAtLeastOneNumber = value; });
settings.watch('Accounts_Password_Policy_AtLeastOneSpecialCharacter', (value) => { passwordPolicy.mustContainAtLeastOneSpecialCharacter = value; });

@ -2,7 +2,7 @@ import { Meteor } from 'meteor/meteor';
import moment from 'moment';
import { hasPermission } from '../../../authorization';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
import { callbacks } from '../../../callbacks/server';
import { Subscriptions, Users } from '../../../models/server';
import { roomTypes } from '../../../utils';
@ -393,7 +393,7 @@ export async function sendAllNotifications(message, room) {
return message;
}
settings.get('Troubleshoot_Disable_Notifications', (key, value) => {
settings.watch('Troubleshoot_Disable_Notifications', (value) => {
if (TroubleshootDisableNotifications === value) { return; }
TroubleshootDisableNotifications = value;

@ -10,10 +10,8 @@ const emailValidationRegex = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[
let emailDomainBlackList = [];
let emailDomainWhiteList = [];
let useDefaultBlackList = false;
let useDNSDomainCheck = false;
settings.get('Accounts_BlockedDomainsList', function(key, value) {
settings.watch('Accounts_BlockedDomainsList', function(value) {
if (!value) {
emailDomainBlackList = [];
return;
@ -21,7 +19,7 @@ settings.get('Accounts_BlockedDomainsList', function(key, value) {
emailDomainBlackList = value.split(',').filter(Boolean).map((domain) => domain.trim());
});
settings.get('Accounts_AllowedDomainsList', function(key, value) {
settings.watch('Accounts_AllowedDomainsList', function(value) {
if (!value) {
emailDomainWhiteList = [];
return;
@ -29,12 +27,6 @@ settings.get('Accounts_AllowedDomainsList', function(key, value) {
emailDomainWhiteList = value.split(',').filter(Boolean).map((domain) => domain.trim());
});
settings.get('Accounts_UseDefaultBlockedDomainsList', function(key, value) {
useDefaultBlackList = value;
});
settings.get('Accounts_UseDNSDomainCheck', function(key, value) {
useDNSDomainCheck = value;
});
export const validateEmailDomain = function(email) {
if (!emailValidationRegex.test(email)) {
@ -46,11 +38,11 @@ export const validateEmailDomain = function(email) {
if (emailDomainWhiteList.length && !emailDomainWhiteList.includes(emailDomain)) {
throw new Meteor.Error('error-invalid-domain', 'The email domain is not in whitelist', { function: 'RocketChat.validateEmailDomain' });
}
if (emailDomainBlackList.length && (emailDomainBlackList.indexOf(emailDomain) !== -1 || (useDefaultBlackList && emailDomainDefaultBlackList.indexOf(emailDomain) !== -1))) {
if (emailDomainBlackList.length && (emailDomainBlackList.indexOf(emailDomain) !== -1 || (settings.get('Accounts_UseDefaultBlockedDomainsList') && emailDomainDefaultBlackList.indexOf(emailDomain) !== -1))) {
throw new Meteor.Error('error-email-domain-blacklisted', 'The email domain is blacklisted', { function: 'RocketChat.validateEmailDomain' });
}
if (useDNSDomainCheck) {
if (settings.get('Accounts_UseDNSDomainCheck')) {
try {
dnsResolveMx(emailDomain);
} catch (e) {

@ -8,7 +8,7 @@ import { IMessage } from '../../../../definition/IMessage';
const Dep = new Tracker.Dependency();
Meteor.startup(() => {
settings.get(/Message_AllowBadWordsFilter|Message_BadWordsFilterList|Message_BadWordsWhitelist/, () => {
settings.watchMultiple(['Message_AllowBadWordsFilter', 'Message_BadWordsFilterList', 'Message_BadWordsWhitelist'], () => {
Dep.changed();
});
Tracker.autorun(() => {

@ -3,7 +3,7 @@ import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { hasPermission } from '../../../authorization';
import { settings } from '../../../settings';
import { Settings } from '../../../models/server';
Meteor.methods({
removeOAuthService(name) {
@ -19,33 +19,33 @@ Meteor.methods({
name = name.toLowerCase().replace(/[^a-z0-9_]/g, '');
name = capitalize(name);
settings.removeById(`Accounts_OAuth_Custom-${ name }`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-url`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-token_path`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-identity_path`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-authorize_path`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-scope`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-access_token_param`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-token_sent_via`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-identity_token_sent_via`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-id`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-secret`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-button_label_text`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-button_label_color`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-button_color`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-login_style`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-key_field`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-username_field`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-email_field`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-name_field`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-avatar_field`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-roles_claim`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-merge_roles`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-merge_users`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-show_button`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-groups_claim`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-channels_admin`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-map_channels`);
settings.removeById(`Accounts_OAuth_Custom-${ name }-groups_channel_map`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-url`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-token_path`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-identity_path`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-authorize_path`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-scope`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-access_token_param`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-token_sent_via`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-identity_token_sent_via`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-id`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-secret`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-button_label_text`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-button_label_color`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-button_color`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-login_style`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-key_field`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-username_field`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-email_field`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-name_field`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-avatar_field`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-roles_claim`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-merge_roles`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-merge_users`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-show_button`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-groups_claim`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-channels_admin`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-map_channels`);
Settings.removeById(`Accounts_OAuth_Custom-${ name }-groups_channel_map`);
},
});

@ -3,7 +3,6 @@ import { Match, check } from 'meteor/check';
import { hasPermission, hasAllPermission } from '../../../authorization/server';
import { getSettingPermissionId } from '../../../authorization/lib';
import { settings } from '../../../settings';
import { Settings } from '../../../models';
import { twoFactorRequired } from '../../../2fa/server/twoFactorRequired';
@ -45,7 +44,7 @@ Meteor.methods({
break;
}
settings.updateById(_id, value, editor);
Settings.updateValueAndEditorById(_id, value, editor);
return true;
}),
});

@ -2,7 +2,6 @@ import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';
import { hasPermission } from '../../../authorization';
import { settings } from '../../../settings';
import { Settings } from '../../../models';
import { getSettingPermissionId } from '../../../authorization/lib';
import { twoFactorRequired } from '../../../2fa/server/twoFactorRequired';
@ -54,7 +53,7 @@ Meteor.methods({
});
}
params.forEach(({ _id, value, editor }) => settings.updateById(_id, value, editor));
params.forEach(({ _id, value, editor }) => Settings.updateValueById(_id, value, editor));
return true;
}),

@ -1,6 +1,6 @@
import { settings } from '../../../settings';
import { settingsRegistry } from '../../../settings/server';
settings.addGroup('Email', function() {
settingsRegistry.addGroup('Email', function() {
this.section('Style', function() {
this.add('email_plain_text_only', false, {
type: 'boolean',

@ -4,58 +4,58 @@ import _ from 'underscore';
import { CustomOAuth } from '../../../custom-oauth';
import { Logger } from '../../../logger';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
import { addOAuthService } from '../functions/addOAuthService';
const logger = new Logger('rocketchat:lib');
function _OAuthServicesUpdate() {
const services = settings.get(/^(Accounts_OAuth_|Accounts_OAuth_Custom-)[a-z0-9_]+$/i);
services.forEach((service) => {
logger.info({ oauth_updated: service.key });
let serviceName = service.key.replace('Accounts_OAuth_', '');
const services = settings.getByRegexp(/^(Accounts_OAuth_|Accounts_OAuth_Custom-)[a-z0-9_]+$/i);
services.forEach(([key, value]) => {
logger.debug({ oauth_updated: key });
let serviceName = key.replace('Accounts_OAuth_', '');
if (serviceName === 'Meteor') {
serviceName = 'meteor-developer';
}
if (/Accounts_OAuth_Custom-/.test(service.key)) {
serviceName = service.key.replace('Accounts_OAuth_Custom-', '');
if (/Accounts_OAuth_Custom-/.test(key)) {
serviceName = key.replace('Accounts_OAuth_Custom-', '');
}
if (service.value === true) {
if (value === true) {
const data = {
clientId: settings.get(`${ service.key }_id`),
secret: settings.get(`${ service.key }_secret`),
clientId: settings.get(`${ key }_id`),
secret: settings.get(`${ key }_secret`),
};
if (/Accounts_OAuth_Custom-/.test(service.key)) {
if (/Accounts_OAuth_Custom-/.test(key)) {
data.custom = true;
data.clientId = settings.get(`${ service.key }-id`);
data.secret = settings.get(`${ service.key }-secret`);
data.serverURL = settings.get(`${ service.key }-url`);
data.tokenPath = settings.get(`${ service.key }-token_path`);
data.identityPath = settings.get(`${ service.key }-identity_path`);
data.authorizePath = settings.get(`${ service.key }-authorize_path`);
data.scope = settings.get(`${ service.key }-scope`);
data.accessTokenParam = settings.get(`${ service.key }-access_token_param`);
data.buttonLabelText = settings.get(`${ service.key }-button_label_text`);
data.buttonLabelColor = settings.get(`${ service.key }-button_label_color`);
data.loginStyle = settings.get(`${ service.key }-login_style`);
data.buttonColor = settings.get(`${ service.key }-button_color`);
data.tokenSentVia = settings.get(`${ service.key }-token_sent_via`);
data.identityTokenSentVia = settings.get(`${ service.key }-identity_token_sent_via`);
data.keyField = settings.get(`${ service.key }-key_field`);
data.usernameField = settings.get(`${ service.key }-username_field`);
data.emailField = settings.get(`${ service.key }-email_field`);
data.nameField = settings.get(`${ service.key }-name_field`);
data.avatarField = settings.get(`${ service.key }-avatar_field`);
data.rolesClaim = settings.get(`${ service.key }-roles_claim`);
data.groupsClaim = settings.get(`${ service.key }-groups_claim`);
data.channelsMap = settings.get(`${ service.key }-groups_channel_map`);
data.channelsAdmin = settings.get(`${ service.key }-channels_admin`);
data.mergeUsers = settings.get(`${ service.key }-merge_users`);
data.mapChannels = settings.get(`${ service.key }-map_channels`);
data.mergeRoles = settings.get(`${ service.key }-merge_roles`);
data.showButton = settings.get(`${ service.key }-show_button`);
data.clientId = settings.get(`${ key }-id`);
data.secret = settings.get(`${ key }-secret`);
data.serverURL = settings.get(`${ key }-url`);
data.tokenPath = settings.get(`${ key }-token_path`);
data.identityPath = settings.get(`${ key }-identity_path`);
data.authorizePath = settings.get(`${ key }-authorize_path`);
data.scope = settings.get(`${ key }-scope`);
data.accessTokenParam = settings.get(`${ key }-access_token_param`);
data.buttonLabelText = settings.get(`${ key }-button_label_text`);
data.buttonLabelColor = settings.get(`${ key }-button_label_color`);
data.loginStyle = settings.get(`${ key }-login_style`);
data.buttonColor = settings.get(`${ key }-button_color`);
data.tokenSentVia = settings.get(`${ key }-token_sent_via`);
data.identityTokenSentVia = settings.get(`${ key }-identity_token_sent_via`);
data.keyField = settings.get(`${ key }-key_field`);
data.usernameField = settings.get(`${ key }-username_field`);
data.emailField = settings.get(`${ key }-email_field`);
data.nameField = settings.get(`${ key }-name_field`);
data.avatarField = settings.get(`${ key }-avatar_field`);
data.rolesClaim = settings.get(`${ key }-roles_claim`);
data.groupsClaim = settings.get(`${ key }-groups_claim`);
data.channelsMap = settings.get(`${ key }-groups_channel_map`);
data.channelsAdmin = settings.get(`${ key }-channels_admin`);
data.mergeUsers = settings.get(`${ key }-merge_users`);
data.mapChannels = settings.get(`${ key }-map_channels`);
data.mergeRoles = settings.get(`${ key }-merge_roles`);
data.showButton = settings.get(`${ key }-show_button`);
new CustomOAuth(serviceName.toLowerCase(), {
serverURL: data.serverURL,
@ -131,11 +131,11 @@ function OAuthServicesRemove(_id) {
});
}
settings.get(/^Accounts_OAuth_.+/, function() {
settings.watchByRegex(/^Accounts_OAuth_.+/, function() {
return OAuthServicesUpdate(); // eslint-disable-line new-cap
});
settings.get(/^Accounts_OAuth_Custom-[a-z0-9_]+/, function(key, value) {
settings.watchByRegex(/^Accounts_OAuth_Custom-[a-z0-9_]+/, function(key, value) {
if (!value) {
return OAuthServicesRemove(key);// eslint-disable-line new-cap
}

@ -3,7 +3,7 @@ import { Meteor } from 'meteor/meteor';
import { DDPRateLimiter } from 'meteor/ddp-rate-limiter';
import { RateLimiter } from 'meteor/rate-limit';
import { settings } from '../../../settings';
import { settings } from '../../../settings/server';
import { metrics } from '../../../metrics';
import { Logger } from '../../../logger';
@ -203,9 +203,9 @@ const configConnectionByMethod = _.debounce(() => {
}, 1000);
if (!process.env.TEST_MODE) {
settings.get(/^DDP_Rate_Limit_IP_.+/, configIP);
settings.get(/^DDP_Rate_Limit_User_[^B].+/, configUser);
settings.get(/^DDP_Rate_Limit_Connection_[^B].+/, configConnection);
settings.get(/^DDP_Rate_Limit_User_By_Method_.+/, configUserByMethod);
settings.get(/^DDP_Rate_Limit_Connection_By_Method_.+/, configConnectionByMethod);
settings.watchByRegex(/^DDP_Rate_Limit_IP_.+/, configIP);
settings.watchByRegex(/^DDP_Rate_Limit_User_[^B].+/, configUser);
settings.watchByRegex(/^DDP_Rate_Limit_Connection_[^B].+/, configConnection);
settings.watchByRegex(/^DDP_Rate_Limit_User_By_Method_.+/, configUserByMethod);
settings.watchByRegex(/^DDP_Rate_Limit_Connection_By_Method_.+/, configConnectionByMethod);
}

@ -1,18 +1,19 @@
import { Random } from 'meteor/random';
import { settings } from '../../../settings/server';
import { settingsRegistry } from '../../../settings/server';
import './email';
import { MessageTypesValues } from '../../lib/MessageTypes';
// Insert server unique id if it doesn't exist
settings.add('uniqueID', process.env.DEPLOYMENT_ID || Random.id(), {
settingsRegistry.add('uniqueID', process.env.DEPLOYMENT_ID || Random.id(), {
public: true,
});
// When you define a setting and want to add a description, you don't need to automatically define the i18nDescription
// if you add a node to the i18n.json with the same setting name but with `_Description` it will automatically work.
settings.addGroup('Accounts', function() {
settingsRegistry.addGroup('Accounts', function() {
this.add('Accounts_AllowAnonymousRead', false, {
type: 'boolean',
public: true,
@ -148,7 +149,7 @@ settings.addGroup('Accounts', function() {
enableQuery: {
_id: 'SMTP_Host',
value: {
$exists: 1,
$exists: true,
$ne: '',
},
},
@ -622,7 +623,7 @@ settings.addGroup('Accounts', function() {
});
});
settings.addGroup('OAuth', function() {
settingsRegistry.addGroup('OAuth', function() {
this.section('Facebook', function() {
const enableQuery = {
_id: 'Accounts_OAuth_Facebook',
@ -644,7 +645,6 @@ settings.addGroup('OAuth', function() {
return this.add('Accounts_OAuth_Facebook_callback_url', '_oauth/facebook', {
type: 'relativeUrl',
readonly: true,
force: true,
enableQuery,
});
});
@ -669,7 +669,6 @@ settings.addGroup('OAuth', function() {
return this.add('Accounts_OAuth_Google_callback_url', '_oauth/google', {
type: 'relativeUrl',
readonly: true,
force: true,
enableQuery,
});
});
@ -694,7 +693,6 @@ settings.addGroup('OAuth', function() {
return this.add('Accounts_OAuth_Github_callback_url', '_oauth/github', {
type: 'relativeUrl',
readonly: true,
force: true,
enableQuery,
});
});
@ -719,7 +717,6 @@ settings.addGroup('OAuth', function() {
return this.add('Accounts_OAuth_Linkedin_callback_url', '_oauth/linkedin', {
type: 'relativeUrl',
readonly: true,
force: true,
enableQuery,
});
});
@ -744,7 +741,6 @@ settings.addGroup('OAuth', function() {
return this.add('Accounts_OAuth_Meteor_callback_url', '_oauth/meteor', {
type: 'relativeUrl',
readonly: true,
force: true,
enableQuery,
});
});
@ -769,7 +765,6 @@ settings.addGroup('OAuth', function() {
return this.add('Accounts_OAuth_Twitter_callback_url', '_oauth/twitter', {
type: 'relativeUrl',
readonly: true,
force: true,
enableQuery,
});
});
@ -785,7 +780,7 @@ settings.addGroup('OAuth', function() {
});
});
settings.addGroup('General', function() {
settingsRegistry.addGroup('General', function() {
this.add('Show_Setup_Wizard', 'pending', {
type: 'select',
public: true,
@ -803,7 +798,9 @@ settings.addGroup('General', function() {
},
],
});
this.add('Site_Url', typeof __meteor_runtime_config__ !== 'undefined' && __meteor_runtime_config__ !== null ? __meteor_runtime_config__.ROOT_URL : null, {
// eslint-disable-next-line @typescript-eslint/camelcase
this.add('Site_Url', typeof (global as any).__meteor_runtime_config__ !== 'undefined' && (global as any).__meteor_runtime_config__ !== null ? (global as any).__meteor_runtime_config__.ROOT_URL : null, {
type: 'string',
i18nDescription: 'Site_Url_Description',
public: true,
@ -1076,7 +1073,7 @@ settings.addGroup('General', function() {
});
});
settings.addGroup('Message', function() {
settingsRegistry.addGroup('Message', function() {
this.section('Message_Attachments', function() {
this.add('Message_Attachments_GroupAttach', false, {
type: 'boolean',
@ -1287,7 +1284,7 @@ settings.addGroup('Message', function() {
});
});
settings.addGroup('Meta', function() {
settingsRegistry.addGroup('Meta', function() {
this.add('Meta_language', '', {
type: 'string',
});
@ -1313,7 +1310,7 @@ settings.addGroup('Meta', function() {
});
});
settings.addGroup('Mobile', function() {
settingsRegistry.addGroup('Mobile', function() {
this.add('Allow_Save_Media_to_Gallery', true, {
type: 'boolean',
public: true,
@ -1334,7 +1331,7 @@ const pushEnabledWithoutGateway = [
},
];
settings.addGroup('Push', function() {
settingsRegistry.addGroup('Push', function() {
this.add('Push_enable', true, {
type: 'boolean',
public: true,
@ -1455,7 +1452,7 @@ settings.addGroup('Push', function() {
});
});
settings.addGroup('Layout', function() {
settingsRegistry.addGroup('Layout', function() {
this.section('Content', function() {
this.add('Layout_Home_Title', 'Home', {
type: 'string',
@ -1569,7 +1566,7 @@ settings.addGroup('Layout', function() {
});
});
settings.addGroup('Logs', function() {
settingsRegistry.addGroup('Logs', function() {
this.add('Log_Level', '0', {
type: 'select',
values: [
@ -1621,7 +1618,7 @@ settings.addGroup('Logs', function() {
});
// See the default port allocation at https://github.com/prometheus/prometheus/wiki/Default-port-allocations
this.add('Prometheus_Port', 9458, {
type: 'string',
type: 'int',
i18nLabel: 'Port',
});
this.add('Prometheus_Reset_Interval', 0, {
@ -1637,7 +1634,7 @@ settings.addGroup('Logs', function() {
});
});
settings.addGroup('Setup_Wizard', function() {
settingsRegistry.addGroup('Setup_Wizard', function() {
this.section('Organization_Info', function() {
this.add('Organization_Type', '', {
type: 'select',
@ -2979,7 +2976,7 @@ settings.addGroup('Setup_Wizard', function() {
});
});
settings.addGroup('Rate Limiter', function() {
settingsRegistry.addGroup('Rate Limiter', function() {
this.section('DDP Rate Limiter', function() {
this.add('DDP_Rate_Limit_IP_Enabled', true, { type: 'boolean' });
this.add('DDP_Rate_Limit_IP_Requests_Allowed', 120000, { type: 'int', enableQuery: { _id: 'DDP_Rate_Limit_IP_Enabled', value: true } });
@ -3010,7 +3007,7 @@ settings.addGroup('Rate Limiter', function() {
});
});
settings.addGroup('Troubleshoot', function() {
settingsRegistry.addGroup('Troubleshoot', function() {
this.add('Troubleshoot_Disable_Notifications', false, {
type: 'boolean',
alert: 'Troubleshoot_Disable_Notifications_Alert',
@ -3044,5 +3041,3 @@ settings.addGroup('Troubleshoot', function() {
alert: 'Troubleshoot_Disable_Workspace_Sync_Alert',
});
});
settings.init();

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save