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

-9
View File
@@ -556,9 +556,6 @@ async function submitAddContactToShift(c: Context, services: AdminServices): Pro
email: parsed.draft.emailNorm,
phone: parsed.draft.phone,
notes: parsed.draft.notes,
isMinor: parsed.draft.isMinor,
guardianName: parsed.draft.guardianName,
guardianEmail: parsed.draft.guardianEmail,
operationId: token.claims.operationId,
now: services.now(),
mail: mailIdentity(services.db, services.config),
@@ -1224,9 +1221,6 @@ async function submitWalkIn(c: Context, services: AdminServices): Promise<Respon
email: parsed.draft.emailNorm,
phone: parsed.draft.phone,
notes: parsed.draft.notes,
isMinor: parsed.draft.isMinor,
guardianName: parsed.draft.guardianName,
guardianEmail: parsed.draft.guardianEmail,
operationId: token.claims.operationId,
now: services.now(),
mail: mailIdentity(services.db, services.config),
@@ -1571,9 +1565,6 @@ function signupValuesFrom(body: Record<string, unknown>): SignupValues {
email: textField(body, 'email'),
phone: textField(body, 'phone'),
notes: textField(body, 'notes'),
under18: textField(body, 'under18') === 'yes',
guardianName: textField(body, 'guardianName'),
guardianEmail: textField(body, 'guardianEmail'),
};
}
+20 -34
View File
@@ -42,7 +42,7 @@ const SHIFT_PEOPLE_BODY = 'Remove everyone on this roster first.';
const SHIFT_WAIT_BODY = 'Cancel this shift, or wait until it has ended, before removing it.';
const SHIFT_WEEKLY_NOTE =
'This date came from a weekly template that is still active. Add weekly shifts can put this date back. End that template first if the date should stay gone.';
const PERSON_DELETE_BODY = 'This deletes their name, email, phone, guardian details, and notes from the roster. It does not send email.';
const PERSON_DELETE_BODY = 'This deletes their name, email, phone, and notes from the roster. It does not send email.';
const PERSON_WAIT_BODY = 'Cancel this signup before removing it.';
const PERSON_CANCEL_BODY = 'Cancelling a signup emails them. Their old private link stops working, and the email includes a new one.';
const SHIFT_CANCEL_EMPTY = 'No one is signed up. Cancelling closes the shift and does not send email.';
@@ -341,7 +341,7 @@ export function SettingsPage(props: {
<label>
Keep signups for, months
<input name="retention_months" type="number" min="1" max="120" required value={props.values.retentionMonths} />
<span class="hint">The default is 24, counted after the shift ends. After 1:00 AM Central Time, signups older than this lose their name, email, phone, guardian, and notes in this app. A spreadsheet already downloaded is left as it is.</span>
<span class="hint">The default is 24, counted after the shift ends. After 1:00 AM Central Time, signups older than this lose their name, email, phone, and notes in this app. A spreadsheet already downloaded is left as it is.</span>
{errors.retentionMonths ? <span class="error">{errors.retentionMonths}</span> : null}
</label>
<label>
@@ -406,18 +406,18 @@ export function ContactsPage(props: {
<form method="post" action={appPath(props.config, '/admin/contacts/new')} class="signup-form desk-download">
<input type="hidden" name="csrf" value={props.csrf} />
<h2>Add a contact</h2>
<p>This saves one person. It does not sign them up and does not send email. The same name and email updates that person. A different name is saved separately, even with the same email. A blank phone does not erase a phone already saved. Names are capitalized. A 10-digit phone is saved with dashes, like 712-555-0100.</p>
<p>This saves one person. It does not sign them up and does not send email. The same name and email updates that person. A different name is saved separately, even with the same email. Names are capitalized. A 10-digit phone is saved with dashes, like 712-555-0100.</p>
<WalkInField id="contact-first" label="First name" name="first_name" type="text" value={manual.values.firstName} error={manual.errors.firstName} />
<WalkInField id="contact-last" label="Last name" name="last_name" type="text" value={manual.values.lastName} error={manual.errors.lastName} />
<WalkInField id="contact-email" label="Email" name="email" type="email" value={manual.values.email} error={manual.errors.email} />
<WalkInField id="contact-phone" label="Phone (optional)" name="phone" type="tel" value={manual.values.phone} error={manual.errors.phone} hint="We will not text them" />
<WalkInField id="contact-phone" label="Phone" name="phone" type="tel" value={manual.values.phone} error={manual.errors.phone} required />
<button type="submit">Save this contact</button>
</form>
<form method="post" action={appPath(props.config, '/admin/contacts/import')} class="signup-form desk-download" enctype="multipart/form-data">
<input type="hidden" name="csrf" value={props.csrf} />
<h2>Import a contact list</h2>
<p>
Use a spreadsheet with First Name, Last Name, Email, and Phone. The SignUpGenius people export works. Address is ignored. The same name and email updates that person. A different name stays a separate person, even when the email matches. A different email stays a separate person, even when the name matches. A blank phone does not erase a phone already saved. Names are capitalized. A 10-digit phone is saved with dashes, like 712-555-0100. Email addresses are stored in lowercase. The file has to be under 64 KB.
Use a spreadsheet with First Name, Last Name, Email, and Phone. The SignUpGenius people export works. Address is ignored. The same name and email updates that person. A different name stays a separate person, even when the email matches. A different email stays a separate person, even when the name matches. A row without a phone is skipped. Names are capitalized. A 10-digit phone is saved with dashes, like 712-555-0100. Email addresses are stored in lowercase. The file has to be under 64 KB.
</p>
{props.importError ? <p class="error">{props.importError}</p> : null}
<label>
@@ -521,19 +521,19 @@ export function ContactPage(props: {
<input type="hidden" name="csrf" value={props.csrf} />
<h2>Correct this contact</h2>
<p>
This changes the saved person. A different name stays this contact and does not create a second person. It does not change a signup, take a spot, or send email. Names are capitalized. A 10-digit phone is saved with dashes, like 712-555-0100. A blank phone removes the saved number.
This changes the saved person. A different name stays this contact and does not create a second person. It does not change a signup, take a spot, or send email. Names are capitalized. A 10-digit phone is saved with dashes, like 712-555-0100.
</p>
<WalkInField id="correct-first" label="First name" name="first_name" type="text" value={correction.values.firstName} error={correction.errors.firstName} />
<WalkInField id="correct-last" label="Last name" name="last_name" type="text" value={correction.values.lastName} error={correction.errors.lastName} />
<WalkInField id="correct-email" label="Email" name="email" type="email" value={correction.values.email} error={correction.errors.email} />
<WalkInField
id="correct-phone"
label="Phone (optional)"
label="Phone"
name="phone"
type="tel"
value={correction.values.phone}
error={correction.errors.phone}
hint="We will not text them"
required
/>
<button type="submit">Save this correction</button>
</form>
@@ -568,15 +568,6 @@ export function ContactPage(props: {
</textarea>
{errors.notes ? <span class="field-error">{errors.notes}</span> : null}
</label>
<label class="check" for="add-under-18">
<input id="add-under-18" name="under18" type="checkbox" value="yes" data-under-18="" checked={values.under18 ? true : undefined} />
They are under 18
</label>
<fieldset data-guardian="">
<legend>Parent or guardian</legend>
<WalkInField id="add-guardianName" label="Guardian name" name="guardianName" type="text" value={values.guardianName} error={errors.guardianName} />
<WalkInField id="add-guardianEmail" label="Guardian email" name="guardianEmail" type="email" value={values.guardianEmail} error={errors.guardianEmail} />
</fieldset>
<button type="submit">Add to this shift</button>
</form>
) : (
@@ -1559,7 +1550,7 @@ function WalkInForm(props: { config: AppConfig; csrf: string; shiftId: number; f
) : null}
<WalkInField id="walkin-name" label="Name" name="name" type="text" value={values.name} error={errors.name} />
<WalkInField id="walkin-email" label="Email" name="email" type="email" value={values.email} error={errors.email} />
<WalkInField id="walkin-phone" label="Phone (optional)" name="phone" type="tel" value={values.phone} error={errors.phone} hint="We will not text you" />
<WalkInField id="walkin-phone" label="Phone" name="phone" type="tel" value={values.phone} error={errors.phone} required />
<label for="walkin-notes">
Notes (optional)
<textarea id="walkin-notes" name="notes" aria-invalid={errors.notes ? 'true' : undefined} aria-describedby={errors.notes ? 'walkin-notes-error' : undefined}>
@@ -1571,21 +1562,21 @@ function WalkInForm(props: { config: AppConfig; csrf: string; shiftId: number; f
</span>
) : null}
</label>
<label class="check" for="walkin-under-18">
<input id="walkin-under-18" name="under18" type="checkbox" value="yes" data-under-18="" checked={values.under18 ? true : undefined} />
They are under 18
</label>
<fieldset data-guardian="">
<legend>Parent or guardian</legend>
<WalkInField id="walkin-guardianName" label="Guardian name" name="guardianName" type="text" value={values.guardianName} error={errors.guardianName} />
<WalkInField id="walkin-guardianEmail" label="Guardian email" name="guardianEmail" type="email" value={values.guardianEmail} error={errors.guardianEmail} />
</fieldset>
<button type="submit">Add to this shift</button>
</form>
);
}
function WalkInField(props: { id: string; label: string; name: string; type: 'text' | 'email' | 'tel'; value: string; error?: string; hint?: string }) {
function WalkInField(props: {
id: string;
label: string;
name: string;
type: 'text' | 'email' | 'tel';
value: string;
error?: string;
hint?: string;
required?: boolean;
}) {
const errorId = `${props.id}-error`;
const hintId = `${props.id}-hint`;
const describedBy = [props.hint ? hintId : '', props.error ? errorId : ''].filter(Boolean).join(' ') || undefined;
@@ -1598,6 +1589,7 @@ function WalkInField(props: { id: string; label: string; name: string; type: 'te
type={props.type}
value={props.value}
autocomplete="off"
required={props.required ? true : undefined}
aria-invalid={props.error ? 'true' : undefined}
aria-describedby={describedBy}
/>
@@ -1631,12 +1623,6 @@ function Roster(props: { config: AppConfig; csrf: string; people: RosterPerson[]
</p>
<p>{person.email}</p>
{person.phone ? <p>{person.phone}</p> : null}
{person.minor ? <p>Under 18</p> : null}
{person.guardianName || person.guardianEmail ? (
<p>
Guardian: {person.guardianName} {person.guardianEmail}
</p>
) : null}
{person.notes ? <p>Note: {person.notes}</p> : null}
<p>{person.status === 'confirmed' ? 'Confirmed' : 'Cancelled'}</p>
{person.status === 'cancelled' ? (
+5 -18
View File
@@ -85,9 +85,6 @@ export type RosterPerson = {
name: string;
email: string;
phone: string | null;
minor: boolean;
guardianName: string | null;
guardianEmail: string | null;
notes: string | null;
status: 'confirmed' | 'cancelled';
attendance: 'attended' | 'no-show' | null;
@@ -294,7 +291,7 @@ export function getAdminShift(db: Database.Database, id: number): AdminShift | n
if (!row) return null;
const people = db
.prepare(
`SELECT id, name, email, phone, is_minor, guardian_name, guardian_email, notes, status, attended
`SELECT id, name, email, phone, notes, status, attended
FROM signups
WHERE shift_id = ? AND anonymized_at IS NULL AND name IS NOT NULL AND email IS NOT NULL
ORDER BY CASE status WHEN 'confirmed' THEN 0 ELSE 1 END, id`,
@@ -304,9 +301,6 @@ export function getAdminShift(db: Database.Database, id: number): AdminShift | n
name: string;
email: string;
phone: string | null;
is_minor: number;
guardian_name: string | null;
guardian_email: string | null;
notes: string | null;
status: string;
attended: number | null;
@@ -324,9 +318,6 @@ export function getAdminShift(db: Database.Database, id: number): AdminShift | n
name: person.name,
email: person.email,
phone: person.phone,
minor: person.is_minor === 1,
guardianName: person.guardian_name,
guardianEmail: person.guardian_email,
notes: person.notes,
status: person.status,
attendance: person.attended === 1 ? 'attended' : person.attended === 0 ? 'no-show' : null,
@@ -1277,7 +1268,7 @@ function relocate(
const newSignupId = Number(inserted.lastInsertRowid);
const shift = mailShift(db, destination.id);
if (!shift) throw new Error('The destination shift was not available after it was checked.');
queueChanged(
queueChanged(
db,
{
signupId: newSignupId,
@@ -1286,7 +1277,6 @@ function relocate(
token: issued.token,
volunteerName: source.name,
volunteerEmail: source.email_norm,
guardianEmail: source.is_minor === 1 ? source.guardian_email : null,
shift: shift.facts,
mail,
now,
@@ -1419,7 +1409,7 @@ function bumpAndNotify(db: Database.Database, shiftId: number, now: string, mail
if (!shift) return 0;
const people = db
.prepare(
`SELECT id, name, email_norm, guardian_email, shift_id, status
`SELECT id, name, email_norm, shift_id, status
FROM signups
WHERE shift_id = ? AND status = 'confirmed' AND anonymized_at IS NULL AND name IS NOT NULL AND email_norm IS NOT NULL`,
)
@@ -1435,7 +1425,6 @@ function bumpAndNotify(db: Database.Database, shiftId: number, now: string, mail
token,
volunteerName: person.name,
volunteerEmail: person.email_norm,
guardianEmail: person.guardian_email,
shift: shift.facts,
mail,
now,
@@ -1448,7 +1437,7 @@ function bumpAndNotify(db: Database.Database, shiftId: number, now: string, mail
function cancelConfirmedOnShift(db: Database.Database, shiftId: number, now: string, mail: MailIdentity): number {
const people = db
.prepare(
`SELECT id, name, email_norm, guardian_email, shift_id, status
`SELECT id, name, email_norm, shift_id, status
FROM signups
WHERE shift_id = ? AND status = 'confirmed' AND anonymized_at IS NULL AND name IS NOT NULL AND email_norm IS NOT NULL`,
)
@@ -1481,7 +1470,6 @@ function cancelConfirmedPerson(db: Database.Database, person: PersonRow, now: st
token: issued.token,
volunteerName: person.name,
volunteerEmail: person.email_norm,
guardianEmail: person.guardian_email,
shift: shift.facts,
mail,
now,
@@ -1546,7 +1534,7 @@ function mailShift(db: Database.Database, shiftId: number): { version: number; e
function loadPerson(db: Database.Database, signupId: number): PersonRow | null {
const row = db
.prepare(
`SELECT id, name, email_norm, guardian_email, shift_id, status
`SELECT id, name, email_norm, shift_id, status
FROM signups
WHERE id = ? AND anonymized_at IS NULL`,
)
@@ -1692,7 +1680,6 @@ type PersonRow = {
id: number;
name: string | null;
email_norm: string | null;
guardian_email: string | null;
shift_id: number;
status: string;
};
+19 -14
View File
@@ -16,13 +16,13 @@ const MAX_SKIPS = 30;
const CONTROL = /[\u0000-\u001F\u007F]/;
export const CONTACT_CSV_EMPTY = 'Choose a spreadsheet to import.';
export const CONTACT_CSV_COLUMNS = 'This spreadsheet needs First Name, Last Name, and Email columns.';
export const CONTACT_CSV_COLUMNS = 'This spreadsheet needs First Name, Last Name, Email, and Phone columns.';
export const CONTACT_CSV_READ = 'This spreadsheet could not be read.';
export const CONTACT_CSV_LARGE = 'This spreadsheet has more than 2000 people.';
export const CONTACT_CSV_BINARY = 'Save the spreadsheet as CSV.';
export const CONTACT_CSV_LIMIT = 'This spreadsheet has to be under 64 KB.';
export type ContactSkipCode = 'e' | 'n' | 'p' | 'l' | 'c';
export type ContactSkipCode = 'e' | 'n' | 'p' | 'm' | 'l' | 'c';
export type ContactSkip = { line: number; code: ContactSkipCode };
@@ -71,6 +71,7 @@ const SKIP_REASON: Record<ContactSkipCode, string> = {
e: 'the email is not an address',
n: 'the name is missing',
p: 'the phone is too long',
m: 'the phone is missing',
l: 'the name is too long',
c: 'a field has a line break',
};
@@ -108,7 +109,7 @@ export function parseContactSkips(value: string | undefined): ContactSkip[] {
if (!value) return [];
const skips: ContactSkip[] = [];
for (const part of value.split('.')) {
const match = /^(\d+)([enplc])$/.exec(part);
const match = /^(\d+)([enplcm])$/.exec(part);
if (!match) continue;
const line = Number(match[1]);
const code = match[2];
@@ -224,7 +225,7 @@ export function removeContact(db: Database.Database, coordinatorId: number, id:
/**
* Saves the person from a confirmed signup.
* The same name and email updates that contact. A different name is a new contact, even with the same email.
* A blank phone does not erase a phone already saved.
* A blank phone does not erase a phone already saved (legacy or cleared records).
*/
export function rememberSignupContact(
db: Database.Database,
@@ -267,7 +268,7 @@ export function saveManualContact(
/**
* Replaces the name, email, and phone on one saved contact.
* A different name stays this contact. A blank phone removes the saved number.
* A different name stays this contact. Phone is required.
*/
export function correctContact(
db: Database.Database,
@@ -346,7 +347,7 @@ function columnIndex(cells: string[]): { first: number; last: number; email: num
const last = names.indexOf('last name');
const email = names.indexOf('email');
const phone = names.indexOf('phone');
if (first < 0 || last < 0 || email < 0) return null;
if (first < 0 || last < 0 || email < 0 || phone < 0) return null;
return { first, last, email, phone };
}
@@ -382,7 +383,8 @@ function manualContact(values: ContactManualValues): { ok: true; person: ReadyCo
if (firstName && lastName && !errors.firstName && !errors.lastName && `${firstName} ${lastName}`.length > MAX_NAME) {
errors.lastName = `Use ${MAX_NAME} characters or fewer for the full name.`;
}
if (CONTROL.test(phoneRaw)) errors.phone = 'Enter a phone number without line breaks.';
if (!phoneRaw || !phone) errors.phone = 'Enter a phone number.';
else if (CONTROL.test(phoneRaw)) errors.phone = 'Enter a phone number without line breaks.';
else if (phoneRaw.length > MAX_PHONE || phone.length > MAX_PHONE) errors.phone = `Use ${MAX_PHONE} characters or fewer.`;
let email = '';
const emailRaw = values.email.normalize('NFC').trim();
@@ -396,8 +398,8 @@ function manualContact(values: ContactManualValues): { ok: true; person: ReadyCo
errors.email = err instanceof EmailAddressError ? err.message : 'Enter an email address.';
}
}
if (Object.keys(errors).length > 0 || !email) return { ok: false, errors };
return { ok: true, person: { firstName, lastName, email, phone: phone.length === 0 ? null : phone } };
if (Object.keys(errors).length > 0 || !email || !phone) return { ok: false, errors };
return { ok: true, person: { firstName, lastName, email, phone } };
}
function findContact(
@@ -453,16 +455,19 @@ function parsePerson(cells: string[], columns: { first: number; last: number; em
const last = capitalizeName(lastName);
if (!first || !last) return { code: 'n' };
if (first.length > MAX_NAME || last.length > MAX_NAME || `${first} ${last}`.length > MAX_NAME) return { code: 'l' };
const phone = phoneRaw.length === 0 ? '' : formatPhone(phoneRaw);
if (phoneRaw.length > MAX_PHONE || phone.length > MAX_PHONE) return { code: 'p' };
let email = '';
try {
const email = normalizeEmail(emailRaw);
email = normalizeEmail(emailRaw);
if (email.length > MAX_EMAIL) return { code: 'e' };
return { firstName: first, lastName: last, email, phone: phone.length === 0 ? null : phone };
} catch (err) {
if (err instanceof EmailAddressError) return { code: 'e' };
throw err;
}
if (!phoneRaw) return { code: 'm' };
const phone = formatPhone(phoneRaw);
if (!phone) return { code: 'm' };
if (phoneRaw.length > MAX_PHONE || phone.length > MAX_PHONE) return { code: 'p' };
return { firstName: first, lastName: last, email, phone };
}
function cellAt(cells: string[], index: number): string {
@@ -533,5 +538,5 @@ function parseCsv(text: string): { line: number; cells: string[] }[] {
}
function isSkipCode(value: string): value is ContactSkipCode {
return value === 'e' || value === 'n' || value === 'p' || value === 'l' || value === 'c';
return value === 'e' || value === 'n' || value === 'p' || value === 'm' || value === 'l' || value === 'c';
}
+2 -14
View File
@@ -122,19 +122,13 @@ function insertFakeSignups(db: Database.Database, shiftId: number, createdAt: st
name: 'Fake Volunteer Ada',
email: `ada.fake@${SEED_EMAIL_DOMAIN}`,
phone: '712-555-0101',
isMinor: 0,
guardianName: null,
guardianEmail: null,
notes: 'Fake note for development.',
status: 'confirmed',
},
{
name: 'Fake Volunteer Ben',
email: `ben.fake@${SEED_EMAIL_DOMAIN}`,
phone: null,
isMinor: 1,
guardianName: 'Fake Guardian Pat',
guardianEmail: `pat.fake@${SEED_EMAIL_DOMAIN}`,
phone: '712-555-0102',
notes: null,
status: 'confirmed',
},
@@ -142,9 +136,6 @@ function insertFakeSignups(db: Database.Database, shiftId: number, createdAt: st
name: 'Fake Volunteer Cam',
email: `cam.fake@${SEED_EMAIL_DOMAIN}`,
phone: null,
isMinor: 0,
guardianName: null,
guardianEmail: null,
notes: null,
status: 'cancelled',
},
@@ -154,7 +145,7 @@ function insertFakeSignups(db: Database.Database, shiftId: number, createdAt: st
shift_id, name, email, email_norm, phone, is_minor, guardian_name, guardian_email,
group_size, notes, status, manage_token_hash, token_expires_at, reminders_off,
attended, created_at, updated_at, anonymized_at
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?, NULL, NULL, 0, NULL, ?, ?, NULL)`,
) VALUES (?, ?, ?, ?, ?, 0, NULL, NULL, 1, ?, ?, NULL, NULL, 0, NULL, ?, ?, NULL)`,
);
return people.map((person) =>
insertId(
@@ -164,9 +155,6 @@ function insertFakeSignups(db: Database.Database, shiftId: number, createdAt: st
person.email,
normalizeEmail(person.email),
person.phone,
person.isMinor,
person.guardianName,
person.guardianEmail,
person.notes,
person.status,
createdAt,
-10
View File
@@ -16,9 +16,6 @@ const COLUMNS = [
'Email',
'Phone',
'Group size',
'Minor',
'Guardian name',
'Guardian email',
'Notes',
'Status',
'Attended',
@@ -35,9 +32,6 @@ type RosterRecord = {
email: string | null;
phone: string | null;
group_size: number;
is_minor: number;
guardian_name: string | null;
guardian_email: string | null;
notes: string | null;
status: string;
attended: number | null;
@@ -46,7 +40,6 @@ type RosterRecord = {
const ROSTER_SQL = `SELECT s.starts_at_utc AS starts_at_utc, s.ends_at_utc AS ends_at_utc, e.tz AS tz, s.role AS role,
su.name AS name, su.email AS email, su.phone AS phone, su.group_size AS group_size,
su.is_minor AS is_minor, su.guardian_name AS guardian_name, su.guardian_email AS guardian_email,
su.notes AS notes, su.status AS status, su.attended AS attended, su.anonymized_at AS anonymized_at
FROM signups su
JOIN shifts s ON s.id = su.shift_id
@@ -136,9 +129,6 @@ function present(row: RosterRecord): string[] {
row.email ?? '',
row.phone ?? '',
String(row.group_size),
row.anonymized_at ? '' : row.is_minor === 1 ? 'Yes' : 'No',
row.guardian_name ?? '',
row.guardian_email ?? '',
row.notes ?? '',
row.status === 'cancelled' ? 'Cancelled' : 'Confirmed',
row.attended === 1 ? 'Attended' : row.attended === 0 ? 'No-show' : '',
+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 = [
+3 -37
View File
@@ -353,15 +353,6 @@ export function ManagePage(props: {
<dd>{signup.phone}</dd>
</div>
) : null}
{signup.isMinor ? (
<div>
<dt>Guardian</dt>
<dd>
{signup.guardianName}
{signup.guardianEmail ? ` (${signup.guardianEmail})` : ''}
</dd>
</div>
) : null}
{signup.notes ? (
<div>
<dt>Notes</dt>
@@ -713,7 +704,7 @@ function SignupForm(props: { config: AppConfig; shiftId: number; form: SignupFor
return (
<form class="signup-form" method="post" action={appPath(props.config, `/s/${props.shiftId}`)}>
<h2>Sign up</h2>
<p>Each signup is for one person and takes one spot. Another person can use the same email address. If you are under 18, add a parent or guardian.</p>
<p>Each signup is for one person and takes one spot. Another person can use the same email address.</p>
<noscript>
<p class="error">Signing up needs JavaScript for the abuse check. The pantry has not published a contact method for help with signup.</p>
</noscript>
@@ -761,13 +752,13 @@ function SignupForm(props: { config: AppConfig; shiftId: number; form: SignupFor
<Field id="signup-email" label="Email" name="email" type="email" value={form.values.email} error={errors.email} autoComplete="email" />
<Field
id="signup-phone"
label="Phone (optional)"
label="Phone"
name="phone"
type="tel"
value={form.values.phone}
error={errors.phone}
autoComplete="tel"
hint="We will not text you"
required
/>
<label for="signup-notes">
Notes (optional)
@@ -780,31 +771,6 @@ function SignupForm(props: { config: AppConfig; shiftId: number; form: SignupFor
</span>
) : null}
</label>
<label class="check" for="signup-under-18">
<input id="signup-under-18" name="under18" type="checkbox" value="yes" data-under-18="" checked={form.values.under18 ? true : undefined} />
I am under 18
</label>
<fieldset data-guardian="">
<legend>Parent or guardian</legend>
<Field
id="signup-guardianName"
label="Guardian name"
name="guardianName"
type="text"
value={form.values.guardianName}
error={errors.guardianName}
autoComplete="name"
/>
<Field
id="signup-guardianEmail"
label="Guardian email"
name="guardianEmail"
type="email"
value={form.values.guardianEmail}
error={errors.guardianEmail}
autoComplete="email"
/>
</fieldset>
<div class="cf-turnstile" data-sitekey={form.siteKey} data-action="signup" />
<p id="signup-turnstile-hint">This check confirms the signup came from a browser.</p>
<button type="submit">Sign up</button>
+2 -23
View File
@@ -8,8 +8,6 @@ import { formatUtc } from './time.js';
export const SIGNUP_IP_LIMIT = 5;
export const SIGNUP_IP_WINDOW_MS = 10 * 60 * 1000;
export const SIGNUP_EMAIL_LIMIT = 3;
/** A guardian can have several children signed up, so this allowance is a little wider. */
export const SIGNUP_GUARDIAN_LIMIT = 5;
export const SWITCH_IP_LIMIT = 10;
export const SWITCH_RECIPIENT_LIMIT = 5;
export const MANAGE_TOKEN_LIMIT = 20;
@@ -30,8 +28,8 @@ export type RateDecision = { limited: false } | { limited: true; retryAfter: num
/**
* Counts validated public switch attempts, not the rotating signup id or token.
* Both recipient roles share one daily allowance. Check and charge every bucket
* atomically so a blocked recipient cannot consume another person's allowance.
* Check and charge every bucket atomically so a blocked recipient cannot consume
* another person's allowance.
*/
export function recordSwitchAttempt(
db: Database.Database,
@@ -144,25 +142,6 @@ export function recordSignupEmail(
});
}
/**
* Counts signups that mail a guardian address. Without it, someone could rotate
* volunteer addresses and keep sending mail to one guardian.
*/
export function recordSignupGuardian(
db: Database.Database,
secret: string,
now: string,
timeZone: string,
guardianEmailNorm: string,
): RateDecision {
return record(db, secret, now, {
kind: 'signup-guardian',
id: guardianEmailNorm,
limit: SIGNUP_GUARDIAN_LIMIT,
window: dayWindow(now, timeZone),
});
}
function record(
db: Database.Database,
secret: string,
+5 -13
View File
@@ -14,7 +14,6 @@ type DueSignup = {
id: number;
name: string;
email_norm: string;
guardian_email: string | null;
version: number;
starts_at_utc: string;
ends_at_utc: string;
@@ -38,7 +37,7 @@ export function queueDueReminders(db: Database.Database, mail: MailIdentity, sec
const activeMail = { ...mail, replyTo: readReplyTo(db, mail.replyTo) };
const rows = db
.prepare(
`SELECT su.id AS id, su.name AS name, su.email_norm AS email_norm, su.guardian_email AS guardian_email,
`SELECT su.id AS id, su.name AS name, su.email_norm AS email_norm,
su.shift_id AS shift_id, s.version AS version, s.starts_at_utc AS starts_at_utc,
s.ends_at_utc AS ends_at_utc, s.role AS role,
e.title AS title, e.location AS location, e.tz AS tz
@@ -129,7 +128,7 @@ function insertReminder(
): boolean {
const unsubscribeUrl = absoluteUrl(mail, `/u/${issueReminderOffToken(secret, row.id)}`);
const headers = reminderHeaders(mail, unsubscribeUrl);
const volunteerId = insertOutbox(db, row, kind, row.email_norm, 'volunteer', mail, headers, unsubscribeUrl, now, mode);
const volunteerId = insertOutbox(db, row, kind, mail, headers, unsubscribeUrl, now, mode);
if (volunteerId === null) return false;
const saved = db
.prepare(
@@ -138,19 +137,13 @@ function insertReminder(
ON CONFLICT (signup_id, kind, shift_version) DO NOTHING`,
)
.run(row.id, kind, row.version, volunteerId, now);
if (saved.changes !== 1) return false;
if (mode === 'pending' && row.guardian_email && row.guardian_email !== row.email_norm) {
insertOutbox(db, row, kind, row.guardian_email, 'guardian', mail, headers, unsubscribeUrl, now, 'pending');
}
return true;
return saved.changes === 1;
}
function insertOutbox(
db: Database.Database,
row: DueSignup,
kind: string,
recipient: string,
audience: 'volunteer' | 'guardian',
mail: MailIdentity,
headers: Record<string, string>,
unsubscribeUrl: string,
@@ -159,7 +152,6 @@ function insertOutbox(
): number | null {
const rendered = mode === 'pending'
? renderReminder({
audience,
volunteerName: row.name,
shift: shiftFacts(row),
unsubscribeUrl,
@@ -175,10 +167,10 @@ function insertOutbox(
ON CONFLICT (dedupe_key) DO NOTHING`,
)
.run(
`reminder:v${row.version}:${row.id}:${kind}:${recipient}`,
`reminder:v${row.version}:${row.id}:${kind}:${row.email_norm}`,
row.id,
row.shift_id,
recipient,
row.email_norm,
rendered.subject,
rendered.text,
rendered.html,
+7 -43
View File
@@ -13,25 +13,18 @@ export type SignupValues = {
email: string;
phone: string;
notes: string;
under18: boolean;
guardianName: string;
guardianEmail: string;
};
export type SignupErrors = Partial<
Record<'name' | 'firstName' | 'lastName' | 'email' | 'phone' | 'notes' | 'guardianName' | 'guardianEmail' | 'form', string>
Record<'name' | 'firstName' | 'lastName' | 'email' | 'phone' | 'notes' | 'form', string>
>;
export type SignupDraft = {
name: string;
email: string;
emailNorm: string;
phone: string | null;
phone: string;
notes: string | null;
isMinor: boolean;
guardianName: string | null;
guardianEmail: string | null;
guardianEmailNorm: string | null;
};
export const EMPTY_SIGNUP: SignupValues = {
@@ -41,9 +34,6 @@ export const EMPTY_SIGNUP: SignupValues = {
email: '',
phone: '',
notes: '',
under18: false,
guardianName: '',
guardianEmail: '',
};
const controlChars = /[\u0000-\u001F\u007F]/;
@@ -69,9 +59,6 @@ export function parseSignupForm(
email: z.string(),
phone: z.string(),
notes: z.string(),
under18: z.boolean(),
guardianName: z.string(),
guardianEmail: z.string(),
})
.safeParse(input);
if (!parsed.success) return { ok: false, errors: { form: 'Check the signup fields and try again.' } };
@@ -103,47 +90,24 @@ export function parseSignupForm(
const phoneRaw = parsed.data.phone.normalize('NFC').trim();
const phone = phoneRaw.length === 0 ? '' : formatPhone(phoneRaw);
if (phoneRaw.length > PHONE_MAX || phone.length > PHONE_MAX) errors.phone = `Use ${PHONE_MAX} characters or fewer.`;
if (phoneRaw.length === 0 || phone.length === 0) {
errors.phone = voice === 'coordinator' ? 'Enter their phone number.' : 'Enter your phone number.';
} else if (phoneRaw.length > PHONE_MAX || phone.length > PHONE_MAX) errors.phone = `Use ${PHONE_MAX} characters or fewer.`;
else if (controlChars.test(phoneRaw)) errors.phone = 'Enter a phone number without line breaks.';
const notes = parsed.data.notes.normalize('NFC').trim();
if (notes.length > NOTES_MAX) errors.notes = `Use ${NOTES_MAX} characters or fewer.`;
else if (controlChars.test(notes)) errors.notes = 'Enter notes without control characters.';
let guardianName: string | null = null;
let guardianEmail: string | null = null;
let guardianEmailNorm: string | null = null;
if (parsed.data.under18) {
const guardianRaw = parsed.data.guardianName.normalize('NFC').trim();
guardianName = capitalizeName(guardianRaw);
if (guardianRaw.length === 0 || guardianName.length === 0) errors.guardianName = 'Enter the guardian name.';
else if (guardianRaw.length > NAME_MAX || guardianName.length > NAME_MAX) errors.guardianName = `Use ${NAME_MAX} characters or fewer.`;
else if (controlChars.test(guardianRaw)) errors.guardianName = 'Enter the guardian name without line breaks.';
if (parsed.data.guardianEmail.trim() === '') {
errors.guardianEmail = 'Enter the guardian email.';
} else {
try {
guardianEmailNorm = normalizeEmail(parsed.data.guardianEmail);
guardianEmail = guardianEmailNorm;
} catch (err) {
errors.guardianEmail = err instanceof EmailAddressError ? err.message : 'Enter the guardian email.';
}
}
}
if (Object.keys(errors).length > 0 || emailNorm.length === 0) return { ok: false, errors };
if (Object.keys(errors).length > 0 || emailNorm.length === 0 || phone.length === 0) return { ok: false, errors };
return {
ok: true,
draft: {
name,
email: emailNorm,
emailNorm,
phone: phone.length === 0 ? null : phone,
phone,
notes: notes.length === 0 ? null : notes,
isMinor: parsed.data.under18,
guardianName: parsed.data.under18 ? guardianName : null,
guardianEmail: parsed.data.under18 ? guardianEmail : null,
guardianEmailNorm: parsed.data.under18 ? guardianEmailNorm : null,
},
};
}
+2 -17
View File
@@ -24,7 +24,7 @@ import {
type SignupFormView,
type SwitchForm,
} from './pages.js';
import { recordInvalidManageToken, recordSignupEmail, recordSignupGuardian, recordSignupIp, recordSwitchAttempt } from './rate-limit.js';
import { recordInvalidManageToken, recordSignupEmail, recordSignupIp, recordSwitchAttempt } from './rate-limit.js';
import { getPublicShift, type PublicShift } from './schedule.js';
import { EMPTY_SIGNUP, parseSignupForm, type SignupErrors, type SignupValues } from './signup-form.js';
import type { MailIdentity } from './mail/types.js';
@@ -154,13 +154,6 @@ async function submitSignup(c: Context, services: SignupServices): Promise<Respo
if (emailLimit.limited) {
return shiftResponse(c, services, shift, 429, formFor(services, shift, values, {}, textField(body, 'form_token')), TOO_MANY, emailLimit.retryAfter);
}
const guardianEmail = parsed.draft.guardianEmailNorm;
if (guardianEmail && guardianEmail !== parsed.draft.emailNorm) {
const guardianLimit = recordSignupGuardian(db, config.sessionSecret, now, config.defaultTimeZone, guardianEmail);
if (guardianLimit.limited) {
return shiftResponse(c, services, shift, 429, formFor(services, shift, values, {}, textField(body, 'form_token')), TOO_MANY, guardianLimit.retryAfter);
}
}
try {
const reserved = reserveSignup(db, {
shiftId: shift.id,
@@ -168,9 +161,6 @@ async function submitSignup(c: Context, services: SignupServices): Promise<Respo
email: parsed.draft.emailNorm,
phone: parsed.draft.phone,
notes: parsed.draft.notes,
isMinor: parsed.draft.isMinor,
guardianName: parsed.draft.guardianName,
guardianEmail: parsed.draft.guardianEmail,
operationId: tokenResult.claims.operationId,
now,
mail: mailIdentity(db, config),
@@ -284,9 +274,6 @@ function valuesFrom(body: Record<string, unknown>): SignupValues {
email: textField(body, 'email'),
phone: textField(body, 'phone'),
notes: textField(body, 'notes'),
under18: textField(body, 'under18') === 'yes',
guardianName: textField(body, 'guardianName'),
guardianEmail: textField(body, 'guardianEmail'),
};
}
@@ -381,10 +368,8 @@ async function submitSwitch(c: Context, services: SignupServices): Promise<Respo
if (!formToken.ok) return showManage(c, services, token, 400, SWITCH_STALE);
try {
const ip = clientAddress(services.config.trustProxy, peerAddress(c, services.clientIp), c.req.header('x-forwarded-for'));
const recipients = [signup.emailNorm];
if (signup.isMinor && signup.guardianEmail) recipients.push(signup.guardianEmail);
const limit = recordSwitchAttempt(
services.db, services.config.sessionSecret, services.now(), services.config.defaultTimeZone, ip, recipients,
services.db, services.config.sessionSecret, services.now(), services.config.defaultTimeZone, ip, [signup.emailNorm],
);
if (limit.limited) {
c.header('Retry-After', String(limit.retryAfter));
+4 -22
View File
@@ -15,9 +15,6 @@ export type ReserveInput = {
email: string;
phone: string | null;
notes: string | null;
isMinor: boolean;
guardianName: string | null;
guardianEmail: string | null;
operationId: string;
now: string;
mail: MailIdentity;
@@ -36,9 +33,6 @@ export type ManageView = {
email: string;
phone: string | null;
notes: string | null;
isMinor: boolean;
guardianName: string | null;
guardianEmail: string | null;
status: 'confirmed' | 'cancelled';
remindersOff: boolean;
emailNorm: string;
@@ -109,9 +103,6 @@ export function readManageSignup(db: Database.Database, token: string, now: stri
su.email AS email,
su.phone AS phone,
su.notes AS notes,
su.is_minor AS is_minor,
su.guardian_name AS guardian_name,
su.guardian_email AS guardian_email,
su.status AS status,
su.reminders_off AS reminders_off,
su.email_norm AS email_norm,
@@ -138,9 +129,6 @@ export function readManageSignup(db: Database.Database, token: string, now: stri
email: row.email,
phone: row.phone,
notes: row.notes,
isMinor: row.is_minor === 1,
guardianName: row.guardian_name,
guardianEmail: row.guardian_email,
status: row.status,
remindersOff: row.reminders_off === 1,
emailNorm: row.email_norm,
@@ -214,9 +202,9 @@ function placeReservation(db: Database.Database, input: ReserveInput, emailNorm:
emailNorm,
emailNorm,
input.phone,
input.isMinor ? 1 : 0,
input.isMinor ? input.guardianName : null,
input.isMinor ? input.guardianEmail : null,
0,
null,
null,
input.notes,
sha256(manageToken),
expiresAt,
@@ -232,7 +220,6 @@ function placeReservation(db: Database.Database, input: ReserveInput, emailNorm:
token: manageToken,
volunteerName: input.name,
volunteerEmail: emailNorm,
guardianEmail: input.isMinor ? input.guardianEmail : null,
shift: shiftFacts(shift).facts,
mail: input.mail,
now: input.now,
@@ -282,7 +269,7 @@ function cancelConfirmed(db: Database.Database, hash: string, token: string, now
const row = db
.prepare(
`SELECT su.id AS id, su.status AS status, su.token_expires_at AS token_expires_at, su.anonymized_at AS anonymized_at,
su.name AS name, su.email_norm AS email_norm, su.guardian_email AS guardian_email, su.shift_id AS shift_id
su.name AS name, su.email_norm AS email_norm, su.shift_id AS shift_id
FROM signups su
WHERE su.manage_token_hash = ?`,
)
@@ -294,7 +281,6 @@ function cancelConfirmed(db: Database.Database, hash: string, token: string, now
anonymized_at: string | null;
name: string | null;
email_norm: string | null;
guardian_email: string | null;
shift_id: number;
}
| undefined;
@@ -322,7 +308,6 @@ function cancelConfirmed(db: Database.Database, hash: string, token: string, now
token,
volunteerName: row.name,
volunteerEmail: row.email_norm,
guardianEmail: row.guardian_email,
shift: shift.facts,
mail,
now,
@@ -405,9 +390,6 @@ type ManageRow = {
email_norm: string | null;
phone: string | null;
notes: string | null;
is_minor: number;
guardian_name: string | null;
guardian_email: string | null;
status: string;
reminders_off: number;
token_expires_at: string | null;