feat: require phone and drop under-18 signup

Phone is required on public and coordinator forms, and the under-18
guardian flow, mail copies, and export columns are removed.
This commit is contained in:
blake committed 2026-10-26 13:30:30 -05:00
1 parent 7cfb984d63
commit 58da832bac
27 files changed
+225 -562

No files matched your search

+24 -36
View File
@@ -10,7 +10,6 @@ export type QueuedSignup = {
token: string;
volunteerName: string;
volunteerEmail: string;
guardianEmail: string | null;
shift: MailShift;
mail: MailIdentity;
now: string;
@@ -19,8 +18,7 @@ export type QueuedSignup = {
/** Inserts one row per recipient. The same logical message does not get a second row. */
export function queueConfirmation(db: Database.Database, input: QueuedSignup): void {
queue(db, 'confirmation', input, (audience) => renderConfirmation({
audience,
queue(db, 'confirmation', input, () => renderConfirmation({
volunteerName: input.volunteerName,
shift: input.shift,
manageUrl: manageUrl(input),
@@ -29,8 +27,7 @@ export function queueConfirmation(db: Database.Database, input: QueuedSignup): v
}
export function queueCancellation(db: Database.Database, input: QueuedSignup): void {
queue(db, 'cancelled', input, (audience) => renderCancellation({
audience,
queue(db, 'cancelled', input, () => renderCancellation({
volunteerName: input.volunteerName,
shift: input.shift,
manageUrl: manageUrl(input),
@@ -40,9 +37,8 @@ export function queueCancellation(db: Database.Database, input: QueuedSignup): v
}
export function queueChanged(db: Database.Database, input: QueuedSignup, reason: 'edit' | 'move' | 'switch' = 'edit'): void {
queue(db, 'changed', input, (audience) => {
queue(db, 'changed', input, () => {
const letter = {
audience,
volunteerName: input.volunteerName,
shift: input.shift,
manageUrl: manageUrl(input),
@@ -110,36 +106,28 @@ function queue(
db: Database.Database,
kind: 'confirmation' | 'cancelled' | 'changed',
input: QueuedSignup,
render: (audience: 'volunteer' | 'guardian') => { subject: string; text: string; html: string },
render: () => { subject: string; text: string; html: string },
): void {
for (const recipient of recipients(input.volunteerEmail, input.guardianEmail)) {
const audience = recipient === input.volunteerEmail ? 'volunteer' : 'guardian';
const rendered = render(audience);
db.prepare(
`INSERT INTO outbox (
dedupe_key, signup_id, shift_id, kind, to_email, subject, body_text, body_html,
headers_json, send_after, attempts, status, created_at
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 'pending', ?)
ON CONFLICT (dedupe_key) DO NOTHING`,
).run(
`${kind}:v${input.shiftVersion}:${input.signupId}:${recipient}`,
input.signupId,
input.shiftId,
kind,
recipient,
rendered.subject,
rendered.text,
rendered.html,
JSON.stringify({ From: input.mail.from, 'Reply-To': input.mail.replyTo }),
input.now,
input.now,
);
}
}
function recipients(volunteerEmail: string, guardianEmail: string | null): string[] {
if (!guardianEmail || guardianEmail === volunteerEmail) return [volunteerEmail];
return [volunteerEmail, guardianEmail];
const rendered = render();
db.prepare(
`INSERT INTO outbox (
dedupe_key, signup_id, shift_id, kind, to_email, subject, body_text, body_html,
headers_json, send_after, attempts, status, created_at
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 'pending', ?)
ON CONFLICT (dedupe_key) DO NOTHING`,
).run(
`${kind}:v${input.shiftVersion}:${input.signupId}:${input.volunteerEmail}`,
input.signupId,
input.shiftId,
kind,
input.volunteerEmail,
rendered.subject,
rendered.text,
rendered.html,
JSON.stringify({ From: input.mail.from, 'Reply-To': input.mail.replyTo }),
input.now,
input.now,
);
}
function manageUrl(input: QueuedSignup): string {
+13 -46
View File
@@ -19,7 +19,6 @@ export type RenderedMail = {
* ink and blue from public/brand/tokens.css.
*/
export function renderConfirmation(input: {
audience: 'volunteer' | 'guardian';
volunteerName: string;
shift: MailShift;
manageUrl: string;
@@ -27,14 +26,10 @@ export function renderConfirmation(input: {
}): RenderedMail {
const role = singleLine(input.shift.role);
const name = singleLine(input.volunteerName);
const subject = input.audience === 'guardian' ? `${name} is signed up for ${role}` : `You're signed up for ${role}`;
const hello = input.audience === 'guardian'
? `${name} is signed up for ${role}. You are listed as the parent or guardian.`
: `You are signed up for ${role}.`;
return render({
subject,
hello,
greeting: input.audience === 'guardian' ? 'Hello,' : `Hello ${name},`,
subject: `You're signed up for ${role}`,
hello: `You are signed up for ${role}.`,
greeting: `Hello ${name},`,
shift: input.shift,
linkLabel: 'Open this signup',
linkNote: 'You can cancel or switch this signup from that link. Use the separate link for each signup.',
@@ -44,7 +39,6 @@ export function renderConfirmation(input: {
}
export function renderCancellation(input: {
audience: 'volunteer' | 'guardian';
volunteerName: string;
shift: MailShift;
manageUrl: string;
@@ -53,16 +47,10 @@ export function renderCancellation(input: {
}): RenderedMail {
const role = singleLine(input.shift.role);
const name = singleLine(input.volunteerName);
const subject = input.audience === 'guardian'
? `${name}'s signup for ${role} is cancelled`
: `Your signup for ${role} is cancelled`;
const hello = input.audience === 'guardian'
? `${name}'s signup for ${role} is cancelled. The spot is open for someone else.`
: `Your signup for ${role} is cancelled. The spot is open for someone else.`;
return render({
subject,
hello,
greeting: input.audience === 'guardian' ? 'Hello,' : `Hello ${name},`,
subject: `Your signup for ${role} is cancelled`,
hello: `Your signup for ${role} is cancelled. The spot is open for someone else.`,
greeting: `Hello ${name},`,
shift: input.shift,
linkLabel: 'Open this signup',
linkNote: input.linkNote ?? 'That link opens the cancelled signup.',
@@ -72,55 +60,37 @@ export function renderCancellation(input: {
}
export function renderChanged(input: {
audience: 'volunteer' | 'guardian';
volunteerName: string;
shift: MailShift;
manageUrl: string;
replyTo: string;
}): RenderedMail {
const role = singleLine(input.shift.role);
const name = singleLine(input.volunteerName);
const subject = input.audience === 'guardian' ? `${name}'s ${role} shift has changed` : `Your ${role} shift has changed`;
const hello = input.audience === 'guardian'
? `The time or place for ${name}'s ${role} shift has changed.`
: `The time or place for your ${role} shift has changed.`;
return changedLetter(input, subject, hello);
return changedLetter(input, `Your ${role} shift has changed`, `The time or place for your ${role} shift has changed.`);
}
export function renderMoved(input: {
audience: 'volunteer' | 'guardian';
volunteerName: string;
shift: MailShift;
manageUrl: string;
replyTo: string;
}): RenderedMail {
const role = singleLine(input.shift.role);
const name = singleLine(input.volunteerName);
const subject = input.audience === 'guardian' ? `${name}'s signup was moved to ${role}` : `Your signup was moved to ${role}`;
const hello = input.audience === 'guardian'
? `A coordinator moved ${name}'s signup to a different shift.`
: 'A coordinator moved your signup to a different shift.';
return changedLetter(input, subject, hello);
return changedLetter(input, `Your signup was moved to ${role}`, 'A coordinator moved your signup to a different shift.');
}
export function renderSwitched(input: {
audience: 'volunteer' | 'guardian';
volunteerName: string;
shift: MailShift;
manageUrl: string;
replyTo: string;
}): RenderedMail {
const role = singleLine(input.shift.role);
const name = singleLine(input.volunteerName);
const subject = input.audience === 'guardian' ? `${name}'s signup was switched to ${role}` : `Your signup was switched to ${role}`;
const hello = input.audience === 'guardian'
? `${name} switched this signup to a different shift.`
: 'You switched this signup to a different shift.';
return changedLetter(input, subject, hello);
return changedLetter(input, `Your signup was switched to ${role}`, 'You switched this signup to a different shift.');
}
function changedLetter(
input: { audience: 'volunteer' | 'guardian'; volunteerName: string; shift: MailShift; manageUrl: string; replyTo: string },
input: { volunteerName: string; shift: MailShift; manageUrl: string; replyTo: string },
subject: string,
hello: string,
): RenderedMail {
@@ -128,7 +98,7 @@ function changedLetter(
return render({
subject,
hello,
greeting: input.audience === 'guardian' ? 'Hello,' : `Hello ${name},`,
greeting: `Hello ${name},`,
shift: input.shift,
linkLabel: 'Open this signup',
linkNote: 'This link replaces the earlier one. The previous link no longer works.',
@@ -138,7 +108,6 @@ function changedLetter(
}
export function renderReminder(input: {
audience: 'volunteer' | 'guardian';
volunteerName: string;
shift: MailShift;
unsubscribeUrl: string;
@@ -147,12 +116,10 @@ export function renderReminder(input: {
const role = singleLine(input.shift.role);
const name = singleLine(input.volunteerName);
const subject = `Reminder: ${role}`;
const hello = input.audience === 'guardian'
? `${name} is still signed up for ${role}. You are listed as the parent or guardian.`
: `You are still signed up for ${role}.`;
const hello = `You are still signed up for ${role}.`;
const cancelNote = 'To cancel, use the link in your confirmation email.';
const stopNote = `To stop reminder emails for this signup, open ${input.unsubscribeUrl}. The pantry reads mail sent to ${input.replyTo}. Stopping reminders does not cancel the signup. Confirmation, change, and cancellation emails still arrive.`;
const greeting = input.audience === 'guardian' ? 'Hello,' : `Hello ${name},`;
const greeting = `Hello ${name},`;
const when = input.shift.whenLabel;
const place = input.shift.location.trim();
const lines = [