Skip to content

Commit 35d20bd

Browse files
authored
Merge pull request #398 from OpenSignLabs/api-v1-beta
feat: add Send in order to send mail sequentially for signing document
2 parents aaa3dfc + 97983c4 commit 35d20bd

File tree

12 files changed

+385
-164
lines changed

12 files changed

+385
-164
lines changed

apps/OpenSign/src/routes/Form.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ const Forms = (props) => {
3434
Name: "",
3535
Description: "",
3636
Note: "Please review and sign this document",
37-
TimeToCompleteDays: 15
37+
TimeToCompleteDays: 15,
38+
SendinOrder: "false"
3839
});
3940
const [fileupload, setFileUpload] = useState([]);
4041
const [fileload, setfileload] = useState(false);
@@ -161,6 +162,8 @@ const Forms = (props) => {
161162
"TimeToCompleteDays",
162163
parseInt(formData?.TimeToCompleteDays)
163164
);
165+
const isChecked = formData.SendinOrder === "true" ? true : false;
166+
object.set("SendinOrder", isChecked);
164167
}
165168
object.set("URL", fileupload);
166169
object.set("CreatedBy", Parse.User.createWithoutData(currentUser.id));
@@ -365,6 +368,32 @@ const Forms = (props) => {
365368
/>
366369
</div>
367370
)}
371+
{props.title !== "Sign Yourself" && (
372+
<div className="text-xs mt-2">
373+
<label className="block">Send In Order</label>
374+
<div className="flex items-center gap-2 ml-2 mb-1">
375+
<input
376+
type="radio"
377+
value={"true"}
378+
name="SendinOrder"
379+
checked={formData.SendinOrder === "true"}
380+
className=""
381+
onChange={handleStrInput}
382+
/>
383+
<div className="text-center">Yes</div>
384+
</div>
385+
<div className="flex items-center gap-2 ml-2 mb-1">
386+
<input
387+
type="radio"
388+
value={"false"}
389+
name="SendinOrder"
390+
checked={formData.SendinOrder === "false"}
391+
onChange={handleStrInput}
392+
/>
393+
<div className="text-center">No</div>
394+
</div>
395+
</div>
396+
)}
368397
<div className="flex items-center mt-3 gap-2 text-white">
369398
<button
370399
className={`${

apps/OpenSignServer/cloud/customRoute/v1/routes/CreateDocumentWithTemplate.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ export default async function createDocumentWithTemplate(request, response) {
5454
const send_email = request.body.send_email;
5555
const email_subject = request.body.email_subject;
5656
const email_body = request.body.email_body;
57+
const sendInOrder = request.body.sendInOrder || false;
58+
5759
try {
5860
const reqToken = request.headers['x-api-token'];
5961
if (!reqToken) {
@@ -101,7 +103,11 @@ export default async function createDocumentWithTemplate(request, response) {
101103
object.set('Description', template.Description);
102104
}
103105
object.set('IsSendMail', send_email);
104-
106+
if (sendInOrder) {
107+
object.set('SendinOrder', sendInOrder);
108+
} else if (template?.SendinOrder && template?.SendinOrder) {
109+
object.set('SendinOrder', template?.SendinOrder);
110+
}
105111
let templateSigner = template?.Signers ? template?.Signers : [];
106112
let contact = [];
107113
if (signers && signers.length > 0) {
@@ -196,6 +202,9 @@ export default async function createDocumentWithTemplate(request, response) {
196202
console.log("don't send mail");
197203
} else {
198204
for (let i = 0; i < contact.length; i++) {
205+
if (sendInOrder) {
206+
contact.splice(1);
207+
}
199208
try {
200209
const imgPng = 'https://qikinnovation.ams3.digitaloceanspaces.com/logo.png';
201210
let url = `${process.env.SERVER_URL}/functions/sendmailv3/`;

apps/OpenSignServer/cloud/customRoute/v1/routes/createDocument.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default async function createDocument(request, response) {
1111
const base64File = request.body.file;
1212
const send_email = request.body.send_email || true;
1313
const fileData = request.files?.[0] ? request.files[0].buffer : null;
14+
const SendinOrder = request.body.sendInOrder || false;
1415
// console.log('fileData ', fileData);
1516
const protocol = customAPIurl();
1617

@@ -69,6 +70,9 @@ export default async function createDocument(request, response) {
6970
if (description) {
7071
object.set('Description', description);
7172
}
73+
if (SendinOrder) {
74+
object.set('SendinOrder', SendinOrder);
75+
}
7276
object.set('URL', fileUrl);
7377
object.set('CreatedBy', userPtr);
7478
object.set('ExtUserPtr', extUserPtr);

apps/OpenSignServer/cloud/customRoute/v1/routes/createDocumentwithCoordinate.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export default async function createDocumentwithCoordinate(request, response) {
5757
const fileData = request.files?.[0] ? request.files[0].buffer : null;
5858
const email_subject = request.body.email_subject;
5959
const email_body = request.body.email_body;
60+
const sendInOrder = request.body.sendInOrder || false;
6061
// console.log('fileData ', fileData);
6162
const protocol = customAPIurl();
6263
const baseUrl = new URL(process.env.SERVER_URL);
@@ -112,6 +113,9 @@ export default async function createDocumentwithCoordinate(request, response) {
112113
if (description) {
113114
object.set('Description', description);
114115
}
116+
if (sendInOrder) {
117+
object.set('SendinOrder', sendInOrder);
118+
}
115119
object.set('URL', fileUrl);
116120
object.set('CreatedBy', userPtr);
117121
object.set('ExtUserPtr', extUserPtr);
@@ -248,6 +252,9 @@ export default async function createDocumentwithCoordinate(request, response) {
248252
if (send_email === false) {
249253
console.log("don't send mail");
250254
} else {
255+
if (sendInOrder) {
256+
contact.splice(1);
257+
}
251258
for (let i = 0; i < contact.length; i++) {
252259
try {
253260
const imgPng = 'https://qikinnovation.ams3.digitaloceanspaces.com/logo.png';

apps/OpenSignServer/cloud/customRoute/v1/routes/createTemplate.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default async function createTemplate(request, response) {
88
const signers = request.body?.signers;
99
const folderId = request.body?.folderId;
1010
const base64File = request.body.file;
11+
const SendinOrder = request.body.sendInOrder || false;
1112
const fileData = request.files?.[0] ? request.files[0].buffer : null;
1213
const baseUrl = new URL(process.env.SERVER_URL);
1314

@@ -61,6 +62,9 @@ export default async function createTemplate(request, response) {
6162
object.set('URL', fileUrl);
6263
object.set('CreatedBy', userPtr);
6364
object.set('ExtUserPtr', extUserPtr);
65+
if (SendinOrder) {
66+
object.set('SendinOrder', SendinOrder);
67+
}
6468
if (signers && signers.length > 0) {
6569
let parseSigners;
6670
if (base64File) {

apps/OpenSignServer/cloud/customRoute/v1/routes/createTemplatewithCoordinate.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default async function createTemplatewithCoordinate(request, response) {
1010
const folderId = request.body.folderId;
1111
const base64File = request.body.file;
1212
const fileData = request.files?.[0] ? request.files[0].buffer : null;
13+
const SendinOrder = request.body.sendInOrder || false;
1314
// console.log('fileData ', fileData);
1415
const protocol = customAPIurl();
1516

@@ -63,6 +64,9 @@ export default async function createTemplatewithCoordinate(request, response) {
6364
if (description) {
6465
object.set('Description', description);
6566
}
67+
if (SendinOrder) {
68+
object.set('SendinOrder', SendinOrder);
69+
}
6670
object.set('URL', fileUrl);
6771
object.set('CreatedBy', userPtr);
6872
object.set('ExtUserPtr', extUserPtr);

apps/OpenSignServer/cloud/parsefunction/pdf/PDF.min.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ async function sendMail(e) {
5555
html:
5656
"<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /></head><body> <div style='background-color:#f5f5f5;padding:20px'> <div style='box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;background-color:white;'> <div><img src=https://qikinnovation.ams3.digitaloceanspaces.com/logo.png height='50' style='padding:20px'/> </div><div style='padding:2px;font-family:system-ui; background-color: #47a3ad;'> <p style='font-size:20px;font-weight:400;color:white;padding-left:20px',> Document Copy</p></div><div><p style='padding:20px;font-family:system-ui;font-size:14px'>A copy of the document " +
5757
s +
58-
' Standard is attached to this email. Kindly download the document from the attachment.</p></div> </div><div><p>This is an automated email from Open Sign. For any queries regarding this email, please contact the sender ' +
58+
' Standard is attached to this email. Kindly download the document from the attachment.</p></div> </div><div><p>This is an automated email from OpenSign™. For any queries regarding this email, please contact the sender ' +
5959
t.Mail +
60-
' directly. If you think this email is inappropriate or spam, you may file a complaint with Open Sign <a href=www.opensignlabs.com target=_blank>here</a>.</p></div></div></body></html>',
60+
' directly. If you think this email is inappropriate or spam, you may file a complaint with OpenSign™ <a href=www.opensignlabs.com target=_blank>here</a>.</p></div></div></body></html>',
6161
};
6262
await axios.post(serverUrl + '/functions/sendmailv3', a, {
6363
headers: {
@@ -80,9 +80,9 @@ async function sendCompletedMail(e) {
8080
html:
8181
"<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /></head><body> <div style='background-color:#f5f5f5;padding:20px'> <div style='box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;background-color:white;'> <div><img src=https://qikinnovation.ams3.digitaloceanspaces.com/logo.png height='50' style='padding:20px'/> </div><div style='padding:2px;font-family:system-ui; background-color: #47a3ad;'> <p style='font-size:20px;font-weight:400;color:white;padding-left:20px',> Document sign successfully</p></div><div><p style='padding:20px;font-family:system-ui;font-size:14px'>All parties have successfully signed the document" +
8282
s +
83-
'. Kindly download the document from the attachment.</p></div> </div><div><p>This is an automated email from Open Sign. For any queries regarding this email, please contact the sender ' +
83+
'. Kindly download the document from the attachment.</p></div> </div><div><p>This is an automated email from OpenSign™. For any queries regarding this email, please contact the sender ' +
8484
t.Mail +
85-
' directly. If you think this email is inappropriate or spam, you may file a complaint with Open Sign <a href=www.opensignlabs.com target=_blank>here</a>.</p></div></div></body></html>',
85+
' directly. If you think this email is inappropriate or spam, you may file a complaint with OpenSign™ <a href=www.opensignlabs.com target=_blank>here</a>.</p></div></div></body></html>',
8686
};
8787
await axios.post(serverUrl + '/functions/sendmailv3', a, {
8888
headers: {
@@ -238,13 +238,13 @@ async function PDF(i, n) {
238238
v && 0 < v.length
239239
? plainAddPlaceholder({
240240
pdfBuffer: e,
241-
reason: 'Digitally signed by Open sign for ' + v?.join(', '),
241+
reason: 'Digitally signed by OpenSign for ' + v?.join(', '),
242242
location: 'location',
243243
signatureLength: 1e4,
244244
})
245245
: plainAddPlaceholder({
246246
pdfBuffer: e,
247-
reason: 'Digitally signed by Open sign for ' + m + ' <' + g + '>',
247+
reason: 'Digitally signed by OpenSign for ' + m + ' <' + g + '>',
248248
location: 'location',
249249
signatureLength: 1e4,
250250
})),

0 commit comments

Comments
 (0)