Compare commits

..

No commits in common. "5cf33146fe45ffa761963189c442780d02cbb392" and "57d4a095a405ed5fc8b7abb5aa2bee9881e6f959" have entirely different histories.

4 changed files with 27 additions and 12 deletions

View File

@ -39,7 +39,7 @@ curl -X POST http://localhost:3000/api/v1/email \
"language": "en", "language": "en",
"data": { "data": {
"name": "John Doe", "name": "John Doe",
"barcode_content": "0123456789", "barcode_url": "https://barcodeapi.org/api/8/12345670?",
"link": "https://portal.lauf-fuer-kaya.de/" "link": "https://portal.lauf-fuer-kaya.de/"
} }
}' }'
@ -95,7 +95,7 @@ The project uses:
### Welcome Email ### Welcome Email
- Languages: 🇬🇧 English, 🇩🇪 German - Languages: 🇬🇧 English, 🇩🇪 German
- Variables: `name`, `link`, `barcode_content` - Variables: `name`, `link`, `barcode_url`
### Password Reset ### Password Reset
- Languages: 🇬🇧 English, 🇩🇪 German - Languages: 🇬🇧 English, 🇩🇪 German

View File

@ -17,22 +17,17 @@ const sendEmailSchema = z.object({
}) })
emailRouter.post('/', zValidator('json', sendEmailSchema), async (c) => { emailRouter.post('/', zValidator('json', sendEmailSchema), async (c) => {
let { to, subject, templateName, language, data } = c.req.valid('json') const { to, subject, templateName, language, data } = c.req.valid('json')
try { try {
const template = getEmailTemplate(templateName, language as Language) const template = getEmailTemplate(templateName, language as Language)
if (templateName === "welcome") {
if (data.barcode_content === "0123456789") {
data.barcode_url = "https://barcodeapi.org/api/128/0123456789?"
}
}
await emailService.sendEmail({ await emailService.sendEmail({
to, to,
subject, subject,
html: template.html(data), html: template.html(data),
text: template.text(data) text: template.text(data)
}) })
return c.json({ success: true }) return c.json({ success: true })
} catch (error) { } catch (error) {
return c.json({ success: false, error: (error as Error).message }, 400) return c.json({ success: false, error: (error as Error).message }, 400)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long