From 09cc1127e88fc81648ba90700c96837574aef1b3 Mon Sep 17 00:00:00 2001 From: KMKoushik Date: Fri, 16 May 2025 23:33:58 +1000 Subject: [PATCH] fix sending true/false in html for email --- .../server/public-api/api/emails/send-email.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/web/src/server/public-api/api/emails/send-email.ts b/apps/web/src/server/public-api/api/emails/send-email.ts index e0c3970..6a87481 100644 --- a/apps/web/src/server/public-api/api/emails/send-email.ts +++ b/apps/web/src/server/public-api/api/emails/send-email.ts @@ -33,17 +33,20 @@ function send(app: PublicAPIApp) { app.openapi(route, async (c) => { const team = await getTeamFromToken(c); + let html = undefined; + + const _html = c.req.valid("json")?.html?.toString(); + + if (_html && _html !== "true" && _html !== "false") { + html = _html; + } + const email = await sendEmail({ ...c.req.valid("json"), teamId: team.id, apiKeyId: team.apiKeyId, text: c.req.valid("json").text ?? undefined, - html: - !c.req.valid("json")?.html || - c.req.valid("json")?.html === "false" || - c.req.valid("json")?.html === "true" - ? undefined - : c.req.valid("json").html?.toString(), + html: html, }); return c.json({ emailId: email?.id });