fix: delete pending documents (#1118)

## Description

Currently deleting a pending document where you are a recipient off will
delete the document, but will also throw an error.

This is due to the recipient being updated after the document deleted,
which is only supposed to happen for completed documents.
This commit is contained in:
David Nguyen
2024-04-30 20:53:18 +07:00
committed by GitHub
parent 5109bb17d6
commit dbd452be97

View File

@ -75,17 +75,19 @@ export const deleteDocument = async ({
}
// Continue to hide the document from the user if they are a recipient.
// Dirty way of doing this but it's faster than refetching the document.
if (userRecipient?.documentDeletedAt === null) {
await prisma.recipient.update({
await prisma.recipient
.update({
where: {
documentId_email: {
documentId: document.id,
email: user.email,
},
id: userRecipient.id,
},
data: {
documentDeletedAt: new Date().toISOString(),
},
})
.catch(() => {
// Do nothing.
});
}