mirror of
https://github.com/documenso/documenso.git
synced 2025-11-20 03:32:14 +10:00
chore: redo changes
This commit is contained in:
@ -88,6 +88,7 @@ export const TeamDocumentPreferencesForm = ({
|
|||||||
includeSenderDetails,
|
includeSenderDetails,
|
||||||
includeSigningCertificate,
|
includeSigningCertificate,
|
||||||
typedSignatureEnabled,
|
typedSignatureEnabled,
|
||||||
|
includeAuditTrailLog,
|
||||||
} = data;
|
} = data;
|
||||||
|
|
||||||
await updateTeamDocumentPreferences({
|
await updateTeamDocumentPreferences({
|
||||||
@ -98,6 +99,7 @@ export const TeamDocumentPreferencesForm = ({
|
|||||||
includeSenderDetails,
|
includeSenderDetails,
|
||||||
typedSignatureEnabled,
|
typedSignatureEnabled,
|
||||||
includeSigningCertificate,
|
includeSigningCertificate,
|
||||||
|
includeAuditTrailLog,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import { TRPCError } from '@trpc/server';
|
import { TRPCError } from '@trpc/server';
|
||||||
import { DateTime } from 'luxon';
|
import { DateTime } from 'luxon';
|
||||||
import { PDFDocument } from 'pdf-lib';
|
|
||||||
|
|
||||||
import { getServerLimits } from '@documenso/ee/server-only/limits/server';
|
import { getServerLimits } from '@documenso/ee/server-only/limits/server';
|
||||||
import { NEXT_PUBLIC_WEBAPP_URL } from '@documenso/lib/constants/app';
|
import { NEXT_PUBLIC_WEBAPP_URL } from '@documenso/lib/constants/app';
|
||||||
@ -24,7 +23,6 @@ import { searchDocumentsWithKeyword } from '@documenso/lib/server-only/document/
|
|||||||
import { sendDocument } from '@documenso/lib/server-only/document/send-document';
|
import { sendDocument } from '@documenso/lib/server-only/document/send-document';
|
||||||
import { updateDocument } from '@documenso/lib/server-only/document/update-document';
|
import { updateDocument } from '@documenso/lib/server-only/document/update-document';
|
||||||
import { symmetricEncrypt } from '@documenso/lib/universal/crypto';
|
import { symmetricEncrypt } from '@documenso/lib/universal/crypto';
|
||||||
import { getFile } from '@documenso/lib/universal/upload/get-file';
|
|
||||||
import { getPresignPostUrl } from '@documenso/lib/universal/upload/server-actions';
|
import { getPresignPostUrl } from '@documenso/lib/universal/upload/server-actions';
|
||||||
import { DocumentDataType, DocumentStatus } from '@documenso/prisma/client';
|
import { DocumentDataType, DocumentStatus } from '@documenso/prisma/client';
|
||||||
|
|
||||||
@ -69,82 +67,11 @@ export const documentRouter = router({
|
|||||||
const { teamId } = ctx;
|
const { teamId } = ctx;
|
||||||
const { documentId, includeCertificate, includeAuditLog } = input;
|
const { documentId, includeCertificate, includeAuditLog } = input;
|
||||||
|
|
||||||
const documentWithData = await getDocumentById({
|
return await getDocumentById({
|
||||||
userId: ctx.user.id,
|
userId: ctx.user.id,
|
||||||
teamId,
|
teamId,
|
||||||
documentId,
|
documentId,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (includeCertificate && includeAuditLog) {
|
|
||||||
return documentWithData;
|
|
||||||
} else if (includeCertificate) {
|
|
||||||
const pdfData = await getFile(documentWithData.documentData);
|
|
||||||
const pdfDoc = await PDFDocument.load(pdfData);
|
|
||||||
|
|
||||||
const totalPages = pdfDoc.getPageCount();
|
|
||||||
|
|
||||||
if (!includeAuditLog) {
|
|
||||||
pdfDoc.removePage(totalPages - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const pdfBytes = await pdfDoc.save();
|
|
||||||
const pdfBuffer = Buffer.from(pdfBytes).toString('base64');
|
|
||||||
|
|
||||||
return {
|
|
||||||
...documentWithData,
|
|
||||||
documentData: {
|
|
||||||
...documentWithData.documentData,
|
|
||||||
data: pdfBuffer,
|
|
||||||
initialData: documentWithData.documentData.data,
|
|
||||||
type: DocumentDataType.BYTES_64,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
} else if (includeAuditLog) {
|
|
||||||
const pdfData = await getFile(documentWithData.documentData);
|
|
||||||
const pdfDoc = await PDFDocument.load(pdfData);
|
|
||||||
|
|
||||||
const totalPages = pdfDoc.getPageCount();
|
|
||||||
|
|
||||||
if (!includeCertificate) {
|
|
||||||
pdfDoc.removePage(totalPages - 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
const pdfBytes = await pdfDoc.save();
|
|
||||||
const pdfBuffer = Buffer.from(pdfBytes).toString('base64');
|
|
||||||
|
|
||||||
return {
|
|
||||||
...documentWithData,
|
|
||||||
documentData: {
|
|
||||||
...documentWithData.documentData,
|
|
||||||
data: pdfBuffer,
|
|
||||||
initialData: documentWithData.documentData.data,
|
|
||||||
type: DocumentDataType.BYTES_64,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
} else if (!includeCertificate && !includeAuditLog) {
|
|
||||||
const pdfData = await getFile(documentWithData.documentData);
|
|
||||||
const pdfDoc = await PDFDocument.load(pdfData);
|
|
||||||
|
|
||||||
const totalPages = pdfDoc.getPageCount();
|
|
||||||
|
|
||||||
pdfDoc.removePage(totalPages - 1);
|
|
||||||
pdfDoc.removePage(totalPages - 2);
|
|
||||||
|
|
||||||
const pdfBytes = await pdfDoc.save();
|
|
||||||
const pdfBuffer = Buffer.from(pdfBytes).toString('base64');
|
|
||||||
|
|
||||||
return {
|
|
||||||
...documentWithData,
|
|
||||||
documentData: {
|
|
||||||
...documentWithData.documentData,
|
|
||||||
data: pdfBuffer,
|
|
||||||
initialData: documentWithData.documentData.data,
|
|
||||||
type: DocumentDataType.BYTES_64,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return documentWithData;
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user