ui: support search by displayname (#621)

This commit is contained in:
panda authored and GitHub committed 2023-08-22 08:10:26 +08:00
1 parent 28a32869e2
commit ced52792be
3 files changed
+6 -3

No files matched your search

+3 -1
View File
@@ -399,7 +399,9 @@ class UserModel {
const $regex = `^${escapeRegExp(prefix.toLowerCase())}`;
const udocs = await coll.find({ unameLower: { $regex } })
.limit(limit).project({ _id: 1 }).toArray();
return await Promise.all(udocs.map(({ _id }) => UserModel.getById(domainId, _id)));
const dudocs = await domain.getMultiUserInDomain(domainId, { displayName: { $regex } }).limit(limit).project({ uid: 1 }).toArray();
const uids = uniq([...udocs.map(({ _id }) => _id), ...dudocs.map(({ uid }) => uid)]);
return await Promise.all(uids.map(({ _id }) => UserModel.getById(domainId, _id)));
}
@ArgMethod