Add a Request form, with files in Google Drive and email notices
One form at /request for blog posts, events, and new or updated chapters, regions (updates only), partners, teams, awards and people. ?type= opens it on one; buttons on the Community sections, blog posts, Retreats and the front page calendar do. Files (.docx, PDF, JPEG, PNG) go to a Google Drive folder through a service account. Requests are feedback rows of type 'content' (migration 046), in a third Forms queue: files download from Drive, a .docx can become a draft blog post, and deleting a request deletes its files. New content and data requests email the addresses in Site settings through Gmail. Setup: docs/google-drive-and-mail.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0e582c236b
commit
dc53af238f
31 changed files with 1318 additions and 113 deletions
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
import { Hono } from "hono";
|
||||
import { clientIp, hashIp } from "../auth.js";
|
||||
import { notifyNew } from "../notify.js";
|
||||
|
||||
const feedback = new Hono();
|
||||
|
||||
|
|
@ -36,14 +37,14 @@ const TYPES = ["broken", "confusing", "outdated", "request", "praise", "other",
|
|||
|
||||
/* ── Input cleaning ──────────────────────────────────────────── */
|
||||
|
||||
function clean(value, max) {
|
||||
export function clean(value, max) {
|
||||
if (typeof value !== "string") return "";
|
||||
return value.trim().slice(0, max);
|
||||
}
|
||||
|
||||
// Deliberately permissive. Rejecting odd-but-valid addresses loses
|
||||
// real submissions, and the field is optional anyway.
|
||||
function looksLikeEmail(value) {
|
||||
export function looksLikeEmail(value) {
|
||||
return value === "" || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
|
||||
}
|
||||
|
||||
|
|
@ -108,6 +109,15 @@ feedback.post("/", async (c) => {
|
|||
|
||||
// created_at and status come from column defaults.
|
||||
console.log(`feedback #${result.lastInsertRowid} (${feedbackType})`);
|
||||
if (feedbackType === "privacy") {
|
||||
notifyNew(db, {
|
||||
id: result.lastInsertRowid,
|
||||
subject: "Data request from the Privacy page",
|
||||
lines: [`From: ${name ? `${name} <${email}>` : email}`, "", message],
|
||||
replyTo: email,
|
||||
queue: "/admin/data-requests",
|
||||
});
|
||||
}
|
||||
|
||||
return c.body(null, 204);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue