fix: add replyToAddresses to email composer
This commit is contained in:
@@ -1551,6 +1551,7 @@ export default function Home() {
|
|||||||
mode={pendingDraft?.mode ?? composerMode}
|
mode={pendingDraft?.mode ?? composerMode}
|
||||||
replyTo={pendingDraft?.replyTo ?? (selectedEmail ? {
|
replyTo={pendingDraft?.replyTo ?? (selectedEmail ? {
|
||||||
from: selectedEmail.from,
|
from: selectedEmail.from,
|
||||||
|
replyToAddresses: selectedEmail.replyTo,
|
||||||
to: selectedEmail.to,
|
to: selectedEmail.to,
|
||||||
cc: selectedEmail.cc,
|
cc: selectedEmail.cc,
|
||||||
bcc: selectedEmail.bcc,
|
bcc: selectedEmail.bcc,
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ interface EmailComposerProps {
|
|||||||
mode?: 'compose' | 'reply' | 'replyAll' | 'forward';
|
mode?: 'compose' | 'reply' | 'replyAll' | 'forward';
|
||||||
replyTo?: {
|
replyTo?: {
|
||||||
from?: { email?: string; name?: string }[];
|
from?: { email?: string; name?: string }[];
|
||||||
|
replyToAddresses?: { email?: string; name?: string }[];
|
||||||
to?: { email?: string; name?: string }[];
|
to?: { email?: string; name?: string }[];
|
||||||
cc?: { email?: string; name?: string }[];
|
cc?: { email?: string; name?: string }[];
|
||||||
bcc?: { email?: string; name?: string }[];
|
bcc?: { email?: string; name?: string }[];
|
||||||
@@ -107,13 +108,15 @@ export function EmailComposer({
|
|||||||
// Initialize with reply/forward data if provided
|
// Initialize with reply/forward data if provided
|
||||||
const getInitialTo = () => {
|
const getInitialTo = () => {
|
||||||
if (!replyTo) return "";
|
if (!replyTo) return "";
|
||||||
|
// RFC 5322: use Reply-To header if present, otherwise fall back to From
|
||||||
|
const replyTarget = replyTo.replyToAddresses?.length
|
||||||
|
? replyTo.replyToAddresses.filter(r => r.email).map(r => r.email).join(", ")
|
||||||
|
: replyTo.from?.[0]?.email || "";
|
||||||
if (mode === 'reply') {
|
if (mode === 'reply') {
|
||||||
const email = replyTo.from?.[0]?.email || "";
|
return replyTarget ? replyTarget + ', ' : "";
|
||||||
return email ? email + ', ' : "";
|
|
||||||
} else if (mode === 'replyAll') {
|
} else if (mode === 'replyAll') {
|
||||||
const from = replyTo.from?.[0]?.email || "";
|
|
||||||
const originalTo = replyTo.to?.filter(r => r.email).map(r => r.email).join(", ") || "";
|
const originalTo = replyTo.to?.filter(r => r.email).map(r => r.email).join(", ") || "";
|
||||||
const combined = [from, originalTo].filter(Boolean).join(", ");
|
const combined = [replyTarget, originalTo].filter(Boolean).join(", ");
|
||||||
return combined ? combined + ', ' : "";
|
return combined ? combined + ', ' : "";
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
+17
-7
@@ -1648,19 +1648,28 @@ export class JMAPClient implements IJMAPClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let finalIdentityId = identityId;
|
let finalIdentityId = identityId;
|
||||||
if (!finalIdentityId) {
|
let identityReplyTo: EmailAddress[] | undefined;
|
||||||
|
{
|
||||||
const identityResponse = await this.request([
|
const identityResponse = await this.request([
|
||||||
["Identity/get", { accountId: this.accountId }, "0"]
|
["Identity/get", { accountId: this.accountId }, "0"]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
finalIdentityId = this.accountId;
|
if (!finalIdentityId) {
|
||||||
|
finalIdentityId = this.accountId;
|
||||||
|
}
|
||||||
if (identityResponse.methodResponses?.[0]?.[0] === "Identity/get") {
|
if (identityResponse.methodResponses?.[0]?.[0] === "Identity/get") {
|
||||||
const identities = (identityResponse.methodResponses[0][1].list || []) as { id: string; email: string }[];
|
const identities = (identityResponse.methodResponses[0][1].list || []) as Identity[];
|
||||||
if (identities.length > 0) {
|
if (identities.length > 0) {
|
||||||
const target = fromEmail || this.username;
|
if (!identityId) {
|
||||||
const matchingIdentity = identities.find((id) => id.email === target)
|
const target = fromEmail || this.username;
|
||||||
|| (!target.includes('@') ? identities.find((id) => id.email.split('@')[0] === target) : undefined);
|
const matchingIdentity = identities.find((id) => id.email === target)
|
||||||
finalIdentityId = matchingIdentity?.id || identities[0].id;
|
|| (!target.includes('@') ? identities.find((id) => id.email.split('@')[0] === target) : undefined);
|
||||||
|
finalIdentityId = matchingIdentity?.id || identities[0].id;
|
||||||
|
identityReplyTo = matchingIdentity?.replyTo || identities[0].replyTo;
|
||||||
|
} else {
|
||||||
|
const matchedIdentity = identities.find((id) => id.id === identityId);
|
||||||
|
identityReplyTo = matchedIdentity?.replyTo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1668,6 +1677,7 @@ export class JMAPClient implements IJMAPClient {
|
|||||||
// Always create a new email with the final body content
|
// Always create a new email with the final body content
|
||||||
const emailCreate: Record<string, unknown> = {
|
const emailCreate: Record<string, unknown> = {
|
||||||
from: [{ ...(fromName ? { name: fromName } : {}), email: fromEmail || this.username }],
|
from: [{ ...(fromName ? { name: fromName } : {}), email: fromEmail || this.username }],
|
||||||
|
replyTo: identityReplyTo?.length ? identityReplyTo : undefined,
|
||||||
to: to.map(email => ({ email })),
|
to: to.map(email => ({ email })),
|
||||||
cc: cc?.map(email => ({ email })),
|
cc: cc?.map(email => ({ email })),
|
||||||
bcc: bcc?.map(email => ({ email })),
|
bcc: bcc?.map(email => ({ email })),
|
||||||
|
|||||||
Reference in New Issue
Block a user