Skip to content

Commit

Permalink
Fix out mailer for svelte 5
Browse files Browse the repository at this point in the history
  • Loading branch information
scosman committed Nov 1, 2024
1 parent 5843a8a commit 54de971
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/lib/mailer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { PRIVATE_SUPABASE_SERVICE_ROLE } from "$env/static/private"
import { PUBLIC_SUPABASE_URL } from "$env/static/public"
import { createClient, type User } from "@supabase/supabase-js"
import type { Database } from "../DatabaseDefinitions"
import { render } from "svelte/server"

// Sends an email to the admin email address.
// Does not throw errors, but logs them.
Expand Down Expand Up @@ -123,8 +124,8 @@ export const sendTemplatedEmail = async ({
const emailTemplate = await import(
`./emails/${template_name}_text.svelte`
).then((mod) => mod.default)
const { html } = emailTemplate.render(template_properties)
plaintextBody = html
const { body } = render(emailTemplate, { props: template_properties })
plaintextBody = body.replace(/<!--[\s\S]*?-->/g, "")
} catch (e) {
// ignore, plaintextBody is optional
plaintextBody = undefined
Expand All @@ -135,8 +136,8 @@ export const sendTemplatedEmail = async ({
const emailTemplate = await import(
`./emails/${template_name}_html.svelte`
).then((mod) => mod.default)
const { html } = emailTemplate.render(template_properties)
htmlBody = html
const { body } = render(emailTemplate, { props: template_properties })
htmlBody = body
} catch (e) {
// ignore, htmlBody is optional
htmlBody = undefined
Expand Down

0 comments on commit 54de971

Please sign in to comment.