Skip to content

Open-source document signature platform. Not affiliated with DocuSign.

TypeScript

Merge PR #157 (signing at the same time) by MattJackson

Claude9f7480714a03
diff --cc src/lib/envelopes.ts
index a384437,d905dc0..a0cdc29
--- a/src/lib/envelopes.ts
+++ b/src/lib/envelopes.ts
@@@ -2772,25 -2875,35 +2900,35 @@@ export async function sendDraftEnvelope
throw error;
}
- let invitationMessageId: string | undefined;
+ // The first invitation decides whether the envelope went out. If it
+ // fails, nothing has been delivered, and the envelope goes back to being
+ // a draft. Once one has been accepted the envelope is out: a later one
+ // that fails is logged, and the sender's reminder (or the automatic one)
+ // sends that signer a new link.
+ const invitationMessageIds = new Map<string, string | undefined>();
+ let branding: Branding;
try {
- invitationMessageId = (
- await emailService.send(
- buildSigningInvitationEmail({
- branding: await getBranding(),
- envelopeTitle: envelope.title,
- expiresAt,
- senderName: input.senderName,
- signerEmail: firstSigner.email,
- signerName: firstSigner.name,
- signingUrl: issuedLink.url,
- }),
- )
- ).messageId;
+ branding = await getBranding();
+ invitationMessageIds.set(
+ firstSigner.id,
+ (
+ await emailService.send(
+ buildSigningInvitationEmail({
+ branding,
+ envelopeTitle: envelope.title,
+ expiresAt,
+ senderName: input.senderName,
+ signerEmail: firstSigner.email,
+ signerName: firstSigner.name,
+ signingUrl: issuedLinks.get(firstSigner.id)!.url,
+ }),
+ )
+ ).messageId,
+ );
} catch (error) {
await withTransaction(async (tx) => {
- await tx.query(
+ const revertedEnvelope = await tx.query(
`
UPDATE envelopes
SET
diff --cc src/lib/services/pdf-finalize.ts
index 8212d2b,5926c5a..868e6df
--- a/src/lib/services/pdf-finalize.ts
+++ b/src/lib/services/pdf-finalize.ts
@@@ -10,8 -10,8 +10,9 @@@ import
import type { FieldRecord } from "../schemas/field.ts";
import type { SignerRecord } from "../schemas/signer.ts";
import { buildSignatureManifestation } from "../signature-meanings.ts";
+ import { hasSharedSigningStep, signingStepOf } from "../signing-steps.ts";
import { describeSignerCorrectedEvent } from "./audit.ts";
+import { isCapturedMessageId } from "./captured-email.ts";
import { canonicalJson } from "../utils/canonical-json.ts";
import { normalizedRectToPdfRect } from "../utils/pdf-coords.ts";
import { embedTextFaces, type TextFace } from "./pdf-fonts.ts";