mirror of
https://github.com/documenso/documenso.git
synced 2026-07-25 01:15:49 +10:00
chore: code changes based of review
This commit is contained in:
@@ -106,23 +106,6 @@ export const resendDocument = async ({
|
||||
return;
|
||||
}
|
||||
|
||||
let newExpiryDate: Date | null = null;
|
||||
if (recipient.expired) {
|
||||
const durationInMs = recipient.expired.getTime() - document.updatedAt.getTime();
|
||||
newExpiryDate = new Date(Date.now() + durationInMs);
|
||||
|
||||
await prisma.recipient.update({
|
||||
where: { id: recipient.id },
|
||||
data: {
|
||||
expired: newExpiryDate,
|
||||
signingStatus:
|
||||
recipient.signingStatus === SigningStatus.EXPIRED
|
||||
? SigningStatus.NOT_SIGNED
|
||||
: recipient.signingStatus,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const i18n = await getI18nInstance(document.documentMeta?.language);
|
||||
|
||||
const recipientEmailType = RECIPIENT_ROLE_TO_EMAIL_TYPE[recipient.role];
|
||||
@@ -183,6 +166,22 @@ export const resendDocument = async ({
|
||||
|
||||
await prisma.$transaction(
|
||||
async (tx) => {
|
||||
if (recipient.expired) {
|
||||
const durationInMs = recipient.expired.getTime() - document.updatedAt.getTime();
|
||||
const newExpiryDate = new Date(Date.now() + durationInMs);
|
||||
|
||||
await tx.recipient.update({
|
||||
where: { id: recipient.id },
|
||||
data: {
|
||||
expired: newExpiryDate,
|
||||
signingStatus:
|
||||
recipient.signingStatus === SigningStatus.EXPIRED
|
||||
? SigningStatus.NOT_SIGNED
|
||||
: recipient.signingStatus,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const [html, text] = await Promise.all([
|
||||
renderEmailWithI18N(template, {
|
||||
lang: document.documentMeta?.language,
|
||||
|
||||
@@ -31,26 +31,24 @@ export const updateExpiredRecipients = async (documentId: number) => {
|
||||
},
|
||||
});
|
||||
|
||||
await Promise.all(
|
||||
expiredRecipients.map(async (recipient) =>
|
||||
prisma.documentAuditLog.create({
|
||||
data: createDocumentAuditLogData({
|
||||
type: DOCUMENT_AUDIT_LOG_TYPE.DOCUMENT_RECIPIENT_EXPIRED,
|
||||
documentId,
|
||||
user: {
|
||||
name: recipient.name,
|
||||
email: recipient.email,
|
||||
},
|
||||
data: {
|
||||
recipientEmail: recipient.email,
|
||||
recipientName: recipient.name,
|
||||
recipientId: recipient.id,
|
||||
recipientRole: recipient.role,
|
||||
},
|
||||
}),
|
||||
await prisma.documentAuditLog.createMany({
|
||||
data: expiredRecipients.map((recipient) =>
|
||||
createDocumentAuditLogData({
|
||||
type: DOCUMENT_AUDIT_LOG_TYPE.DOCUMENT_RECIPIENT_EXPIRED,
|
||||
documentId,
|
||||
user: {
|
||||
name: recipient.name,
|
||||
email: recipient.email,
|
||||
},
|
||||
data: {
|
||||
recipientName: recipient.name,
|
||||
recipientRole: recipient.role,
|
||||
recipientId: recipient.id,
|
||||
recipientEmail: recipient.email,
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return expiredRecipients;
|
||||
|
||||
Reference in New Issue
Block a user