Skip to content

Conversation

@evanhutnik
Copy link
Contributor

Summary

This PR adds per-message contact name storage to preserve the exact sender and recipient names as they appear in each email.

Changes:

  • Added from_name column to email_messages to store the sender's name as it appears in the message
  • Added name column to email_message_recipients to store recipient names as they appear in the message
  • Updated thread/message/preview APIs to prioritize message-specific names, falling back to email_contacts names when unavailable

Background:

Previously, we avoided storing contact names for generic emails in email_contacts due to an edge case where personal names could be associated with shared addresses:
image
This led to incorrect name display when multiple people used the same email address.

By storing names on a per-message basis, we now correctly handle this scenario—each message displays the name as it appeared when sent.

Migration & Backfill:

The migration includes a backfill for existing messages where possible. However, as mentioned, generic email names processed before this change were intentionally not stored in email_contacts and cannot be fully recovered. Rather than re-processing 6.7 million messages across 444 accounts, new messages going forward will have complete name data. Existing messages will show names where available in email_contacts. There is already logic in the FE to handle the case where no name exists for the contact, so this shouldn't result in any weird behaviour.

Screenshots, GIFs, and Videos

@evanhutnik evanhutnik requested a review from a team as a code owner December 3, 2025 20:15
@linear
Copy link

linear bot commented Dec 3, 2025

@evanhutnik evanhutnik merged commit 3f2a0c3 into main Dec 3, 2025
34 checks passed
@evanhutnik evanhutnik deleted the evan/ema-45-create-one-row-per-recipient-per-email-for-contacts branch December 3, 2025 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants