🐛 Cant delete a document with archived file in it (#203)
This commit is contained in:
parent
6aaf8749d6
commit
8b636dadd3
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user