mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 20:46:38 +08:00
feat(server): search docs by keywork from indexer (#12863)
#### PR Dependency Tree * **PR #12867** * **PR #12863** 👈 * **PR #12837** * **PR #12866** This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal)
This commit is contained in:
@@ -45,6 +45,10 @@ interface UserFilter {
|
||||
withDisabled?: boolean;
|
||||
}
|
||||
|
||||
export interface ItemWithUserId {
|
||||
userId: string;
|
||||
}
|
||||
|
||||
export type PublicUser = Pick<User, keyof typeof publicUserSelect>;
|
||||
export type WorkspaceUser = Pick<User, keyof typeof workspaceUserSelect>;
|
||||
export type { ConnectedAccount, User };
|
||||
@@ -78,6 +82,19 @@ export class UserModel extends BaseModel {
|
||||
});
|
||||
}
|
||||
|
||||
async getPublicUsersMap<T extends ItemWithUserId>(
|
||||
items: T[]
|
||||
): Promise<Map<string, PublicUser>> {
|
||||
const userIds: string[] = [];
|
||||
for (const item of items) {
|
||||
if (item.userId) {
|
||||
userIds.push(item.userId);
|
||||
}
|
||||
}
|
||||
const users = await this.getPublicUsers(userIds);
|
||||
return new Map(users.map(user => [user.id, user]));
|
||||
}
|
||||
|
||||
async getWorkspaceUser(id: string): Promise<WorkspaceUser | null> {
|
||||
return this.db.user.findUnique({
|
||||
select: workspaceUserSelect,
|
||||
|
||||
Reference in New Issue
Block a user