From d7b2d7074a761bc1013de8de451a2fb777275174 Mon Sep 17 00:00:00 2001 From: Aashish John Date: Tue, 6 Oct 2026 15:58:28 -0400 Subject: [PATCH] fix: pass reply to field to provider --- components/email-wizard/index.tsx | 1 + .../email-wizard/step-4-schedule-send.tsx | 1 + components/modal/send-email-modal.tsx | 4 ++ components/send-email-button.tsx | 3 ++ lib/actions/send-email.test.ts | 38 +++++++++++++++++++ lib/actions/send-email.ts | 7 ++++ 6 files changed, 54 insertions(+) diff --git a/components/email-wizard/index.tsx b/components/email-wizard/index.tsx index 2b212e8c..42a84263 100644 --- a/components/email-wizard/index.tsx +++ b/components/email-wizard/index.tsx @@ -129,6 +129,7 @@ function EmailWizardContent({ subject: formData.subject, content: formData.content, previewText: formData.previewText, + replyTo: formData.replyTo, segmentId: formData.selectedSegment || undefined, scheduledTime, organizationId, diff --git a/components/email-wizard/step-4-schedule-send.tsx b/components/email-wizard/step-4-schedule-send.tsx index 3815d3e6..34711365 100644 --- a/components/email-wizard/step-4-schedule-send.tsx +++ b/components/email-wizard/step-4-schedule-send.tsx @@ -77,6 +77,7 @@ export function Step4ScheduleSend({ subject: formData.subject, content: formData.content, previewText: formData.previewText, + replyTo: formData.replyTo, organizationId, audienceListId: formData.audienceListId || undefined, }); diff --git a/components/modal/send-email-modal.tsx b/components/modal/send-email-modal.tsx index bd6fef56..92cfb742 100644 --- a/components/modal/send-email-modal.tsx +++ b/components/modal/send-email-modal.tsx @@ -31,6 +31,7 @@ interface SendEmailModalProps { subject: string; previewText: string; from: string; + replyTo?: string | null; content: string; emailId: string; audienceListId?: string | null; @@ -48,6 +49,7 @@ export function SendEmailModal({ subject, previewText, from, + replyTo, content, emailId, audienceListId: audienceListIdProp, @@ -89,6 +91,7 @@ export function SendEmailModal({ subject, content, previewText, + replyTo, organizationId, audienceListId: audienceListIdProp || selectedAudienceList || undefined, }); @@ -135,6 +138,7 @@ export function SendEmailModal({ subject, content, previewText, + replyTo, scheduledTime: mode === "now" ? "" : when, id: emailId, organizationId, diff --git a/components/send-email-button.tsx b/components/send-email-button.tsx index b2fa748e..73eff3cc 100644 --- a/components/send-email-button.tsx +++ b/components/send-email-button.tsx @@ -21,6 +21,7 @@ interface SendEmailButtonProps { subject: string; previewText: string; from: string; + replyTo?: string | null; content: string; emailId: string; onSent?: () => void; @@ -40,6 +41,7 @@ export default function SendEmailButton({ subject, previewText, from, + replyTo, content, emailId, onConfirm, @@ -60,6 +62,7 @@ export default function SendEmailButton({ subject={subject} previewText={previewText} from={from} + replyTo={replyTo} content={content} emailId={emailId} onConfirm={(scheduledTime) => { diff --git a/lib/actions/send-email.test.ts b/lib/actions/send-email.test.ts index 8e301d46..c1db658e 100644 --- a/lib/actions/send-email.test.ts +++ b/lib/actions/send-email.test.ts @@ -355,6 +355,44 @@ describe("sendBulkEmail SES scheduling", () => { expect(delayMs).toBeLessThanOrEqual(24 * 60 * 60 * 1000 + 5000); }); + test("passes replyTo into queued job data", async () => { + const { sendBulkEmail } = await import("@/lib/actions/send-email"); + const scheduledTime = new Date(Date.now() + 60 * 60 * 1000).toISOString(); + + await sendBulkEmail({ + id: "email-1", + organizationId: "org-1", + from: "Sender", + subject: "Subject", + content: null, + previewText: null, + replyTo: " replies@example.com ", + scheduledTime, + }); + + const [jobs] = mockQueueBulkEmails.mock.calls[0]; + expect(jobs[0].replyTo).toBe("replies@example.com"); + }); + + test("omits replyTo from queued job data when it is whitespace only", async () => { + const { sendBulkEmail } = await import("@/lib/actions/send-email"); + const scheduledTime = new Date(Date.now() + 60 * 60 * 1000).toISOString(); + + await sendBulkEmail({ + id: "email-1", + organizationId: "org-1", + from: "Sender", + subject: "Subject", + content: null, + previewText: null, + replyTo: " ", + scheduledTime, + }); + + const [jobs] = mockQueueBulkEmails.mock.calls[0]; + expect(jobs[0].replyTo).toBeUndefined(); + }); + test("saves scheduledJobIds to database when all jobs queued", async () => { const { default: prisma } = await import("@/lib/prisma"); const { sendBulkEmail } = await import("@/lib/actions/send-email"); diff --git a/lib/actions/send-email.ts b/lib/actions/send-email.ts index 6e662878..46c78176 100644 --- a/lib/actions/send-email.ts +++ b/lib/actions/send-email.ts @@ -165,6 +165,7 @@ export type SendEmailOpts = { react?: React.ReactElement; organizationId?: string; audienceListId?: string | null; + replyTo?: string | null; }; export const sendEmail = async ({ @@ -177,6 +178,7 @@ export const sendEmail = async ({ react, organizationId, audienceListId, + replyTo, }: SendEmailOpts) => { const { client, @@ -268,6 +270,7 @@ export const sendEmail = async ({ subject: subject || "No Subject", html: htmlContent, text: previewText ?? "", + replyTo: replyTo?.trim() || undefined, }); if (result.error) { @@ -296,6 +299,7 @@ export const sendBulkEmail = async ({ id, organizationId, segmentId, + replyTo, }: { audienceListId?: string | null; from: string; @@ -306,6 +310,7 @@ export const sendBulkEmail = async ({ id: string; organizationId: string; segmentId?: string | null; + replyTo?: string | null; }) => { const session = await getSession(); if (!session?.user.id) return { error: "Not authenticated" }; @@ -465,6 +470,7 @@ export const sendBulkEmail = async ({ subject: subject || "No Subject", html: htmlContent || "", text: previewText ?? "", + replyTo: replyTo?.trim() || undefined, organizationId, provider, awsRegion, @@ -536,6 +542,7 @@ export const sendBulkEmail = async ({ subject: subject || "No Subject", html: htmlContent || "", text: previewText ?? "", + replyTo: replyTo?.trim() || undefined, tags: [ { name: "intrepidId", value: id }, { name: "userId", value: session.user.id },