feat: Implement merge person functionality with associated request and repository methods
This commit is contained in:
@@ -183,4 +183,36 @@ impl PersonService for PersonServiceImpl {
|
||||
.remove_share(person_id, target_user_id)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn merge_people(
|
||||
&self,
|
||||
target_person_id: Uuid,
|
||||
source_person_id: Uuid,
|
||||
user_id: Uuid,
|
||||
) -> CoreResult<()> {
|
||||
if target_person_id == source_person_id {
|
||||
return Err(CoreError::Validation(
|
||||
"Cannot merge the same person".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
self.auth_service
|
||||
.check_permission(
|
||||
Some(user_id),
|
||||
authz::Permission::EditPerson(target_person_id),
|
||||
)
|
||||
.await?;
|
||||
self.auth_service
|
||||
.check_permission(
|
||||
Some(user_id),
|
||||
authz::Permission::EditPerson(source_person_id),
|
||||
)
|
||||
.await?;
|
||||
|
||||
self.face_repo
|
||||
.reassign_person(source_person_id, target_person_id)
|
||||
.await?;
|
||||
|
||||
self.person_repo.delete(source_person_id).await
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user