Open-source document signature platform. Not affiliated with DocuSign.
TypeScript
Say when a partly verified domain may already be able to send
Claude3adfe9153b10
diff --git a/src/components/settings/organization-settings.tsx b/src/components/settings/organization-settings.tsxindex d456881..5b3e515 100644--- a/src/components/settings/organization-settings.tsx+++ b/src/components/settings/organization-settings.tsx@@ -559,6 +559,11 @@ function describeEmailStatus(status: EmailStatus): {return {lines: [`Add these records where ${status.domain}'s DNS is managed, then check them. DNS changes can take a few minutes to be seen, and sometimes longer.`,+ ...(status.mayAlreadySend+ ? [+ "Resend has verified part of this domain, so sending may already work. Send yourself a test email to find out. If it arrives, email is working.",+ ]+ : []),],ready: false,title: `Waiting for ${status.domain}'s DNS records`,diff --git a/src/lib/email-status.test.ts b/src/lib/email-status.test.tsindex 35ac683..131e013 100644--- a/src/lib/email-status.test.ts+++ b/src/lib/email-status.test.ts@@ -255,6 +255,8 @@ test("a domain whose records are not verified yet is pending, with its records",status.state === "domain_pending" ? status.records.length : 0,1,);+ // Nothing is verified, so there is no reason to think it can send.+ assert.equal("mayAlreadySend" in status, false);assert.deepEqual(resend.calls, ["list", "get domain_1"]);assert.deepEqual(resend.readyMarks, [false]);});@@ -483,6 +485,11 @@ test("a partly verified domain whose sending records are not all in is neither mconst status = await getEmailStatus(resend.options);assert.equal(status.state, "domain_pending");+ // The page then says that a test email is what settles it.+ assert.equal(+ status.state === "domain_pending" && status.mayAlreadySend,+ true,+ );assert.deepEqual(resend.readyMarks, []);});diff --git a/src/lib/email-status.ts b/src/lib/email-status.tsindex ab20ea2..92454c4 100644--- a/src/lib/email-status.ts+++ b/src/lib/email-status.ts@@ -50,6 +50,12 @@ export type EmailStatus =| {state: "domain_pending";domain: string;+ /**+ * Set when Resend has verified part of the domain and the records do+ * not say whether sending is the part that works. Only a test email+ * can tell then.+ */+ mayAlreadySend?: true;records: EmailDnsRecord[];senderAddress: string;}@@ -260,13 +266,14 @@ async function describeDomain(}// When it cannot be told, the mark is left as it is. A test email that- // gets through is what sets it then.+ // gets through is what sets it then, and the status says so.if (sending === "not_ready") {await markReady(false);}return {domain,+ ...(sending === "unknown" ? { mayAlreadySend: true as const } : {}),records: toDnsRecords(details.data.records),senderAddress,state: "domain_pending",