fix(config): store mailing-list addresses in dedicated Contact.Addresses slice#1277
fix(config): store mailing-list addresses in dedicated Contact.Addresses slice#1277mvanhorn wants to merge 2 commits into
Conversation
…ses slice SearchContacts emitted mailing-list virtual contacts with the joined "a@x.com, b@y.com" string crammed into Contact.Email, breaking the single-address invariant. Any downstream code that calls normalizeContactEmail lowercased and trimmed commas off the joined string, corrupting the data, and exact-match lookups against the contact would never find it. Add an Addresses []string field to Contact and populate it for mailing lists; leave Email empty so the single-address invariant holds. Detect mailing lists in the composer via len(Addresses) > 0 instead of "does the email field contain a comma". Render mailing-list suggestions as "Name (addr1, addr2, ...)" so it's clear they expand to multiple recipients. Fixes floatpane#1123
floatpanebot
left a comment
There was a problem hiding this comment.
Hi @mvanhorn! Please fix the following issues with your PR:
- Title: Is too long (78 characters). The PR title must be strictly under 40 characters.
…list-addresses-field # Conflicts: # config/cache.go
floatpanebot
left a comment
There was a problem hiding this comment.
Hi @mvanhorn! Please fix the following issues with your PR:
- Title: Is too long (78 characters). The PR title must be strictly under 40 characters.
|
Resolved and pushed a29f108. The conflict was structural -- since this PR opened, master refactored Merged shape: type Contact struct {
Name string `json:"name"`
Email string `json:"email"`
Addresses []string `json:"addresses,omitempty"`
Usage map[string]ContactUsage `json:"usage_by_account"`
}Mailing-list virtual contacts in
|
What?
SearchContactsbuilds mailing-list virtual contacts by jammingstrings.Join(list.Addresses, ", ")intoContact.Email. That breaks the field's single-address invariant:normalizeContactEmaillowercases and trims commas off the joined string (corrupting the data), and any exact-match lookup against the contact will never find it.This adds a dedicated
Addresses []stringfield toContact, populates it for mailing-list virtual contacts, and leavesEmailempty so the invariant holds. The composer learns to detect mailing lists vialen(selected.Addresses) > 0instead of "does the email field contain a comma", joins the addresses at insertion time, and renders the suggestion asName (addr1, addr2, ...)so it's clear that a single suggestion expands to multiple recipients.Files touched:
config/cache.go-- newAddressesfield onContact; mailing-list construction inSearchContactsswitches to ittui/composer.go-- detection/insertion and rendering swap fromEmailcommas toAddressesThe cache file format is backwards-compatible: the new field is
omitempty, and saved contacts (added viaAddContact) never carryAddressesbecause they're built from a single email parameter. Mailing-list virtual contacts are constructed in-memory on every search and never written to disk.Why?
Closes #1123. The reporter pointed out the data-integrity bug; this implements option 2 of the two fixes they suggested (dedicated
Addressesslice, keepEmailempty), which is the smaller of the two and doesn't require a separate "virtual contact" type.Verification
go build ./config/... ./tui/...: passesgo vet ./config/... ./tui/...: passesgo test ./config/...: 51/51 passinggo test ./tui/...: 79/79 passingDisclosure
Authored with Claude as a coding assistant; I reviewed the change before pushing.