fix(server): do not leak people (#4710)

This commit is contained in:
martin 2023-10-30 09:44:05 +01:00 committed by GitHub
parent 512f672e9e
commit cc3149c520
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -103,15 +103,18 @@ export class PersonRepository implements IPersonRepository {
return this.personRepository.findOne({ where: { id: personId } });
}
getByName(userId: string, personName: string, { withHidden }: PersonNameSearchOptions): Promise<PersonEntity[]> {
async getByName(
userId: string,
personName: string,
{ withHidden }: PersonNameSearchOptions,
): Promise<PersonEntity[]> {
const queryBuilder = this.personRepository
.createQueryBuilder('person')
.leftJoin('person.faces', 'face')
.where('person.ownerId = :userId', { userId })
.andWhere('LOWER(person.name) LIKE :nameStart OR LOWER(person.name) LIKE :nameAnywhere', {
nameStart: `${personName.toLowerCase()}%`,
nameAnywhere: `% ${personName.toLowerCase()}%`,
})
.where(
'person.ownerId = :userId AND (LOWER(person.name) LIKE :nameStart OR LOWER(person.name) LIKE :nameAnywhere)',
{ userId, nameStart: `${personName.toLowerCase()}%`, nameAnywhere: `% ${personName.toLowerCase()}%` },
)
.groupBy('person.id')
.orderBy('COUNT(face.assetId)', 'DESC')
.limit(20);