Skip to content

fix(mail): a removed alias stops being the owner's; sync keeps auto-replied, List-Post, schema.org and calendar method - #3384

Open
leemour wants to merge 2 commits into
mainfrom
fix/mail-own-addresses-signals
Open

leemour wants to merge 2 commits into
mainfrom
fix/mail-own-addresses-signals

Conversation

@leemour

@leemour leemour commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Task

Why

  • Removed alias. ownAddresses joined the stored mail_own_addresses with the configured list, and settleOwnMail wrote the union back. After config unset aliases, the address stayed the owner's for good: its mail stayed outgoing and its person stayed joined to the owner.
  • Signals. An out-of-office with Auto-Submitted: auto-replied was found by its subject only. A discussion list needed three stored senders. Synced mail kept no schema.org markup (the store keeps no HTML of synced mail) and no calendar method.

What

Removed aliases (src/mail/own.ts, src/store/sqlite/email-state.ts)

  • A defined MailAccount.addresses is now the whole list. A sync without it, and an mbox import, drop nothing: a caller that does not know every alias removes none.
  • The list a sync is given is kept under the new sync-state key mail_own_configured.
  • An address that was in that list, is not in it now, and has no live mail in Sent leaves mail_own_addresses.
  • The account's mail from such an address, outside Sent and label:Sent, is incoming again (markOwnMail takes removed).
  • Its email identity leaves the owner only when the rules joined it (method account, by rules). A link the owner made stays.
  • Limit: the join had moved every identity of the alias's person. Only the email identity moves back.
  • A store from before mail_own_configured treats every stored address as possibly configured, once. On that first run, an address vouched for only by a Sent folder the run does not read is dropped.
  • settleOwnMail takes configured in its options.

Signals kept in emails.headers (no store version, the same path as #3379)

  • auto-replied: true: a signed Auto-Submitted: auto-replied, under the DKIM rule programSignalsOf uses. It is not under auto-submitted, because bot detection and reach read that key, and a person's out-of-office must not make them a bot.
  • list-post: true: List-Post names where to post, and does not say NO (RFC 2369). Kept unsigned, like List-Id.
  • schema-types: the schema.org type names from JSON-LD or microdata, at most 10.
  • schema-fields: the first orderNumber, orderStatus, trackingNumber, reservationNumber and reservationStatus, up to 100 characters each. Never the HTML.
  • calendar-method: the method of the text/calendar part (request, cancel, reply), from the Content-Type parameter or the part's METHOD line.
  • These are read in parseMail (src/mail/body-signals.ts) and merged in parsedEmail and retry.ts, so sync, partial completion, whole reads and server search all keep them.

Classifier

  • auto-replied → auto_reply (signal auto-replied).
  • List-Id mail with list-post, no Feedback-ID and no one-click unsubscribe → discussion_list (signal list-post), before three senders are stored.
  • Stored schema-types count as the types of a kept body_html.
  • calendar-method is stored only. No type reads it yet.

Perf fix on the way: JSON_LD_OPEN was <script[^>]*…, which rescans a run of <script with no > to the end. parseMail now runs it on every email, and the 200k hostile-HTML test in parse.test.ts took 5 s. It is now [^<>]*.

Mail stored earlier gets none of these keys until mail sync reads it again.

Downstream: mail-cli gets this with the next cli-core release and its bump. The Gmail sendAs part of #3321 is WireCatLabs/mail-cli#208. Its messages send path passes the saved send-as list, because a given list is now treated as complete.

Testing

  • src/mail/own.test.ts: no list and an mbox import drop nothing; a removed alias (its mail is incoming, no tie, the identity is off the owner); a removed alias still in Sent stays the owner's; the owner's manual link survives; a store without mail_own_configured.
  • src/mail/headers.test.ts: signed auto-replied kept apart; List-Post kept, NO dropped.
  • src/mail/mail-types.test.ts: list-post, list-post with Feedback-ID, auto-replied.
  • src/store/mail-types.test.ts: an end-to-end sync keeps all five signals, no <script in the headers, and types the mail order, shipping, calendar, auto_reply and discussion_list.
  • pnpm typecheck, biome check ., and src/mail plus the store mail tests with one worker (37 files, 371 tests). Also docs-check, check-dist and cli-dev api-report (no API change).

🤖 Generated with Claude Code

leemour and others added 2 commits November 26, 2026 17:30
…eplied, List-Post, schema.org and calendar method

An alias the owner removes from config stopped counting nowhere: ownAddresses joined the stored
mail_own_addresses with the configured list, and settleOwnMail wrote the union back. The sync now
keeps the configured list under mail_own_configured. An address that left it and has no live mail
in Sent leaves mail_own_addresses, its mail outside Sent is incoming again (markOwnMail `removed`),
and its email identity leaves the owner when the rules joined it. The owner's own link stays.
Part of #3321.

Mail sync keeps in emails.headers what #3358 listed as not stored, with no store version:
- auto-replied: a signed Auto-Submitted: auto-replied, apart from auto-submitted, so an
  out-of-office makes no bot;
- list-post: List-Post naming where to post (not NO);
- schema-types and schema-fields: the schema.org type names (at most 10) and orderNumber,
  orderStatus, trackingNumber, reservationNumber, reservationStatus, never the HTML;
- calendar-method: the text/calendar part's method.

The classifier reads them: auto-replied is auto_reply, List-Id mail with List-Post and no campaign
marker is a discussion_list, and stored schema types count as body_html's do. The JSON-LD opener
regex no longer rescans a run of `<script` to the end, now that parseMail runs it on every mail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ports drop nothing

A sync that passes no MailAccount.addresses, and an mbox import, must not read as the owner
removing every alias. Removal now runs only when the caller gives the whole list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant