mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
feat(server): add user existence check and optimize permission queries (#10402)
This commit is contained in:
@@ -498,22 +498,14 @@ export class DocResolver {
|
||||
]);
|
||||
});
|
||||
|
||||
const users = new Map<string, PublicUserType>(
|
||||
await Promise.all(
|
||||
permissions.map(
|
||||
async p =>
|
||||
[p.userId, await this.models.user.getPublicUser(p.userId)] as [
|
||||
string,
|
||||
PublicUserType,
|
||||
]
|
||||
)
|
||||
)
|
||||
const publicUsers = await this.models.user.getPublicUsers(
|
||||
permissions.map(p => p.userId)
|
||||
);
|
||||
|
||||
const publicUsersMap = new Map(publicUsers.map(pu => [pu.id, pu]));
|
||||
return paginate(
|
||||
permissions.map(p => ({
|
||||
...p,
|
||||
user: users.get(p.userId),
|
||||
user: publicUsersMap.get(p.userId) as PublicUserType,
|
||||
})),
|
||||
'createdAt',
|
||||
pagination,
|
||||
|
||||
Reference in New Issue
Block a user