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); + } +});