mirror of
https://github.com/documenso/documenso.git
synced 2025-11-16 09:41:35 +10:00
feat: expiry links
This commit is contained in:
@ -21,6 +21,7 @@ import {
|
||||
import { getFileServerSide } from '../../universal/upload/get-file.server';
|
||||
import { putPdfFileServerSide } from '../../universal/upload/put-file.server';
|
||||
import { isDocumentCompleted } from '../../utils/document';
|
||||
import { calculateRecipientExpiry } from '../../utils/expiry';
|
||||
import { insertFormValuesInPdf } from '../pdf/insert-form-values-in-pdf';
|
||||
import { triggerWebhook } from '../webhooks/trigger/trigger-webhook';
|
||||
import { getDocumentWhereInput } from './get-document-by-id';
|
||||
@ -213,6 +214,24 @@ export const sendDocument = async ({
|
||||
});
|
||||
}
|
||||
|
||||
if (document.documentMeta?.expiryAmount && document.documentMeta?.expiryUnit) {
|
||||
const expiryDate = calculateRecipientExpiry(
|
||||
document.documentMeta.expiryAmount,
|
||||
document.documentMeta.expiryUnit,
|
||||
new Date(), // Calculate from current time
|
||||
);
|
||||
|
||||
await tx.recipient.updateMany({
|
||||
where: {
|
||||
documentId: document.id,
|
||||
expired: null,
|
||||
},
|
||||
data: {
|
||||
expired: expiryDate,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return await tx.document.update({
|
||||
where: {
|
||||
id: documentId,
|
||||
|
||||
Reference in New Issue
Block a user