diff --git a/src/server/api/endpoints/users/search.ts b/src/server/api/endpoints/users/search.ts index edc4d603ca..b37c07003b 100644 --- a/src/server/api/endpoints/users/search.ts +++ b/src/server/api/endpoints/users/search.ts @@ -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