Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove duplicated server settings #13223

Merged
merged 12 commits into from
Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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