Compare commits

..

2 Commits

Author SHA1 Message Date
5cf33146fe
wip: barcode contents welcome mail 2024-12-02 17:10:11 +01:00
402684f206
add lfk logo inline 2024-12-02 17:00:15 +01:00
4 changed files with 12 additions and 27 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_url": "https://barcodeapi.org/api/8/12345670?", "barcode_content": "0123456789",
"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_url` - Variables: `name`, `link`, `barcode_content`
### Password Reset ### Password Reset
- Languages: 🇬🇧 English, 🇩🇪 German - Languages: 🇬🇧 English, 🇩🇪 German

View File

@ -17,17 +17,22 @@ const sendEmailSchema = z.object({
}) })
emailRouter.post('/', zValidator('json', sendEmailSchema), async (c) => { emailRouter.post('/', zValidator('json', sendEmailSchema), async (c) => {
const { to, subject, templateName, language, data } = c.req.valid('json') let { 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