mirror of
https://github.com/wassname/talk.git
synced 2026-08-13 12:40:11 +08:00
added user query by value to graph
This commit is contained in:
@@ -28,7 +28,6 @@ const MailerService = require('./mailer');
|
||||
const i18n = require('./i18n');
|
||||
const Wordlist = require('./wordlist');
|
||||
const DomainList = require('./domain_list');
|
||||
const {escapeRegExp} = require('./regex');
|
||||
|
||||
const EMAIL_CONFIRM_JWT_SUBJECT = 'email_confirm';
|
||||
const PASSWORD_RESET_JWT_SUBJECT = 'password_reset';
|
||||
@@ -759,47 +758,6 @@ class UsersService {
|
||||
return [user, loc];
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a user using a value which gets compared using a prefix match against
|
||||
* the user's email address and/or their username.
|
||||
* @param {String} value value to search by
|
||||
* @return {Promise}
|
||||
*/
|
||||
static search(value) {
|
||||
if (!value || typeof value !== 'string' || value.length === 0) {
|
||||
return UserModel.find({});
|
||||
}
|
||||
|
||||
value = escapeRegExp(value).toLowerCase();
|
||||
|
||||
// Compile the prefix search regex.
|
||||
const $regex = new RegExp(`^${value}`);
|
||||
|
||||
return UserModel.find({
|
||||
$or: [
|
||||
|
||||
// Search by a prefix match on the username.
|
||||
{
|
||||
lowercaseUsername: {
|
||||
$regex,
|
||||
},
|
||||
},
|
||||
|
||||
// Search by a prefix match on the email address.
|
||||
{
|
||||
profiles: {
|
||||
$elemMatch: {
|
||||
id: {
|
||||
$regex,
|
||||
},
|
||||
provider: 'local',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a count of the current users.
|
||||
* @return {Promise}
|
||||
|
||||
Reference in New Issue
Block a user