summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-07-21 08:54:41 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-07-21 08:54:41 +0900
commit49bc00102b46e8396e82fe813e35ce99003c7f34 (patch)
tree38fc28b0832317841ef3bcc74fac43f0d40db49a /src
parentMerge pull request #1943 from syuilo/refactor-notes-create (diff)
downloadsharkey-49bc00102b46e8396e82fe813e35ce99003c7f34.tar.gz
sharkey-49bc00102b46e8396e82fe813e35ce99003c7f34.tar.bz2
sharkey-49bc00102b46e8396e82fe813e35ce99003c7f34.zip
Fix bug
Diffstat (limited to 'src')
-rw-r--r--src/server/api/endpoints/users/search_by_username.ts14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/server/api/endpoints/users/search_by_username.ts b/src/server/api/endpoints/users/search_by_username.ts
index 1d8553baef..bfab378389 100644
--- a/src/server/api/endpoints/users/search_by_username.ts
+++ b/src/server/api/endpoints/users/search_by_username.ts
@@ -28,7 +28,7 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
});
if (users.length < limit) {
- const remoteUsers = await User
+ const otherUsers = await User
.find({
host: { $ne: null },
usernameLower: new RegExp('^' + escapeRegexp(query.toLowerCase()))
@@ -36,31 +36,33 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
limit: limit - users.length
});
- users = users.concat(remoteUsers);
+ users = users.concat(otherUsers);
}
if (users.length < limit) {
- const remoteUsers = await User
+ const otherUsers = await User
.find({
+ _id: { $nin: users.map(u => u._id) },
host: null,
usernameLower: new RegExp(escapeRegexp(query.toLowerCase()))
}, {
limit: limit - users.length
});
- users = users.concat(remoteUsers);
+ users = users.concat(otherUsers);
}
if (users.length < limit) {
- const remoteUsers = await User
+ const otherUsers = await User
.find({
+ _id: { $nin: users.map(u => u._id) },
host: { $ne: null },
usernameLower: new RegExp(escapeRegexp(query.toLowerCase()))
}, {
limit: limit - users.length
});
- users = users.concat(remoteUsers);
+ users = users.concat(otherUsers);
}
// Serialize