From e5aeadd01c054b13414a4ea3d58226d5589ecda8 Mon Sep 17 00:00:00 2001 From: rene Date: Sun, 17 May 2026 18:16:21 +0200 Subject: [PATCH] =?UTF-8?q?Feature:=20PocketBase=20Hook=20f=C3=BCr=20Inqui?= =?UTF-8?q?ry-Benachrichtigung=20per=20Mail=20(checkflo@motocamp.de)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 8 ++++ pocketbase/pb_hooks/inquiries.pb.js | 59 +++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 pocketbase/pb_hooks/inquiries.pb.js diff --git a/Makefile b/Makefile index f869f9a..af3d0da 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,10 @@ TAR_EXCLUDE := --exclude='.git' \ --exclude='./.env' \ --exclude='./.DS_Store' +# Hook-Sync: pb_hooks nach jedem Deploy auf DS kopieren +HOOKS_SRC := pocketbase/pb_hooks +HOOKS_DST := /volume1/docker/checkflo/pocketbase/data/pb_hooks + .PHONY: help check-ssh start stop restart status logs logs-f logs-app \ shell-pb pb-admin deploy setup-db seed-demo @@ -58,6 +62,10 @@ check-ssh: deploy: check-ssh @echo "→ Sync zu DS..." @COPYFILE_DISABLE=1 tar czf - $(TAR_EXCLUDE) . | ssh $(DS_HOST) "tar xzf - -C $(DS_PATH)/" + @echo "→ PocketBase Hooks synchronisieren..." + @for f in $(HOOKS_SRC)/*.pb.js; do \ + cat "$$f" | ssh $(DS_HOST) "cat > $(HOOKS_DST)/$$(basename $$f)"; \ + done @echo "→ Docker rebuild + restart..." @ssh $(DS_HOST) " \ cd $(DS_PATH) && \ diff --git a/pocketbase/pb_hooks/inquiries.pb.js b/pocketbase/pb_hooks/inquiries.pb.js new file mode 100644 index 0000000..0e2b254 --- /dev/null +++ b/pocketbase/pb_hooks/inquiries.pb.js @@ -0,0 +1,59 @@ +/// + +// Sendet eine Benachrichtigungs-Mail bei neuer Demo-Anfrage +onRecordCreate((e) => { + e.next(); + + if (e.collection.name !== "inquiries") return; + + const r = e.record; + const name = r.getString("name"); + const company = r.getString("company"); + const email = r.getString("email"); + const phone = r.getString("phone"); + const message = r.getString("message"); + const plan = r.getString("plan"); + + const subject = `checkflo: Neue Anfrage von ${name}${company ? " (" + company + ")" : ""}`; + + const html = ` + + + + +
+
+ NEUE DEMO-ANFRAGE +
+

${name}

+ ${company ? `

${company}

` : `
`} + + + + ${phone ? `` : ""} + ${plan ? `` : ""} + ${message ? `` : ""} +
E-Mail${email}
Telefon${phone}
Plan${plan}
Nachricht${message}
+ +
+ + Alle Anfragen in PocketBase → + +
+
+ +`; + + try { + const message = new MailerMessage({ + from: { address: "hallo@checkflo.de", name: "checkflo" }, + to: [{ address: "checkflo@motocamp.de" }], + subject: subject, + html: html, + }); + $app.newMailClient().send(message); + } catch (err) { + console.error("Inquiry-Mail Fehler:", err); + } +});