Skip to content

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

TypeScript

Check again under the lock that a reminder's envelope is not embedded

Claude69bda5b08f03
diff --git a/src/lib/reminders.ts b/src/lib/reminders.ts
index 9f34b1a..39eb2b7 100644
--- a/src/lib/reminders.ts
+++ b/src/lib/reminders.ts
@@ -38,6 +38,7 @@ import {
import { escapeHtml } from "./utils/html.ts";
type ReminderEnvelopeRow = {
+ delivery: "email" | "embedded";
expiresAt: number | null;
id: string;
ownerEmail: string;
@@ -157,6 +158,7 @@ async function getReminderEnvelope(
e.user_id AS "userId",
e.title,
e.status,
+ e.delivery,
e.expires_at AS "expiresAt",
e.reminder_interval_days AS "reminderIntervalDays",
e.updated_at AS "updatedAt",
@@ -344,6 +346,16 @@ async function persistReminder(
);
}
+ // Checked again under the lock: the envelope may have been sent for
+ // another app to sign since the early check, and a reminder would
+ // retire the link that app holds.
+ if (persistedEnvelope.delivery === "embedded") {
+ throw new ReminderMutationError(
+ "This envelope is signed in another app, so SignuDoc does not email its signers.",
+ 409,
+ );
+ }
+
// The deadline may have been moved since the link was issued. From
// here on it cannot be: the envelope's row is locked.
if (persistedEnvelope.expiresAt !== envelope.expiresAt) {