From e47c05c58a67489c7e91739fa04ce477160c1b85 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Thu, 29 Oct 2026 02:50:16 +0100 Subject: [PATCH] fix: choose the reply From by an address the original names only in Bcc #87 --- src/lib/__tests__/reply-compose.test.ts | 21 ++++++++++++++++++++- src/lib/reply-compose.ts | 4 ++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/lib/__tests__/reply-compose.test.ts b/src/lib/__tests__/reply-compose.test.ts index 80abf7a3..16d65bda 100644 --- a/src/lib/__tests__/reply-compose.test.ts +++ b/src/lib/__tests__/reply-compose.test.ts @@ -1,6 +1,7 @@ import { describe, it, expect } from 'vitest'; -import type { Email } from '../../api/types'; +import type { Email, Identity } from '../../api/types'; import { replyComposeParams } from '../reply-compose'; +import { resolveReplyIdentity } from '../reply-identity'; const source = { id: 'm1', @@ -26,6 +27,24 @@ describe('replyComposeParams', () => { expect(replyComposeParams('reply', source)?.prefillBody).toBeUndefined(); expect(replyComposeParams('reply', source, undefined, ' ')?.prefillBody).toBeUndefined(); }); + + it('lets the reply From match an address the message names only in Bcc (native #87)', () => { + const viaBcc = { + ...source, + to: [{ name: 'owner/repo', email: 'repo@noreply.github.com' }], + bcc: [{ email: 'github@example.com' }], + } as Email; + const params = replyComposeParams('reply', viaBcc); + expect(params?.replyTo?.bcc).toEqual([{ email: 'github@example.com' }]); + const identities = [ + { id: 'main', name: 'Me', email: 'me@example.com', mayDelete: false }, + ] as Identity[]; + const resolved = resolveReplyIdentity(identities, params!.replyTo!, { + ownEmails: ['me@example.com'], catchAll: true, matchMode: 'domain', + }); + expect(resolved?.identityId).toBe('main'); + expect(resolved?.overrideEmail).toBe('github@example.com'); + }); }); describe('replyComposeParams: quoted inline images', () => { diff --git a/src/lib/reply-compose.ts b/src/lib/reply-compose.ts index c328d619..f46c6d97 100644 --- a/src/lib/reply-compose.ts +++ b/src/lib/reply-compose.ts @@ -49,6 +49,10 @@ export function replyComposeParams( from: from ?? { email: '' }, to: source.to, cc: source.cc, + // Never a recipient of the reply, but the composer picks the identity + // (and the catch-all From) by the address the message was delivered + // to, and a Sieve rule or a list may name that one only in Bcc. + bcc: source.bcc, // RFC 5322: a reply goes to Reply-To when the sender set one. replyToAddresses: source.replyTo, subject: source.subject ?? '',