IO-2433 Delete on cancel, improved styling.
This commit is contained in:
@@ -85,8 +85,14 @@ async function handleDocumentCompleted(payload = sampleComplete) {
|
||||
|
||||
//Check if the bodyshop is on image proxy or not
|
||||
try {
|
||||
//Split the external id to get the uploaded user.
|
||||
const [jobid, uploaded_by] = payload.externalId.split("|");
|
||||
|
||||
if (!jobid || !uploaded_by) {
|
||||
throw new Error(`Invalid externalId format. Expected "jobid|uploaded_by", got "${payload.externalId}"`);
|
||||
}
|
||||
const { jobs_by_pk } = await client.request(QUERY_META_FOR_ESIG_COMPLETION, {
|
||||
jobid: payload.externalId
|
||||
jobid
|
||||
});
|
||||
const document = await documenso.document.documentDownload({
|
||||
documentId: payload.id,
|
||||
@@ -97,25 +103,24 @@ async function handleDocumentCompleted(payload = sampleComplete) {
|
||||
const buffer = Buffer.from(arrayBuffer);
|
||||
|
||||
|
||||
let key = `${jobs_by_pk.bodyshop.id}/${jobs_by_pk.id}/${replaceAccents(document.filename).replace(/[^A-Z0-9]+/gi, "_")}-${new Date().getTime()}.pdf`;
|
||||
|
||||
if (jobs_by_pk?.bodyshop?.uselocalmediaserver) {
|
||||
//LMS not yet implemented.
|
||||
|
||||
} else {
|
||||
//S3 Upload
|
||||
let key = `${jobs_by_pk.bodyshop.id}/${jobs_by_pk.id}/${replaceAccents(document.filename).replace(/[^A-Z0-9]+/gi, "_")}-${new Date().getTime()}.pdf`;
|
||||
|
||||
const uploadResult = await uploadFileBuffer({ key, buffer, contentType: "application/pdf" });
|
||||
if (!uploadResult.success) {
|
||||
logger.log(`esig-webhook-s3-upload-error`, "ERROR", "redis", "api", {
|
||||
message: uploadResult.message,
|
||||
stack: uploadResult.stack,
|
||||
jobid: payload.externalId,
|
||||
jobid: jobid,
|
||||
documentId: payload.id
|
||||
});
|
||||
} else {
|
||||
logger.log(`esig-webhook-s3-upload-success`, "INFO", "redis", "api", {
|
||||
jobid: payload.externalId,
|
||||
jobid: jobid,
|
||||
documentId: payload.id,
|
||||
s3Key: key,
|
||||
bucket: uploadResult.bucket
|
||||
@@ -125,7 +130,7 @@ async function handleDocumentCompleted(payload = sampleComplete) {
|
||||
jobid: jobs_by_pk.id,
|
||||
bodyshopid: jobs_by_pk.bodyshop.id,
|
||||
operation: `Esignature document with title ${payload.title} (ID: ${payload.documentMeta.id}) has been completed.`,
|
||||
useremail: "patrick@imex.dev", //TODO: Figure out the hardcoded bypass.
|
||||
useremail: uploaded_by,
|
||||
type: 'esig-complete'
|
||||
}
|
||||
})
|
||||
@@ -133,12 +138,12 @@ async function handleDocumentCompleted(payload = sampleComplete) {
|
||||
await client.request(INSERT_ESIGNATURE_DOCUMENT, {
|
||||
docInput: {
|
||||
jobid: jobs_by_pk.id,
|
||||
uploaded_by: "patrick@imex.dev", //TODO: Figure out the hard coded bypass.
|
||||
uploaded_by: uploaded_by,
|
||||
key,
|
||||
type: "application/pdf",
|
||||
extension: "pdf",
|
||||
bodyshopid: jobs_by_pk.bodyshop.id,
|
||||
size: buffer.length, //Leftover from Cloudinary. We don't do any optimization on upload, so it will always be file.size.
|
||||
size: buffer.length,
|
||||
takenat: new Date().toISOString(),
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user