Skip to content

Delete a booking for a GDPR erasure request - #280

Open
Mehr-Vertrieb wants to merge 1 commit into
Calnode:mainfrom
Mehr-Vertrieb:delete-booking-erasure
Open

Mehr-Vertrieb wants to merge 1 commit into
Calnode:mainfrom
Mehr-Vertrieb:delete-booking-erasure

Conversation

@Mehr-Vertrieb

Copy link
Copy Markdown

What

Owners and admins can permanently delete a booking from the Bookings list (trash icon with a destructive ConfirmDialog; DELETE /v1/bookings/{id}, admin only).

One transaction removes:

  • the booking, and through ON DELETE CASCADE its attendees, intake answers, manage tokens and host assignments;
  • the rows that name the person but have no cascade:
    • webhook deliveries (their payload holds the attendee's name and email) and the webhook.deliver jobs that would send them;
    • reminder.send jobs;
    • idempotency records (their stored response holds the booking);
    • transcripts and notes.

No email is sent and no webhook fires: the person asked for their data to be removed, not to be told about a cancellation.

Why

Under the GDPR (Art. 17, right to erasure), an operator in the EU has to delete a person's personal data on request without undue delay. Today Calnode can only cancel a booking. After a cancellation the attendee's name, email, answers and webhook payloads stay in the database indefinitely, and there is no way to remove them short of editing SQLite by hand. That makes Calnode hard to run for EU operators who receive deletion requests, for example from people who booked a sales call and later ask to be forgotten.

What it refuses, and why

Each refusal is a 409 with a stable code; the admin UI turns it into the step to take first:

Code Case Reason
cancel_first upcoming confirmed booking Deleting it silently would leave the meeting in the booker's calendar while it disappears for the host. Cancelling first tells the booker, removes the calendar event, refunds and fires the cancellation webhook. The UI only offers the trash icon on cancelled or already-ended bookings.
paid_booking booking with a payment record Payment records usually have their own retention duties, so this path does not drop them silently.
recordings_first booking with recordings Recordings are files in object storage; removing only the row would orphan the file.
calendar_pending cancelled booking whose calendar event removal failed and is still pending Deleting the row would lose the event id the reconciler needs, leaving the event on the calendar for good.

Deliberately not touched

  • Calendar event of a past meeting: it stays on the host's calendar. Removing it through the provider (Google uses sendUpdates=all) would email the guest a cancellation for a meeting that already happened. The confirmation dialog tells the admin to delete it there without notifying guests.
  • Backups: Litestream replicas keep the data until their own retention ends. That is normal for backups, and the CHANGELOG entry says so.

Notes

Checks

  • gofmt -l . clean, go vet ./..., go build ./....
  • New internal/handler/booking_delete_test.go:
    • everything listed above is gone after a delete, and another booking's rows stay;
    • no cancellation webhook is fired;
    • a second delete is a 404;
    • each refusal code is returned;
    • members get a 403.
  • go test ./... is green except TestCreateWebhook_*, TestDeleteWebhook_success, TestListWebhook*, which fail identically on unmodified main in my sandbox (no DNS for the webhook URL check).
  • pnpm check (0 errors), pnpm check:i18n, catalogue unit tests.
  • Clicked through in a local instance:
    • no trash icon on an upcoming booking;
    • a past booking was deleted;
    • a booking with a recording was refused with the "delete the recordings first" message.

Owners and admins can permanently remove a booking from the Bookings list
(DELETE /v1/bookings/{id}). One transaction removes the booking, its
cascaded rows (attendees, answers, manage tokens, host assignments) and
the rows that name the person without a cascade: webhook deliveries and
their queued jobs, reminder jobs, idempotency records, transcripts and
notes. No email, no webhook.

Refused with a 409 code naming the step to take first: upcoming
confirmed bookings (cancel first), paid bookings (payment record),
bookings with recordings (files in object storage) and cancelled
bookings whose calendar event removal is still pending. A past meeting's
calendar event is left alone, because removing it through the provider
would email the guest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015iakVADVRvb5zkK5sEwxtg

@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.

Important

A successful DELETE /v1/bookings/{id} can return 204 while the participant's display name written into meeting_consents for the booking's video room is still in the database. That store survives both this transaction and the recording deletion the recordings_first refusal points the admin to — see the inline comment.

Approach: sound — one ordered transaction, an explicit refusal with a stable code for each unsafe state, and no notification side effects. The structural gap is that the removal list is hand-maintained and misses a store keyed to the booking's room.

Reviewed changes

  • Erasure service — booking.Service.Delete refuses upcoming, paid, recorded and calendar-pending bookings, then removes the non-cascading rows and the booking in one transaction.
  • Admin endpoint — DELETE /v1/bookings/{id}, admin-only, each refusal as a 409 code the UI can act on.
  • Bookings UI — trash action on cancelled/ended free bookings with a destructive ConfirmDialog; the refusal codes map to translated next steps.
  • Strings and changelog — en/fr catalogue entries and the CHANGELOG "Added" entry.
  • Tests — handler coverage for the row cleanup, the four refusals, the second-delete 404, and member 403.

ℹ️ Cancel-then-delete can still notify the person whose data was erased

Upcoming bookings must be cancelled before deletion, and CancelBooking starts the cancellation side effects in a goroutine after it responds. A delete that lands after loadCancellationData has read the attendee but before SendCancellationToAttendee runs still emails the erased name and address; one that lands before the webhook enqueue makes booking.cancelled fail the webhook_deliveries.booking_id foreign key and be dropped. The window is seconds, but this is the exact flow the cancel_first refusal prescribes.

Technical details
# Cancel side effects are not fenced by the delete

## Affected sites
- internal/handler/booking_handler.go:1821 — `go h.cancelSideEffects(*b)` after the cancel response
- internal/handler/booking_handler.go:2153 — `loadCancellationData` ignores a missing attendee row
- internal/handler/booking_handler.go:1932 — `SendCancellationToAttendee` runs after the per-host calendar calls
- internal/handler/booking_handler.go:1949 — `Enqueue("booking.cancelled", ...)` inserts `webhook_deliveries.booking_id`, which fails once the booking row is gone (`internal/webhook/webhook.go:461`)

## Required outcome
- A delete that follows a cancel must not send cancellation mail, or lose the `booking.cancelled` webhook, because it raced the background goroutine.

## Suggested approach (optional)
- Mark cancellation side effects as pending and have `Delete` refuse until they settle, or have `cancelSideEffects` confirm the booking still exists before sending.

## Open question
- Whether an already-claimed `webhook.deliver` job (the payload is read before the POST) should be treated the same way, since it can also deliver after the `204`.

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

{"webhook deliveries", `DELETE FROM webhook_deliveries WHERE booking_id = ?`},
{"idempotency keys", `DELETE FROM idempotency_keys WHERE booking_id = ?`},
{"transcripts", `DELETE FROM transcripts WHERE booking_id = ?`},
{"notes", `DELETE FROM notes WHERE booking_id = ?`},

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.

meeting_consents stores the display name each participant types into the LiveKit room, keyed by room = 'booking-<id>', and nothing deletes those rows: not the recording deletion the recordings_first refusal sends the admin to, and not this transaction. So a successful delete returns 204 while the person's name is still in the database — the outcome this feature exists to prevent. Add a step for the booking's room and seed a consent row in the handler test.

Technical details
# meeting_consents is not part of the erasure

## Affected sites
- internal/booking/delete.go:95-103 — the steps slice removes jobs, webhook deliveries, idempotency keys, transcripts and notes, but not meeting_consents
- internal/db/migrations/00044_meeting_consents.sql:5 — keyed (room, participant_identity); no FK to bookings, so the cascade never reaches it
- internal/handler/livekit_recording.go:207 — the only writer; room is `booking-<id>` (internal/handler/booking_handler.go:1168)
- internal/handler/livekit_recording.go:439 — `deleteRecordingArtifacts` removes the file, transcripts, notes and the recordings row only; there is no `DELETE FROM meeting_consents` anywhere in the repo

## Required outcome
- After `Delete` commits, no `meeting_consents` row remains for the booking's room.
- `internal/handler/booking_delete_test.go` seeds a consent row for the booking room and asserts it is gone (the fixture currently never creates one).

## Suggested approach
- Add `{"meeting consents", `DELETE FROM meeting_consents WHERE room = 'booking-' || ?`}` to the steps slice, before the bookings delete.

## Open question
- The room holds hosts and attendees alike; erasing the whole room's consent log is the simplest reading of the erasure request, but confirm that is the intent.
Suggested change
{"notes", `DELETE FROM notes WHERE booking_id = ?`},
{"notes", `DELETE FROM notes WHERE booking_id = ?`},
{"meeting consents", `DELETE FROM meeting_consents WHERE room = 'booking-' || ?`},

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