0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-21 00:52:43 -05:00

pr feedback

This commit is contained in:
martabal 2024-02-02 17:59:15 +01:00
parent 5aa05e4630
commit 3e93b46c8b
No known key found for this signature in database
GPG key ID: C00196E3148A52BD

View file

@ -105,13 +105,17 @@ export class PersonService {
await this.access.requirePermission(auth, Permission.PERSON_CREATE, faceId);
const face = await this.repository.getFaceById(faceId);
const person = await this.findOrFail(dto.personId);
const refreshIds = [];
await this.repository.reassignFace(face.id, dto.personId);
if (person.faceAssetId === null) {
await this.createNewFeaturePhoto([person.id]);
refreshIds.push(person.id);
}
if (face.person && face.person.faceAssetId === face.id) {
await this.createNewFeaturePhoto([face.person.id]);
refreshIds.push(face.person.id);
}
if (refreshIds.length > 0) {
await this.createNewFeaturePhoto(refreshIds);
}
return this.findOrFail(dto.personId).then(mapPerson);
@ -124,9 +128,12 @@ export class PersonService {
const changeFeaturePhoto: string[] = [];
for (const data of dto.data) {
const faces = await this.repository.getFacesByIds([{ personId: data.personId, assetId: data.assetId }]);
await this.access.requirePermission(
auth,
Permission.PERSON_CREATE,
faces.map((face) => face.id),
);
for (const face of faces) {
await this.access.requirePermission(auth, Permission.PERSON_CREATE, face.id);
if (person.faceAssetId === null) {
changeFeaturePhoto.push(person.id);
}