Associate lead correspondence, and fix the dead push indexer

FeatureEmailService
Shipped
August 5, 2026 at 6:03 PM UTC
Author
Kamo
Commit
2ed8c00

Adds the mail half of the lead Communications tab, plus the ingestion it needed to exist at all. The platform has no working mail push: IMAP IDLE is hardcoded to Dovecot, there is no Graph change-notification or Gmail watch, and MessageIndexer discarded every notification it ever received because the IDLE publisher omitted the UID its uid<=0 guard rejects — it also resolved the member from the sender rather than the mailbox owner. Both are fixed here, but a hook on that path alone would still have done nothing for most tenants, so association is driven by a sweep over each mailbox through MailReader, which is provider-agnostic by construction. The sweep pages on a timestamp, not a UID. UIDs are monotonic only within an IMAP UIDVALIDITY epoch; a ratcheting high-water mark risks silencing a mailbox re-examining is free because linking is idempotent. CompanyAddressResolver implements the owner's rule: never associate a message where the lead's matched address and every other participant are all company-owned — otherwise adding a colleague's work address to a lead would expose their internal mail. It fails CLOSED: an inventory it could not load answers "unknown" and association is skipped, rather than answering "external" and silently disabling the guard. **************** fetches a body on behalf of the mailbox that holds it. The ordinary endpoint resolves the provider for the caller, and UIDs are unique only within a folder, so aiming it at another member's UID returns an unrelated message instead of an error. Authorisation lives in SecurityService, which resolves the mailbox from the association rather than from the browser. Linking at send time was tried and removed: SMTP returns neither a Message-ID nor a Sent UID, so every outbound mail to a lead collapsed onto one association with no locator to expand. The sweep owns it.

All changes

Like what you see shipping?

Every one of these updates lands in your workspace automatically. Start free and watch it grow week after week.

Start Free ForeverView Pricing