Skip to content

Commit

Permalink
Remove duplicated server settings (#13223)
Browse files Browse the repository at this point in the history
* Move integrations models to rc-models

* Move composeMessage function to rc-utils

* Move PushNotifications class to push-notifications package

* Import variables to remove dependency of RC namespace

* Import variables to remove RC namespace dependency inside rc-lib/server/lib

* Import variables to remove RC namespace inside rc-lib/server/methods

* Import variables to remove dependency with RC namespace

* Remove duplicated server settings located in rc-lib
  • Loading branch information
MarcosSpessatto authored and rodrigok committed Jan 22, 2019
1 parent 23388c4 commit 23547e9
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 355 deletions.
1 change: 0 additions & 1 deletion packages/rocketchat-lib/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ Package.onUse(function(api) {
api.addFiles('server/functions/saveCustomFields.js', 'server');
api.addFiles('server/functions/saveCustomFieldsWithoutValidation.js', 'server');
api.addFiles('server/functions/sendMessage.js', 'server');
api.addFiles('server/functions/settings.js', 'server');
api.addFiles('server/functions/setUserAvatar.js', 'server');
api.addFiles('server/functions/setUsername.js', 'server');
api.addFiles('server/functions/setRealName.js', 'server');
Expand Down
297 changes: 0 additions & 297 deletions packages/rocketchat-lib/server/functions/settings.js

This file was deleted.

3 changes: 2 additions & 1 deletion packages/rocketchat-lib/startup/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as Mailer from 'meteor/rocketchat:mailer';
import { settings } from 'meteor/rocketchat:settings';

Mailer.setSettings(RocketChat.settings);
Mailer.setSettings(settings);
1 change: 0 additions & 1 deletion packages/rocketchat-models/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Package.describe({
Package.onUse(function(api) {
api.use([
'ecmascript',
'rocketchat:settings',
'rocketchat:callbacks',
'rocketchat:ui-cached-collection',
'konecty:multiple-instances-status',
Expand Down
13 changes: 10 additions & 3 deletions packages/rocketchat-models/server/models/Messages.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Match } from 'meteor/check';
import { settings } from 'meteor/rocketchat:settings';
import { Base } from './_Base';
import Rooms from './Rooms';
import Users from './Users';
Expand All @@ -24,6 +23,14 @@ export class Messages extends Base {
this.tryEnsureIndex({ snippeted: 1 }, { sparse: 1 });
this.tryEnsureIndex({ location: '2dsphere' });
this.tryEnsureIndex({ slackBotId: 1, slackTs: 1 }, { sparse: 1 });
this.loadSettings();
}

loadSettings() {
Meteor.startup(async() => {
const { settings } = await import('meteor/rocketchat:settings');
this.settings = settings;
});
}

countVisibleByRoomIdBetweenTimestampsInclusive(roomId, afterTimestamp, beforeTimestamp, options) {
Expand Down Expand Up @@ -600,7 +607,7 @@ export class Messages extends Base {
groupable: false,
};

if (settings.get('Message_Read_Receipt_Enabled')) {
if (this.settings.get('Message_Read_Receipt_Enabled')) {
record.unread = true;
}

Expand Down Expand Up @@ -629,7 +636,7 @@ export class Messages extends Base {
groupable: false,
};

if (settings.get('Message_Read_Receipt_Enabled')) {
if (this.settings.get('Message_Read_Receipt_Enabled')) {
record.unread = true;
}

Expand Down
11 changes: 9 additions & 2 deletions packages/rocketchat-models/server/models/Users.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { settings } from 'meteor/rocketchat:settings';
import { Base } from './_Base';
import Subscriptions from './Subscriptions';
import _ from 'underscore';
Expand All @@ -17,6 +16,14 @@ export class Users extends Base {
this.tryEnsureIndex({ active: 1 }, { sparse: 1 });
this.tryEnsureIndex({ statusConnection: 1 }, { sparse: 1 });
this.tryEnsureIndex({ type: 1 });
this.loadSettings();
}

loadSettings() {
Meteor.startup(async() => {
const { settings } = await import('meteor/rocketchat:settings');
this.settings = settings;
});
}

roleBaseQuery(userId) {
Expand Down Expand Up @@ -200,7 +207,7 @@ export class Users extends Base {

const termRegex = new RegExp(s.escapeRegExp(searchTerm), 'i');

const orStmt = _.reduce(settings.get('Accounts_SearchFields').trim().split(','), function(acc, el) {
const orStmt = _.reduce(this.settings.get('Accounts_SearchFields').trim().split(','), function(acc, el) {
acc.push({ [el.trim()]: termRegex });
return acc;
}, []);
Expand Down
Loading

0 comments on commit 23547e9

Please sign in to comment.