Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
f9a202db55
|
|||
|
92fc5762e4
|
|||
|
326b241dab
|
|||
|
a7a50ff59d
|
|||
|
4257686f35
|
|||
|
2f25937a94
|
28
.gitea/workflows/dev.yaml
Normal file
28
.gitea/workflows/dev.yaml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
name: Build Latest image
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-container:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Login to registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: registry.odit.services
|
||||||
|
username: ${{ vars.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ vars.REGISTRY }}/lfk/mailer:dev
|
||||||
|
${{ vars.REGISTRY }}/lfk/mailer:latest
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
27
.gitea/workflows/release.yaml
Normal file
27
.gitea/workflows/release.yaml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
name: Build release images
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "*.*.*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-container:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Login to registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: registry.odit.services
|
||||||
|
username: ${{ vars.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ vars.REGISTRY }}/lfk/mailer:${{ github.ref_name }}
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
steps:
|
|
||||||
- name: build dev
|
|
||||||
image: woodpeckerci/plugin-docker-buildx
|
|
||||||
settings:
|
|
||||||
repo: registry.odit.services/lfk/mailer
|
|
||||||
tags:
|
|
||||||
- dev
|
|
||||||
registry: registry.odit.services
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
cache_from: registry.odit.services/lfk/mailer:dev
|
|
||||||
username:
|
|
||||||
from_secret: odit-registry-builder-username
|
|
||||||
password:
|
|
||||||
from_secret: odit-registry-builder-password
|
|
||||||
when:
|
|
||||||
branch: dev
|
|
||||||
when:
|
|
||||||
event: push
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
steps:
|
|
||||||
- name: build tag
|
|
||||||
image: woodpeckerci/plugin-docker-buildx
|
|
||||||
settings:
|
|
||||||
repo: registry.odit.services/lfk/mailer
|
|
||||||
tags:
|
|
||||||
- "${CI_COMMIT_TAG}"
|
|
||||||
registry: registry.odit.services
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
cache_from: registry.odit.services/lfk/mailer:dev
|
|
||||||
username:
|
|
||||||
from_secret: odit-registry-builder-username
|
|
||||||
password:
|
|
||||||
from_secret: odit-registry-builder-password
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- tag
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM oven/bun:1.1.40-slim
|
FROM oven/bun:1.2.6-slim
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json .
|
COPY package.json .
|
||||||
RUN bun i
|
RUN bun i
|
||||||
|
|||||||
24
package.json
24
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@odit/lfk-mailer",
|
"name": "@odit/lfk-mailer",
|
||||||
"version": "1.2.1",
|
"version": "1.2.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -8,20 +8,20 @@
|
|||||||
"start": "bun src/index.ts"
|
"start": "bun src/index.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hono/node-server": "1.13.7",
|
"@hono/node-server": "1.14.0",
|
||||||
"@hono/swagger-ui": "0.5.0",
|
"@hono/swagger-ui": "0.5.1",
|
||||||
"@hono/zod-openapi": "0.18.3",
|
"@hono/zod-openapi": "0.19.2",
|
||||||
"@hono/zod-validator": "0.4.2",
|
"@hono/zod-validator": "0.4.3",
|
||||||
"bullmq": "5.34.3",
|
"bullmq": "5.44.4",
|
||||||
"handlebars": "4.7.8",
|
"handlebars": "4.7.8",
|
||||||
"hono": "4.6.14",
|
"hono": "4.7.5",
|
||||||
"ioredis": "5.4.1",
|
"ioredis": "5.6.0",
|
||||||
"nodemailer": "6.9.16",
|
"nodemailer": "6.10.0",
|
||||||
"zod": "3.24.1"
|
"zod": "3.24.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "22.10.2",
|
"@types/node": "22.13.14",
|
||||||
"@types/nodemailer": "6.4.17",
|
"@types/nodemailer": "6.4.17",
|
||||||
"bun-types": "1.1.40"
|
"bun-types": "1.2.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ import { createTransport } from "nodemailer";
|
|||||||
import { Queue, Worker, QueueEvents } from "bullmq";
|
import { Queue, Worker, QueueEvents } from "bullmq";
|
||||||
import { config } from "../config/env";
|
import { config } from "../config/env";
|
||||||
import Redis from "ioredis";
|
import Redis from "ioredis";
|
||||||
|
import { Attachment } from "nodemailer/lib/mailer";
|
||||||
|
|
||||||
interface EmailJob {
|
interface EmailJob {
|
||||||
to: string;
|
to: string;
|
||||||
subject: string;
|
subject: string;
|
||||||
html: string;
|
html: string;
|
||||||
|
attachments: Attachment[];
|
||||||
text: string;
|
text: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,12 +42,13 @@ const worker = new Worker<EmailJob>(
|
|||||||
QUEUE_NAME,
|
QUEUE_NAME,
|
||||||
async (job) => {
|
async (job) => {
|
||||||
await transporter.sendMail({
|
await transporter.sendMail({
|
||||||
from: config.email.from,
|
from: { address: config.email.from, name: "Lauf für Kaya!" },
|
||||||
replyTo: config.email.replyTo,
|
replyTo: config.email.replyTo,
|
||||||
to: job.data.to,
|
to: job.data.to,
|
||||||
subject: job.data.subject,
|
subject: job.data.subject,
|
||||||
text: job.data.text,
|
text: job.data.text,
|
||||||
html: job.data.html,
|
html: job.data.html,
|
||||||
|
attachments: job.data.attachments,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { z } from 'zod'
|
|||||||
import { EmailService } from '../services/email'
|
import { EmailService } from '../services/email'
|
||||||
import { getEmailTemplate } from '../templates'
|
import { getEmailTemplate } from '../templates'
|
||||||
import { Language } from '../types'
|
import { Language } from '../types'
|
||||||
|
import { Attachment } from 'nodemailer/lib/mailer'
|
||||||
|
|
||||||
const emailRouter = new Hono()
|
const emailRouter = new Hono()
|
||||||
const emailService = new EmailService()
|
const emailService = new EmailService()
|
||||||
@@ -20,9 +21,9 @@ async function generateBarcodeDataURL(data) {
|
|||||||
return `${process.env.DOCUMENT_SERVER_URL}/v1/barcodes/code128/${data}`
|
return `${process.env.DOCUMENT_SERVER_URL}/v1/barcodes/code128/${data}`
|
||||||
}
|
}
|
||||||
|
|
||||||
emailRouter.post('/', bearerAuth({ token: process.env.AUTHKEY }), zValidator('json', sendEmailSchema), async (c) => {
|
emailRouter.post('/', bearerAuth({ token: process.env.AUTHKEY || "" }), zValidator('json', sendEmailSchema), async (c) => {
|
||||||
let { to, templateName, language, data } = c.req.valid('json')
|
let { to, templateName, language, data } = c.req.valid('json')
|
||||||
|
const attachments: Attachment[] = []
|
||||||
try {
|
try {
|
||||||
const template = getEmailTemplate(templateName, language as Language)
|
const template = getEmailTemplate(templateName, language as Language)
|
||||||
if (templateName === "welcome") {
|
if (templateName === "welcome") {
|
||||||
@@ -32,6 +33,12 @@ emailRouter.post('/', bearerAuth({ token: process.env.AUTHKEY }), zValidator('js
|
|||||||
} else {
|
} else {
|
||||||
return c.json({ success: false, error: "required params 'data.name', 'data.link', 'data.barcode_content' not provided" }, 406)
|
return c.json({ success: false, error: "required params 'data.name', 'data.link', 'data.barcode_content' not provided" }, 406)
|
||||||
}
|
}
|
||||||
|
const attachment: Attachment = {
|
||||||
|
filename: 'invite.ics',
|
||||||
|
content: `BEGIN:VCALENDAR\nVERSION:2.0\nBEGIN:VEVENT\nSUMMARY:Lauf für Kaya! 2025\nDTSTART:20250523T110000Z\nDTEND:20250523T160000Z\nDTSTAMP:20250318T230306Z\nUID:lfk2025-xhJP3h\nDESCRIPTION:Der Lauf für Kaya! 2025 findet am 23.05.2025 auf dem Sportplatz des Gymnasium Herzogenaurach statt - Bürgerlauf von 14 bis 18 Uhr - Firmenlauf von 13:30 bis 18 Uhr.\nLOCATION:Sportplatz Gymnasium Herzogenaurach\nORGANIZER:info@lauf-fuer-kaya.de\nSTATUS:CONFIRMED\nPRIORITY:5\nEND:VEVENT\nEND:VCALENDAR`,
|
||||||
|
contentType: 'text/calendar; method=REQUEST',
|
||||||
|
}
|
||||||
|
attachments.push(attachment)
|
||||||
}
|
}
|
||||||
if (templateName === "password-reset") {
|
if (templateName === "password-reset") {
|
||||||
if (data.token) {
|
if (data.token) {
|
||||||
@@ -45,6 +52,7 @@ emailRouter.post('/', bearerAuth({ token: process.env.AUTHKEY }), zValidator('js
|
|||||||
data.event_name = process.env.EVENT_NAME
|
data.event_name = process.env.EVENT_NAME
|
||||||
await emailService.sendEmail({
|
await emailService.sendEmail({
|
||||||
to,
|
to,
|
||||||
|
attachments,
|
||||||
subject: template.subject(data),
|
subject: template.subject(data),
|
||||||
html: template.html(data),
|
html: template.html(data),
|
||||||
text: template.text(data)
|
text: template.text(data)
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import { emailQueue } from '../queues/email.queue'
|
import { emailQueue } from '../queues/email.queue'
|
||||||
import { config } from '../config/env'
|
import { config } from '../config/env'
|
||||||
|
import { Attachment } from 'nodemailer/lib/mailer'
|
||||||
|
|
||||||
interface EmailOptions {
|
interface EmailOptions {
|
||||||
to: string
|
to: string
|
||||||
subject: string
|
subject: string
|
||||||
html: string
|
html: string
|
||||||
|
attachments: Attachment[]
|
||||||
text: string
|
text: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -177,8 +177,9 @@
|
|||||||
>
|
>
|
||||||
Am Lauftag (<strong>{{event_date}}</strong>) musst du nur noch
|
Am Lauftag (<strong>{{event_date}}</strong>) musst du nur noch
|
||||||
diesen Barcode vorzeigen, damit erhältst du deine Läuferkarte.<br />Der
|
diesen Barcode vorzeigen, damit erhältst du deine Läuferkarte.<br />Der
|
||||||
Bürger- & Firmenlauf findet von
|
<b>Bürgerlauf</b> findet von
|
||||||
<strong>13:00 bis 18:00 Uhr</strong> statt.
|
<b>14:00 bis 18:00 Uhr</b> statt.<br />Der
|
||||||
|
<b>Firmenlauf</b> beginnt um <b>13:30 Uhr</b>.
|
||||||
</p>
|
</p>
|
||||||
<table
|
<table
|
||||||
align="center"
|
align="center"
|
||||||
@@ -287,41 +288,6 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p
|
|
||||||
style="
|
|
||||||
font-size: 15px;
|
|
||||||
line-height: 26.25px;
|
|
||||||
margin: 0 0 20px 0;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
|
||||||
-moz-osx-font-smoothing: grayscale;
|
|
||||||
color: #374151;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
Wenn der Button nicht funktioniert, kannst du diesen Link in
|
|
||||||
deinen Browser kopieren:
|
|
||||||
<code
|
|
||||||
style="
|
|
||||||
background-color: #efefef;
|
|
||||||
color: #111827;
|
|
||||||
padding: 2px 4px;
|
|
||||||
border-radius: 6px;
|
|
||||||
font-family: SFMono-Regular, Menlo, Monaco, Consolas,
|
|
||||||
'Liberation Mono', 'Courier New', monospace;
|
|
||||||
font-weight: 400;
|
|
||||||
letter-spacing: 0;
|
|
||||||
"
|
|
||||||
>{{link}}</code
|
|
||||||
>
|
|
||||||
</p>
|
|
||||||
<hr
|
|
||||||
style="
|
|
||||||
width: 100%;
|
|
||||||
border: none;
|
|
||||||
border-top: 1px solid #eaeaea;
|
|
||||||
margin-top: 32px;
|
|
||||||
margin-bottom: 32px;
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
<p
|
<p
|
||||||
style="
|
style="
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ Hallo {{name}} 👋
|
|||||||
vielen Dank für deine Registrierung beim {{event_name}}
|
vielen Dank für deine Registrierung beim {{event_name}}
|
||||||
|
|
||||||
Am Lauftag ({{event_date}}) musst du nur noch deinen Barcode vorzeigen, damit erhältst du deine Läuferkarte.
|
Am Lauftag ({{event_date}}) musst du nur noch deinen Barcode vorzeigen, damit erhältst du deine Läuferkarte.
|
||||||
|
Der Bürgerlauf findet von 14:00 bis 18:00 Uhr statt.
|
||||||
|
Der Firmenlauf beginnt um 13:30 Uhr.
|
||||||
|
|
||||||
Deinen Registrierungs-Code, Rundenzeiten und weitere Infos kannst du jederzeit im Lauf für Kaya! Selfservice unter {{link}} einsehen.
|
Deinen Registrierungs-Code, Rundenzeiten und weitere Infos kannst du jederzeit im Lauf für Kaya! Selfservice unter {{link}} einsehen.
|
||||||
|
|
||||||
Wir freuen uns schon auf dich und einen erfolgreichen Lauf für Kaya!
|
Wir freuen uns schon auf dich und einen erfolgreichen Lauf für Kaya!
|
||||||
|
|||||||
@@ -177,8 +177,9 @@
|
|||||||
>
|
>
|
||||||
On the day of the run (<strong>{{event_date}}</strong>) you only
|
On the day of the run (<strong>{{event_date}}</strong>) you only
|
||||||
have to show your barcode to receive your runner's card.<br />The
|
have to show your barcode to receive your runner's card.<br />The
|
||||||
Citizens' & Company Run will take place from
|
<b>Citizens' Run</b> takes place from
|
||||||
<strong> 1:00 p.m. to 6:00 p.m.</strong>
|
<b>2:00 PM to 6:00 PM</b>.<br />The <b>Corporate Run</b> begins at
|
||||||
|
<b>1:30 PM</b>.
|
||||||
</p>
|
</p>
|
||||||
<table
|
<table
|
||||||
align="center"
|
align="center"
|
||||||
@@ -287,41 +288,6 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p
|
|
||||||
style="
|
|
||||||
font-size: 15px;
|
|
||||||
line-height: 26.25px;
|
|
||||||
margin: 0 0 20px 0;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
|
||||||
-moz-osx-font-smoothing: grayscale;
|
|
||||||
color: #374151;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
If the button doesn't work, you can copy this link into your
|
|
||||||
browser:
|
|
||||||
<code
|
|
||||||
style="
|
|
||||||
background-color: #efefef;
|
|
||||||
color: #111827;
|
|
||||||
padding: 2px 4px;
|
|
||||||
border-radius: 6px;
|
|
||||||
font-family: SFMono-Regular, Menlo, Monaco, Consolas,
|
|
||||||
'Liberation Mono', 'Courier New', monospace;
|
|
||||||
font-weight: 400;
|
|
||||||
letter-spacing: 0;
|
|
||||||
"
|
|
||||||
>{{link}}</code
|
|
||||||
>
|
|
||||||
</p>
|
|
||||||
<hr
|
|
||||||
style="
|
|
||||||
width: 100%;
|
|
||||||
border: none;
|
|
||||||
border-top: 1px solid #eaeaea;
|
|
||||||
margin-top: 32px;
|
|
||||||
margin-bottom: 32px;
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
<p
|
<p
|
||||||
style="
|
style="
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ Hello {{name}} 👋
|
|||||||
Thank you for registering for the {{event_name}}
|
Thank you for registering for the {{event_name}}
|
||||||
|
|
||||||
On the day of the run ({{event_date}}) you only have to show your barcode to receive your runner's card.
|
On the day of the run ({{event_date}}) you only have to show your barcode to receive your runner's card.
|
||||||
|
The Citizens' Run takes place from 2:00 PM to 6:00 PM.
|
||||||
|
The Corporate Run begins at 1:30 PM.
|
||||||
|
|
||||||
You can view your registration code, lap times and further information at any time from the Lauf für Kaya! Selfservice at {{link}}.
|
You can view your registration code, lap times and further information at any time from the Lauf für Kaya! Selfservice at {{link}}.
|
||||||
|
|
||||||
We look forward to seeing you and to a successful Lauf für Kaya!
|
We look forward to seeing you and to a successful Lauf für Kaya!
|
||||||
|
|||||||
Reference in New Issue
Block a user