webmail: when replying to message we sent, don't compose the reply to ourselve, but copy the original to/cc/bcc headers

This commit is contained in:
Mechiel Lukkien 2023-11-27 12:26:31 +01:00
parent fb81effe45
commit 7c1879da82
No known key found for this signature in database
2 changed files with 21 additions and 12 deletions

View file

@ -2784,7 +2784,7 @@ const newMsgView = (miv, msglistView, listMailboxes, possibleLabels, messageLoad
parsedMessageResolve = resolve; parsedMessageResolve = resolve;
parsedMessageReject = reject; parsedMessageReject = reject;
}); });
const react = async (to, forward, all) => { const react = async (to, cc, bcc, forward, all) => {
const pm = await parsedMessagePromise; const pm = await parsedMessagePromise;
let body = ''; let body = '';
const sel = window.getSelection(); const sel = window.getSelection();
@ -2821,9 +2821,9 @@ const newMsgView = (miv, msglistView, listMailboxes, possibleLabels, messageLoad
subject = (RegExp('^' + subjectPrefix, 'i').test(subject) ? '' : subjectPrefix + ' ') + subject; subject = (RegExp('^' + subjectPrefix, 'i').test(subject) ? '' : subjectPrefix + ' ') + subject;
const opts = { const opts = {
from: mi.Envelope.To || undefined, from: mi.Envelope.To || undefined,
to: (to || []).map(a => formatAddress(a)), to: to.map(a => formatAddress(a)),
cc: [], cc: cc.map(a => formatAddress(a)),
bcc: [], bcc: bcc.map(a => formatAddress(a)),
subject: subject, subject: subject,
body: body, body: body,
isForward: forward, isForward: forward,
@ -2839,9 +2839,14 @@ const newMsgView = (miv, msglistView, listMailboxes, possibleLabels, messageLoad
compose(opts); compose(opts);
}; };
const reply = async (all, toOpt) => { const reply = async (all, toOpt) => {
await react(toOpt || ((mi.Envelope.ReplyTo || []).length > 0 ? mi.Envelope.ReplyTo : mi.Envelope.From) || null, false, all); if (!all && !toOpt && (mi.Envelope.From || []).length === 1 && envelopeIdentity(mi.Envelope.From || [])) {
await react(mi.Envelope.To || [], mi.Envelope.CC || [], mi.Envelope.BCC || [], false, all);
}
else {
await react(toOpt || ((mi.Envelope.ReplyTo || []).length > 0 ? mi.Envelope.ReplyTo : mi.Envelope.From) || [], [], [], false, all);
}
}; };
const cmdForward = async () => { react([], true, false); }; const cmdForward = async () => { react([], [], [], true, false); };
const cmdReplyList = async () => { const cmdReplyList = async () => {
const pm = await parsedMessagePromise; const pm = await parsedMessagePromise;
if (pm.ListReplyAddress) { if (pm.ListReplyAddress) {

View file

@ -2190,7 +2190,7 @@ const newMsgView = (miv: MsgitemView, msglistView: MsglistView, listMailboxes: l
parsedMessageReject = reject parsedMessageReject = reject
}) })
const react = async (to: api.MessageAddress[] | null, forward: boolean, all: boolean) => { const react = async (to: api.MessageAddress[], cc: api.MessageAddress[], bcc: api.MessageAddress[], forward: boolean, all: boolean) => {
const pm = await parsedMessagePromise const pm = await parsedMessagePromise
let body = '' let body = ''
const sel = window.getSelection() const sel = window.getSelection()
@ -2224,9 +2224,9 @@ const newMsgView = (miv: MsgitemView, msglistView: MsglistView, listMailboxes: l
subject = (RegExp('^'+subjectPrefix, 'i').test(subject) ? '' : subjectPrefix+' ') + subject subject = (RegExp('^'+subjectPrefix, 'i').test(subject) ? '' : subjectPrefix+' ') + subject
const opts: ComposeOptions = { const opts: ComposeOptions = {
from: mi.Envelope.To || undefined, from: mi.Envelope.To || undefined,
to: (to || []).map(a => formatAddress(a)), to: to.map(a => formatAddress(a)),
cc: [], cc: cc.map(a => formatAddress(a)),
bcc: [], bcc: bcc.map(a => formatAddress(a)),
subject: subject, subject: subject,
body: body, body: body,
isForward: forward, isForward: forward,
@ -2243,9 +2243,13 @@ const newMsgView = (miv: MsgitemView, msglistView: MsglistView, listMailboxes: l
} }
const reply = async (all: boolean, toOpt?: api.MessageAddress[]) => { const reply = async (all: boolean, toOpt?: api.MessageAddress[]) => {
await react(toOpt || ((mi.Envelope.ReplyTo || []).length > 0 ? mi.Envelope.ReplyTo : mi.Envelope.From) || null, false, all) if (!all && !toOpt && (mi.Envelope.From || []).length === 1 && envelopeIdentity(mi.Envelope.From || [])) {
await react(mi.Envelope.To || [], mi.Envelope.CC || [], mi.Envelope.BCC || [], false, all)
} else {
await react(toOpt || ((mi.Envelope.ReplyTo || []).length > 0 ? mi.Envelope.ReplyTo : mi.Envelope.From) || [], [], [], false, all)
}
} }
const cmdForward = async () => { react([], true, false) } const cmdForward = async () => { react([], [], [], true, false) }
const cmdReplyList = async () => { const cmdReplyList = async () => {
const pm = await parsedMessagePromise const pm = await parsedMessagePromise
if (pm.ListReplyAddress) { if (pm.ListReplyAddress) {