Merge branch 'preprod' into staging

This commit is contained in:
Max S 2024-08-21 12:04:33 +02:00
commit f8e123b9f5
2 changed files with 6 additions and 2 deletions

View File

@ -62,7 +62,9 @@ export default class DocumentsService extends BaseService {
if (!documentEntity) throw new Error("document not found");
const document = Document.hydrate<Document>(documentEntity, { strategy: "excludeAll" });
if (document.files && document.files.length !== 0) {
const isDocumentEmpty = document.files && !document!.files.find((file) => file.archived_at === null);
if (!isDocumentEmpty) {
throw new Error("Can't delete a document with file");
}
return this.documentsRepository.delete(uid);

View File

@ -62,7 +62,9 @@ export default class DocumentsService extends BaseService {
if (!documentEntity) throw new Error("document not found");
const document = Document.hydrate<Document>(documentEntity, { strategy: "excludeAll" });
if (document.files && document.files.length !== 0 && document.document_status !== "REFUSED") {
const isDocumentEmpty = document.files && !document!.files.find((file) => file.archived_at === null);
if (!isDocumentEmpty && document.document_status !== "REFUSED") {
throw new Error("Can't delete a document with file");
}
return this.documentsRepository.delete(uid);