Skip to content

Commit

Permalink
Fix #3432
Browse files Browse the repository at this point in the history
  • Loading branch information
syuilo committed Nov 29, 2018
1 parent 77d2d84 commit 8ca27a4
Showing 1 changed file with 0 additions and 78 deletions.
78 changes: 0 additions & 78 deletions src/server/api/endpoints/users/search.ts
Expand Up @@ -70,84 +70,6 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {

users = users.concat(otherUsers);
}

if (users.length < ps.limit) {
const otherUsers = await User
.find({
_id: { $nin: users.map(u => u._id) },
host: null,
usernameLower: new RegExp(escapeRegexp(ps.query.replace('@', '').toLowerCase()))
}, {
limit: ps.limit - users.length
});

users = users.concat(otherUsers);
}

if (users.length < ps.limit && !ps.localOnly) {
const otherUsers = await User
.find({
_id: { $nin: users.map(u => u._id) },
host: { $ne: null },
usernameLower: new RegExp(escapeRegexp(ps.query.replace('@', '').toLowerCase()))
}, {
limit: ps.limit - users.length
});

users = users.concat(otherUsers);
}
}

if (users.length < ps.limit) {
const otherUsers = await User
.find({
_id: { $nin: users.map(u => u._id) },
host: null,
name: new RegExp('^' + escapeRegexp(ps.query.toLowerCase()))
}, {
limit: ps.limit - users.length
});

users = users.concat(otherUsers);
}

if (users.length < ps.limit && !ps.localOnly) {
const otherUsers = await User
.find({
_id: { $nin: users.map(u => u._id) },
host: { $ne: null },
name: new RegExp('^' + escapeRegexp(ps.query.toLowerCase()))
}, {
limit: ps.limit - users.length
});

users = users.concat(otherUsers);
}

if (users.length < ps.limit) {
const otherUsers = await User
.find({
_id: { $nin: users.map(u => u._id) },
host: null,
name: new RegExp(escapeRegexp(ps.query.toLowerCase()))
}, {
limit: ps.limit - users.length
});

users = users.concat(otherUsers);
}

if (users.length < ps.limit && !ps.localOnly) {
const otherUsers = await User
.find({
_id: { $nin: users.map(u => u._id) },
host: { $ne: null },
name: new RegExp(escapeRegexp(ps.query.toLowerCase()))
}, {
limit: ps.limit - users.length
});

users = users.concat(otherUsers);
}

// Serialize
Expand Down

0 comments on commit 8ca27a4

Please sign in to comment.