mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fix user_search handler
This commit is contained in:
1 parent
f3153993f7
commit
ff6777a8c0
4 files changed
+14
-29
No files matched your search
@@ -276,11 +276,11 @@ class UserModel {
|
||||
@ArgMethod
|
||||
static async getPrefixList(domainId: string, prefix: string, limit: number = 50) {
|
||||
prefix = prefix.toLowerCase();
|
||||
const $regex = new RegExp(`^${escapeRegExp(prefix)}`, 'gmi');
|
||||
const uids = await coll.find({ unameLower: { $regex } })
|
||||
.limit(limit).map((doc) => doc._id).toArray();
|
||||
const $regex = new RegExp(`\\A${escapeRegExp(prefix)}`, 'gmi');
|
||||
const udocs = await coll.find({ unameLower: { $regex } })
|
||||
.limit(limit).project({ _id: 1 }).toArray();
|
||||
const users = [];
|
||||
for (const uid of uids) users.push(UserModel.getById(domainId, uid));
|
||||
for (const { _id } of udocs) users.push(UserModel.getById(domainId, _id));
|
||||
return await Promise.all(users);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user