Add Test to opt out of username being searchable

This commit is contained in:
Phillip Thelen
2018-11-27 13:20:26 +01:00
parent e9c86622c5
commit 0271d98b91
4 changed files with 9 additions and 3 deletions

View File

@@ -16,13 +16,13 @@ api.getUsernameAutocompletes = {
let username = req.params.username.toLowerCase();
if (username[0] === '@') username = username.slice(1, username.length);
if (username.length < 2) {
if (username.length < 1) {
res.respond(200, []);
return;
}
let members = await User
.find({'auth.local.lowerCaseUsername': {$regex: `.*${username}.*`}, 'flags.verifiedUsername': true})
.find({'auth.local.lowerCaseUsername': {$regex: `.*${username}.*`}, 'flags.verifiedUsername': true, 'preferences.searchableUsername': {$ne: false}})
.select(['profile.name', 'contributor', 'auth.local.username'])
.limit(20)
.exec();