Improving implementation of this new functionality

- Undone the changes to spotlight.js: The fields returned are only name, email and status as before (since we do not use other fields, there is no reason to return them, at least by now)
- Retrieving from mongo the fields to search by in the Users.js model (instead of using the fields coming from spotlight.js)
- Fixed the emails.address field that was removed by mistake in the prior commit
pull/7612/head
Bruno Godoy M Correa 8 years ago
parent 92b0d19e3c
commit 338882bfa5
  1. 6
      packages/rocketchat-lib/server/models/Users.js
  2. 2
      packages/rocketchat-lib/server/startup/settings.js
  3. 10
      server/publications/spotlight.js

@ -138,8 +138,10 @@ class ModelUsers extends RocketChat.models._Base {
}
const termRegex = new RegExp(s.escapeRegExp(searchTerm), 'i');
const orStmt = _.reduce(_.keys(options.fields), function(acc, el) {
acc.push({ [el]: termRegex }); return acc;
const orStmt = _.reduce(RocketChat.settings.get('Accounts_SearchFields').trim().split(','), function(acc, el) {
acc.push({ [el.trim()]: termRegex });
return acc;
}, []);
const query = {
$and: [

@ -70,7 +70,7 @@ RocketChat.settings.addGroup('Accounts', function() {
type: 'boolean',
'public': true
});
this.add('Accounts_SearchFields', 'username, name, status', {
this.add('Accounts_SearchFields', 'username, name, emails.address', {
type: 'string',
public: true
});

@ -28,14 +28,14 @@ Meteor.methods({
if (type.users === true && RocketChat.authz.hasPermission(this.userId, 'view-d-room')) {
const userOptions = {
limit: 5,
fields: {},
fields: {
username: 1,
name: 1,
status: 1
},
sort: {}
};
_.map(RocketChat.settings.get('Accounts_SearchFields').trim().split(','), function(field) {
userOptions.fields[field.trim()] = 1;
});
if (RocketChat.settings.get('UI_Use_Real_Name')) {
userOptions.sort.name = 1;
} else {

Loading…
Cancel
Save