Skip to content

feat(email): intake answers in the host's booking email, opt-in per event type (#264) - #283

Open
dominik-myszkowski wants to merge 3 commits into
Calnode:mainfrom
dominik-myszkowski:feat/host-email-intake-answers
Open

dominik-myszkowski wants to merge 3 commits into
Calnode:mainfrom
dominik-myszkowski:feat/host-email-intake-answers

Conversation

@dominik-myszkowski

@dominik-myszkowski dominik-myszkowski commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Implements the half of #264 you accepted: the attendee's intake answers in the host's new-booking email, opt-in per event type, off by default. The calendar event description is left alone, as agreed.

What it does

  • New column event_types.answers_in_host_email (migration 00076, default 0), exposed as answers_in_host_email on the event type API (GET, create, PATCH) and carried by duplication.
  • When it is on, each host's new-booking email gets an Answers block below the booking details (text and HTML), with questions in form order and unanswered optional ones left out. The new host's email on reassignment gets the same block, because they are the one about to meet the attendee.
  • Editor: a checkbox in the Notifications tab, with a hint that only hosts receive the answers and why it is off by default (en/fr).

Keeping it host-only

  • The answers travel in BookingData.HostAnswers. Only the host templates read that field.
  • It is set only on each host's copy in notifyHosts (and on the reassigned host's copy), never on the bData that the attendee's confirmation and .ics are built from.
  • The HTML part escapes answers, since they are attendee input.

Migration number

00076, after 00074 (#275) and 00075 (#281). If this lands before either of them, I'll renumber.

Tests

  • mailer:
    • the host email lists answers in both parts, a multi-line answer stays indented in the text part, and HTML is escaped;
    • without answers there is no empty heading and the text layout is unchanged;
    • no attendee template (confirmation, cancellation, reschedule, reminder) renders HostAnswers even when it is set.
  • handler, through the real dispatchBookingConfirmation:
    • opted in: the host gets the answer, the blank optional question is omitted, and neither the attendee's email nor its attachments contain it;
    • default: no answers;
    • reassignment: the new host gets them, the attendee doesn't;
    • the flag round-trips through create, GET and PATCH.
  • TestDuplicateEventType_* covers the new column.

Mutation check: dropping the line that sets the answers on the host's copy fails the opt-in test.

gofmt, go vet ./..., go build ./..., go test ./..., go run ./cmd/i18n-coverage, pnpm check, pnpm check:i18n, pnpm build, pnpm test:visual and make build pass locally.

…vent type (Calnode#264)

event_types.answers_in_host_email (migration 00076, default off) lists the
attendee's intake answers in each host's new-booking email, and in the new
host's email when a booking is reassigned. Unanswered questions are left out.

The answers travel in BookingData.HostAnswers, which only the host templates
read and which is set only on each host's copy in notifyHosts, never on the
data the attendee's email and .ics are built from. The calendar event
description is deliberately not used: the attendee sees it in their own
invite on Google, Microsoft and CalDAV.

Editor: a checkbox in the Notifications tab (en/fr). Duplicating an event
type carries the flag.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one merge-order note below and one minor inline comment.

Approach: sound — the answers ride a single BookingData.HostAnswers field that only the host templates read, so the host-only guarantee falls out of where the field is set rather than out of template discipline. Opt-in, default off, additive migration.

Reviewed changes

  • Schema + API — event_types.answers_in_host_email (migration 00076), surfaced on eventTypeJSON, etColumns, create, PATCH and duplication; the admin-side concatenation with etOwnerColumns stays valid because the new column is appended last.
  • Answer loading — Handler.hostEmailAnswers reads the flag then the booking's non-empty answers in form order; failures log and yield nil so the confirmation never blocks on this.
  • Host-only delivery — notifyHosts and reassign.go set HostAnswers on each host's copy only; the attendee's email and .ics are built from the untouched bData, and the ICS description still comes from calDetails().
  • Rendering — Answers block in the text template (continuation lines indented via Answer.IndentedValue) and in htmlConfirmHost; html/template auto-escapes, so attendee input cannot inject markup.
  • Editor — checkbox in the Notifications tab, en/fr strings, value round-tripped through loadET/saveET.
  • Tests — mailer rendering/escaping/no-block/no-attendee-leak, handler opt-in/off/reassign/flag round-trip, duplication column coverage.

ℹ️ 00076 sits above two unmerged migrations, and goose will refuse to boot over that gap

00074 (#275) and 00075 (#281) are still open, so main ends at 00073 and this PR is the highest number. That is fine on its own, but the "I'll renumber" plan only works in one direction: goose's Up returns an error when the embedded migrations contain a version below the database's highest applied version, and cmd/calnode/main.go:76 exits on that error. If this merges first, #275 and #281 must be renumbered above 00076; leaving them at 00074/00075 would fail startup for every deployment that already ran 00076.

Technical details
# Merge-order constraint on migration numbering

## Affected sites
- `internal/db/migrations/00076_event_type_answers_in_host_email.sql:12` — claims 00076 while 74/75 are absent from `main`.
- `internal/db/db.go:61` — `goose.Up(db, "migrations")`.
- `cmd/calnode/main.go:76` — `logger.Error` + `os.Exit(1)` when `Migrate` fails.

## Why the gap matters
`goose.Up` → `UpToContext` → `findMissingMigrations` (goose v3.29.0 `up.go`) collects embedded
versions `< dbMaxVersion` that are not in `goose_db_version` and returns
`"found N missing migrations before current version X"`. A DB migrated to 76 therefore errors on
the next boot once 74/75 appear in the binary, and `/readyz` stays false because
`SchemaReady` compares against `TargetVersion()`.

## Required outcome
- If this PR merges before #275/#281: theirs become 00077/00078 (any number above 00076).
- If #275/#281 merge first: this file is renumbered below them, per the PR description.
- Whichever way, no migration may be added below a version already applied anywhere.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash | 𝕏

Comment thread internal/handler/booking_handler.go Resolved
The admin booking view reads checkbox answers through checkboxTicked,
because older rows hold whatever the surface sent ("Yes", "1", "on").
The host email printed the raw token; it now reads them the same way.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Normalised checkbox answers to Yes/No in the host's email: hostEmailAnswers now selects q.type and maps through the existing checkboxTicked helper, so legacy tokens (on, 1, checked, Yes) can no longer read as the opposite of what the guest ticked. The reassignment path gets the same treatment since it calls the same helper.
  • Added TestHostEmailAnswers_checkboxReadsAsYesNo, covering on → Yes, no → No, and a text answer passing through untouched.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash | 𝕏

…e-answers

# Conflicts:
#	frontend/src/lib/api.ts
#	internal/handler/event_type.go
#	internal/handler/event_type_duplicate_test.go

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — since the prior pullfrog review at afbd40f the only change is e55e3b2, a merge of origin/main (now ce0e135, carrying #275's next-available setting and its migration 00074). No PR-authored code changed, so this run verified the resolution rather than re-reading the feature.

  • Column lists still line up — etColumns (35 columns) and scanEventTypeRow's 35 dest pointers agree in order, the create INSERT has 25 columns, 25 placeholders and 25 arguments, and event_type_duplicate.go copies 38 columns into 38 values with answers_in_host_email last. Neither setting was dropped or shifted by the merge.
  • Editor and catalogue keep both settings — the Notifications tab still loads, binds and submits answersInHostEmail beside main's form.show_next_available, and en/fr carry both key sets in their own blocks with no duplicate keys.
  • Duplication guard — the copied map in TestDuplicateEventType_handlesEveryEventTypeColumn lists both answers_in_host_email and show_next_available, matching the SQL.
  • Verified green on the merged tree — go test ./internal/handler/ ./internal/db/ ./internal/mailer/, node --test internal/handler/assets/booking-logic.test.js (21 pass), gofmt -l . empty, go vet clean. The frontend gates (pnpm check, check:i18n, test:visual) need node_modules, which this checkout does not have, so they were not re-run here.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash | 𝕏

shockalotti added a commit that referenced this pull request Dec 1, 2026
#281 holds 00075, and the queue runs 00076 #283, 00077 #285, 00078 #286.
This must merge after those, so it takes 00079. A lower number landing later
leaves a gap and goose refuses to boot.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant