From 2885fea077fadaf60694628a7bffd553ba6571cc Mon Sep 17 00:00:00 2001 From: cameronapak Date: Tue, 11 Nov 2025 08:30:26 -0600 Subject: [PATCH] Remove multi-recipient support from Plunk driver --- app/src/core/drivers/email/plunk.spec.ts | 37 ------------------------ app/src/core/drivers/email/plunk.ts | 30 ++----------------- 2 files changed, 3 insertions(+), 64 deletions(-) diff --git a/app/src/core/drivers/email/plunk.spec.ts b/app/src/core/drivers/email/plunk.spec.ts index 4296570..82fb544 100644 --- a/app/src/core/drivers/email/plunk.spec.ts +++ b/app/src/core/drivers/email/plunk.spec.ts @@ -52,41 +52,4 @@ describe.skipIf(ALL_TESTS)("plunk", () => { expect(response).toBeDefined(); expect(response.success).toBe(true); }); - - it("should send to multiple recipients", async () => { - const driver = plunkEmail({ - apiKey: process.env.PLUNK_API_KEY!, - from: undefined, - }); - const response = await driver.send( - "help@bknd.io", - "Multi-recipient Test", - "Test email to multiple recipients", - { - to: ["help@bknd.io", "cameronandrewpak@gmail.com"], - }, - ); - expect(response).toBeDefined(); - expect(response.success).toBe(true); - expect(response.emails).toHaveLength(2); - }); - - it("should throw error for more than 5 recipients", async () => { - const driver = plunkEmail({ - apiKey: process.env.PLUNK_API_KEY!, - from: undefined, - }); - expect( - driver.send("help@bknd.io", "Test", "Test", { - to: [ - "help@bknd.io", - "test2@example.com", - "test3@example.com", - "test4@example.com", - "test5@example.com", - "test6@example.com", - ], - }), - ).rejects.toThrow("Plunk supports a maximum of 5 recipients per email"); - }); }); diff --git a/app/src/core/drivers/email/plunk.ts b/app/src/core/drivers/email/plunk.ts index 6e75734..a3c7761 100644 --- a/app/src/core/drivers/email/plunk.ts +++ b/app/src/core/drivers/email/plunk.ts @@ -7,7 +7,6 @@ export type PlunkEmailOptions = { }; export type PlunkEmailSendOptions = { - to?: string | string[]; subscribed?: boolean; name?: string; from?: string; @@ -40,48 +39,25 @@ export const plunkEmail = ( body: string | { text: string; html: string }, options?: PlunkEmailSendOptions, ) => { - // Determine recipients - options.to takes precedence if provided - const recipients = options?.to ?? to; - - // Validate recipient count (Plunk max is 5) - const recipientArray = Array.isArray(recipients) - ? recipients - : [recipients]; - if (recipientArray.length > 5) { - throw new Error( - "Plunk supports a maximum of 5 recipients per email", - ); - } - - // Build base payload const payload: any = { - to: recipients, + from, + to, subject, }; - // Handle body - Plunk only accepts a single body field if (typeof body === "string") { payload.body = body; } else { - // When both text and html are provided, send html (degrades gracefully) payload.body = body.html; } - // Add optional fields from config - if (from) { - payload.from = from; - } - - // Merge with additional options (excluding 'to' since we already handled it) - const { to: _, ...restOptions } = options ?? {}; - const res = await fetch(host, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${config.apiKey}`, }, - body: JSON.stringify({ ...payload, ...restOptions }), + body: JSON.stringify({ ...payload, ...options }), }); if (!res.ok) {