Skip to content

fix(gallagher/parking_approvals): prevent duplicate approval emails - #649

Merged
w-le merged 2 commits into
masterfrom
fix/gallagher/parking_approval
Nov 13, 2026
Merged

w-le merged 2 commits into
masterfrom
fix/gallagher/parking_approval

Conversation

@w-le

@w-le w-le commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Parking approval emails could be sent repeatedly when a stale booking snapshot was written back after a successful approval.

The Staff API merges incoming extension_data into the persisted booking. Allocation/restore were sending the entire extension_data hash from an older fetch, which could overwrite parking_notified and reset emails_sent. The next sweep then saw the booking as unapproved/wait-listed and sent another approval email.

Manual-allocation staff/booking/changed events also carry a point-in-time snapshot, which may already be stale by the time it is processed.

Changes

  • Re-read the persisted booking before processing manual-allocation change events, and use the persisted process_state/notification ledger to decide whether an email is still owed.
  • Serialise manual-allocation handling with a mutex so two events cannot both read the pre-send state.
  • Stop sending the full extension_data hash from allocate/restore_allocation.
  • Patch only allocation-owned metadata (location, parking_group) via booking_extension_data, leaving parking_notified, emails_sent, and other concurrent fields untouched.
  • Update the StaffAPI mock to reflect persisted state on re-fetch, including get_booking.
  • Add regression coverage for:
    • stale manual-allocation event payloads
    • resource_id/resource_ids event payloads
    • allocation not rewriting the full extension data snapshot

Why this matters

Without this, a stale sweep or stale event could erase a successful approval’s ledger entry, causing the user to receive the same “Parking space approved” email multiple times.

Testing

./harness report drivers/gallagher/parking_approvals_spec.cr
Result:
1 tested, 0 failures, 0 timeouts, 0 without spec
Deployment notes
- Driver-only change; no database migrations or setting changes.
- Publish the updated driver and restart the affected ParkingApprovals modules.

William Le added 2 commits November 2, 2026 23:22
…ng model and gallagher parking approval driver use .asset_ids. Update the shared Booking model to be compatible with the Booking signal params
@w-le
w-le requested a review from stakach November 12, 2026 06:39
@w-le w-le self-assigned this Nov 12, 2026
@w-le
w-le merged commit 32b7eb7 into master Nov 13, 2026
3 of 6 checks passed
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