Skip to content

Exclude Gmail send-as aliases from received-message participants#2856

Merged
atomantic merged 2 commits into
mainfrom
next/issue-2831
Jul 22, 2026
Merged

Exclude Gmail send-as aliases from received-message participants#2856
atomantic merged 2 commits into
mainfrom
next/issue-2831

Conversation

@atomantic

Copy link
Copy Markdown
Owner

Summary

Fixes a Tribe-outreach gap where a genuinely unanswered 1:1 email delivered to one of the owner's Gmail send-as aliases (rather than the primary account.email) was never surfaced as an outreach nudge.

In messageActivityCandidates, a received message's participants were computed as [from, ...to, ...cc] filtered to drop only account.email. When a 1:1 message was delivered to a send-as alias, the alias survived the filter, so the message had two counterparts (sender + owner alias) and findUnansweredTribeThreads treated it as a group thread and skipped it. The prior #2796 alias handling only covered the SENT direction (via Gmail's SENT label); the received-to-alias case was unhandled, and the account stored only a single email to filter against.

Changes

  • Fetch & persist aliasesmessageGmailSync.js calls gmail.users.settings.sendAs.list on each sync (best-effort; a null sentinel on failure keeps the stored set rather than clobbering it). Persisted onto the account as sendAsAliases (lowercased, deduped) via a new updateSendAsAliases in messageAccounts.js.
  • Filter the whole owner setmessageActivityCandidates now builds an owner-address set of { selfEmail, ...sendAsAliases } and excludes all of them from received-message participants. The existing SENT-label direction logic is unchanged.
  • Back-compat — absent sendAsAliases degrades to today's behavior (filter on primary email only); missing/failed alias fetch never crashes and produces no false person records. Additive account field, no migration needed.
  • Zod schema (routes/messages.js) extended with the additive sendAsAliases array for parity.

Follow-up

Test plan

  • server/services/humanActivity.test.js — new cases: a received 1:1 delivered to an alias stays a single-counterpart 1:1; back-compat (no aliases stored → only primary email filtered).
  • server/services/messageGmailSync.test.js — new fetchSendAsAliases cases: lowercased aliases returned, empty array vs null sentinel on API failure.
  • Full server suite green (humanActivity, messageGmailSync, messageSync, messageAccounts, routes/messages — 149 tests).

Closes #2831

…participants

A received 1:1 email delivered to a Gmail send-as alias (not the primary
account.email) kept the alias as a second participant, so
findUnansweredTribeThreads treated it as a group thread and never produced an
outreach nudge. Fetch and persist the account's send-as aliases on sync and
exclude the whole owner-address set when normalizing received participants.

Closes #2831
@atomantic
atomantic merged commit a66372b into main Jul 22, 2026
2 checks passed
@atomantic
atomantic deleted the next/issue-2831 branch July 22, 2026 00:07
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.

Tribe outreach: exclude Gmail send-as aliases from received-message participants

1 participant