Compare commits

...

2 Commits

Author SHA1 Message Date
David Nguyen
e52aa8a12d fix: test 2023-09-20 14:21:08 +10:00
David Nguyen
3361acdef3 fix: test 2023-09-20 13:59:14 +10:00
2 changed files with 73 additions and 63 deletions

View File

@@ -1,3 +1,5 @@
TEST
<p align="center" style="margin-top: 120px"> <p align="center" style="margin-top: 120px">
<a href="https://github.com/documenso/documenso"> <a href="https://github.com/documenso/documenso">
<img width="250px" src="https://github.com/documenso/documenso/assets/1309312/cd7823ec-4baa-40b9-be78-4acb3b1c73cb" alt="Documenso Logo"> <img width="250px" src="https://github.com/documenso/documenso/assets/1309312/cd7823ec-4baa-40b9-be78-4acb3b1c73cb" alt="Documenso Logo">
@@ -20,7 +22,7 @@
</p> </p>
<p align="center"> <p align="center">
<a href="https://documen.so/discord"><img src="https://img.shields.io/badge/Discord-documen.so/discord-%235865F2" alt="Join Documenso on Discord"></a> <a href="https://documen.so/discord"><img src="https://img.shields.io/badge/Discord-documen.so/discord-%235865F2" alt="Join Documenso on Discord"></a>
<a href="https://github.com/documenso/documenso/stargazers"><img src="https://img.shields.io/github/stars/documenso/documenso" alt="Github Stars"></a> <a href="https://github.com/documenso/documenso/stargazers"><img src="https://img.shields.io/github/stars/documenso/documenso" alt="Github Stars"></a>
<a href="https://github.com/documenso/documenso/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-AGPLv3-purple" alt="License"></a> <a href="https://github.com/documenso/documenso/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-AGPLv3-purple" alt="License"></a>
<a href="https://github.com/documenso/documenso/pulse"><img src="https://img.shields.io/github/commit-activity/m/documenso/documenso" alt="Commits-per-month"></a> <a href="https://github.com/documenso/documenso/pulse"><img src="https://img.shields.io/github/commit-activity/m/documenso/documenso" alt="Commits-per-month"></a>
@@ -227,11 +229,12 @@ docker run -d --restart=unless-stopped -p 3000:3000 -v documenso:/app/data --nam
``` ```
Command Breakdown: Command Breakdown:
- `-d` - Let's you run the container in background - `-d` - Let's you run the container in background
- `-p` - Passes down which ports to use. First half is the host port, Second half is the app port. You can change the first half anything you want and reverse proxy to that port. - `-p` - Passes down which ports to use. First half is the host port, Second half is the app port. You can change the first half anything you want and reverse proxy to that port.
- `-v` - Volume let's you persist the data - `-v` - Volume let's you persist the data
- `--name` - Name of the container - `--name` - Name of the container
- `documenso:latest` - Image you have built - `documenso:latest` - Image you have built
# Deployment # Deployment
@@ -277,5 +280,5 @@ containers:
- start - start
- -- - --
- -H - -H
- "::" - '::'
``` ```

View File

@@ -89,77 +89,84 @@ export const createSinglePlayerDocument = async (
const pdfBytes = await doc.save(); const pdfBytes = await doc.save();
const documentToken = await prisma.$transaction(async (tx) => { const documentToken = await prisma.$transaction(
const documentToken = nanoid(); async (tx) => {
const documentToken = nanoid();
// Fetch service user who will be the owner of the document. // Fetch service user who will be the owner of the document.
const serviceUser = await tx.user.findFirstOrThrow({ const serviceUser = await tx.user.findFirstOrThrow({
where: { where: {
email: SERVICE_USER_EMAIL, email: SERVICE_USER_EMAIL,
}, },
}); });
const documentDataBytes = Buffer.from(pdfBytes).toString('base64'); const documentDataBytes = Buffer.from(pdfBytes).toString('base64');
const { id: documentDataId } = await tx.documentData.create({ const { id: documentDataId } = await tx.documentData.create({
data: { data: {
type: DocumentDataType.BYTES_64, type: DocumentDataType.BYTES_64,
data: documentDataBytes, data: documentDataBytes,
initialData: documentDataBytes, initialData: documentDataBytes,
}, },
}); });
// Create document. // Create document.
const document = await tx.document.create({ const document = await tx.document.create({
data: { data: {
title: documentName, title: documentName,
status: DocumentStatus.COMPLETED, status: DocumentStatus.COMPLETED,
documentDataId, documentDataId,
userId: serviceUser.id, userId: serviceUser.id,
createdAt, createdAt,
}, },
}); });
// Create recipient. // Create recipient.
const recipient = await tx.recipient.create({ const recipient = await tx.recipient.create({
data: { data: {
documentId: document.id, documentId: document.id,
name: signer.name, name: signer.name,
email: signer.email, email: signer.email,
token: documentToken, token: documentToken,
signedAt: createdAt, signedAt: createdAt,
readStatus: ReadStatus.OPENED, readStatus: ReadStatus.OPENED,
signingStatus: SigningStatus.SIGNED, signingStatus: SigningStatus.SIGNED,
sendStatus: SendStatus.SENT, sendStatus: SendStatus.SENT,
}, },
}); });
// Create fields and signatures. // Create fields and signatures.
await Promise.all( await Promise.all(
fields.map(async (field) => { fields.map(async (field) => {
const insertedField = await tx.field.create({ const insertedField = await tx.field.create({
data: {
documentId: document.id,
recipientId: recipient.id,
...mapField(field, signer),
},
});
if (field.type === FieldType.SIGNATURE || field.type === FieldType.FREE_SIGNATURE) {
await tx.signature.create({
data: { data: {
fieldId: insertedField.id, documentId: document.id,
signatureImageAsBase64,
typedSignature,
recipientId: recipient.id, recipientId: recipient.id,
...mapField(field, signer),
}, },
}); });
}
}),
);
return documentToken; if (field.type === FieldType.SIGNATURE || field.type === FieldType.FREE_SIGNATURE) {
}); await tx.signature.create({
data: {
fieldId: insertedField.id,
signatureImageAsBase64,
typedSignature,
recipientId: recipient.id,
},
});
}
}),
);
return documentToken;
},
// Test values.
{
maxWait: 30000,
timeout: 30000,
},
);
// Todo: Handle `downloadLink` // Todo: Handle `downloadLink`
const template = createElement(DocumentSelfSignedEmailTemplate, { const template = createElement(DocumentSelfSignedEmailTemplate, {