Skip to content

Fix MAIL-ADDR-PERSIST: Persist USPS-corrected address back to contact#164

Open
bmoss2015 wants to merge 1 commit into
mainfrom
fix/persist-corrected-address
Open

Fix MAIL-ADDR-PERSIST: Persist USPS-corrected address back to contact#164
bmoss2015 wants to merge 1 commit into
mainfrom
fix/persist-corrected-address

Conversation

@bmoss2015

Copy link
Copy Markdown
Owner

Summary

  • When the operator clicked Use Corrected Version in Send Mail, the corrected address only lived in the modal's local addressOverrides state. On the next send to the same recipient, the contact still held the original undeliverable address and the fix panel re-appeared.
  • New persistContactAddress server action in src/app/(app)/mail/_verify-action.ts rewrites contacts.value with the canonical "line1, city, ST ZIP" form via formatAddressForStorage().
  • SendMailModal.applyAddressSuggestion() now calls persistContactAddress before re-running verify, and the re-run passes contact_id + force: true so the verify cache repopulates against the fresh value in one round trip.
  • The existing BEFORE UPDATE trigger on public.contacts (migration 0133) clears the address_verify_* cache fields automatically when value changes, so the cache lookup on the next send won't return a stale hit.

Test plan

  • In Send Mail, pick a recipient whose address gets USPS-corrected. Click Use Corrected Version.
  • Close the modal. Open Send Mail for the same recipient again. Confirm the displayed address is the corrected one, the verify pill is green, and no fix panel appears.
  • Send a letter to the corrected address and confirm it goes through end to end.

Preview creds: info@mossyland.com / MossEquity-858dc58d33!

After the operator clicks "Use Corrected Version" in Send Mail, the
Lob-suggested address now writes back to contacts.value via a new
persistContactAddress server action, so the next time the same recipient
shows up in Send Mail the corrected address loads in place of the
original. Previously the correction lived only in the modal's local
addressOverrides state and was thrown away on close, so every send to
the same person re-asked for the correction.

The action serializes the address through formatAddressForStorage() to
the canonical "line1, city, ST ZIP" form. The existing BEFORE UPDATE
trigger on public.contacts (migration 0133) clears the address_verify_*
cache fields automatically when contacts.value changes, so the next
verifyAddressAction call computes against the fresh address. After
persisting, we re-run verifyAddressAction with the contact_id and
force: true so the cache repopulates with the fresh result in one round
trip.
@vercel

vercel Bot commented Jun 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
moss-equity-portal Ready Ready Preview, Comment Jun 19, 2026 6:07pm

Request Review

@supabase

supabase Bot commented Jun 19, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project rsdmyydyhqgkkvwlklif because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

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