Skip to content

Conversation

@bokelley
Copy link
Contributor

@bokelley bokelley commented Jan 4, 2026

Summary

  • When a domain is added to an organization via admin, link all unmapped email contacts with that domain to the org
  • Show email activities on org detail pages via a UNION query that joins through email_contacts.organization_id
  • Remove duplicate write to org_activities in email webhook since the UNION query now handles it

This ensures prospect emails from Addie show up on org detail pages automatically:

  1. When a new email comes in and the domain is already registered
  2. When a domain is added to an org and historical contacts exist

Test plan

  • Typecheck passes
  • All tests pass
  • Local testing verified:
    • Created unmapped contact with test domain
    • Created email activity for that contact
    • Manually linked contact to org
    • Verified activity shows on org detail page via UNION query

🤖 Generated with Claude Code

- Add linkContactsByDomain() function in contacts-db.ts to link
  unmapped email contacts when a domain is added to an organization
- Update org detail page to show email activities via UNION query
  that joins through email_contacts.organization_id
- Remove duplicate write to org_activities in webhooks since the
  UNION query now handles showing email activities
- Add logging when contacts are linked during domain add

This ensures prospect emails show up on org detail pages automatically
when the org's domain is registered, and historical emails appear when
a domain is added to an existing org.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@bokelley bokelley merged commit e183893 into main Jan 4, 2026
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.

2 participants