Preserve QOutlook Reply-To in EML
This commit is contained in:
@@ -176,6 +176,7 @@ describe("outlookMail helpers", () => {
|
||||
"To: reader@example.com",
|
||||
"Cc: copy@example.com",
|
||||
"Bcc: hidden@example.com",
|
||||
"Reply-To: support@example.com",
|
||||
"Subject: =?UTF-8?B?0JzRg9C70YzRgtC40L/QsNGA0YI=?=",
|
||||
"Date: Mon, 01 Jun 2026 10:00:00 +0300",
|
||||
'Content-Type: multipart/alternative; boundary="alt"',
|
||||
@@ -200,6 +201,7 @@ describe("outlookMail helpers", () => {
|
||||
expect(imported.to).toBe("reader@example.com");
|
||||
expect(imported.cc).toBe("copy@example.com");
|
||||
expect(imported.bcc).toBe("hidden@example.com");
|
||||
expect(imported.replyTo).toBe("support@example.com");
|
||||
});
|
||||
|
||||
it("импортирует multipart/mixed EML с вложением", async () => {
|
||||
@@ -249,6 +251,7 @@ describe("outlookMail helpers", () => {
|
||||
{
|
||||
senderSmtpAddress: "sender@example.com",
|
||||
subject: "MSG отчет",
|
||||
headers: "Reply-To: support@example.com\r\nFrom: sender@example.com",
|
||||
bodyHtml: "<p>HTML текст</p>",
|
||||
messageDeliveryTime: "Mon, 01 Jun 2026 10:00:00 GMT",
|
||||
recipients: [
|
||||
@@ -266,6 +269,7 @@ describe("outlookMail helpers", () => {
|
||||
to: "reader@example.com",
|
||||
cc: "copy@example.com",
|
||||
bcc: "hidden@example.com",
|
||||
replyTo: "support@example.com",
|
||||
subject: "MSG отчет",
|
||||
body: "HTML текст",
|
||||
time: "Mon, 01 Jun 2026 10:00:00 GMT",
|
||||
@@ -294,6 +298,7 @@ describe("outlookMail helpers", () => {
|
||||
to: "reader@example.com",
|
||||
cc: "copy@example.com",
|
||||
bcc: "hidden@example.com",
|
||||
replyTo: "support@example.com",
|
||||
subject: "Тема",
|
||||
body: "Текст",
|
||||
time: "Mon, 01 Jan 2024 10:00:00 +0000",
|
||||
@@ -306,6 +311,7 @@ describe("outlookMail helpers", () => {
|
||||
expect(eml).toContain("From: sender@example.com");
|
||||
expect(eml).toContain("Cc: copy@example.com");
|
||||
expect(eml).toContain("Bcc: hidden@example.com");
|
||||
expect(eml).toContain("Reply-To: support@example.com");
|
||||
expect(eml).toContain("Subject: =?UTF-8?B?");
|
||||
expect(eml.endsWith("Текст")).toBe(true);
|
||||
});
|
||||
@@ -318,6 +324,7 @@ describe("outlookMail helpers", () => {
|
||||
to: "reader@example.com",
|
||||
cc: "copy@example.com",
|
||||
bcc: "hidden@example.com",
|
||||
replyTo: "support@example.com",
|
||||
subject: "Тема",
|
||||
body: "Текст",
|
||||
time: "Mon, 01 Jan 2024 10:00:00 +0000",
|
||||
@@ -342,6 +349,7 @@ describe("outlookMail helpers", () => {
|
||||
expect(eml).toContain("Content-Type: multipart/mixed");
|
||||
expect(eml).toContain("Cc: copy@example.com");
|
||||
expect(eml).toContain("Bcc: hidden@example.com");
|
||||
expect(eml).toContain("Reply-To: support@example.com");
|
||||
expect(eml).toContain("filename*=utf-8''%D0%BE%D1%82%D1%87%D0%B5%D1%82%2E%74%78%74");
|
||||
expect(extractMessageBody(parsed.headers, parsed.body)).toBe("Текст");
|
||||
expect(attachments[0]).toMatchObject({
|
||||
|
||||
@@ -89,6 +89,7 @@ export async function importEmlFile(file: File): Promise<ImportedMailMessage> {
|
||||
to: decodeMimeWords(parsed.headers.to || ""),
|
||||
...(parsed.headers.cc ? { cc: decodeMimeWords(parsed.headers.cc) } : {}),
|
||||
...(parsed.headers.bcc ? { bcc: decodeMimeWords(parsed.headers.bcc) } : {}),
|
||||
...(parsed.headers["reply-to"] ? { replyTo: decodeMimeWords(parsed.headers["reply-to"]) } : {}),
|
||||
subject: decodeMimeWords(parsed.headers.subject || "Без темы"),
|
||||
body: extractMessageBody(parsed.headers, parsed.body),
|
||||
time: parsed.headers.date || new Date().toLocaleString("ru-RU"),
|
||||
@@ -117,6 +118,7 @@ export function msgDataToMailMessage(reader: Pick<MsgReaderInstance, "getAttachm
|
||||
const headerFields = data.headers ? parseEmlHeaders(data.headers) : {};
|
||||
const cc = msgRecipientList(data.recipients, "cc") || decodeMimeWords(headerFields.cc || "");
|
||||
const bcc = msgRecipientList(data.recipients, "bcc") || decodeMimeWords(headerFields.bcc || "");
|
||||
const replyTo = decodeMimeWords(headerFields["reply-to"] || "");
|
||||
return {
|
||||
id: `msg-${Date.now()}`,
|
||||
folder: "inbox",
|
||||
@@ -124,6 +126,7 @@ export function msgDataToMailMessage(reader: Pick<MsgReaderInstance, "getAttachm
|
||||
to: msgRecipientList(data.recipients, "to") || decodeMimeWords(headerFields.to || ""),
|
||||
...(cc ? { cc } : {}),
|
||||
...(bcc ? { bcc } : {}),
|
||||
...(replyTo ? { replyTo } : {}),
|
||||
subject: firstText(data.subject, decodeMimeWords(headerFields.subject || ""), "Без темы"),
|
||||
body: msgBodyText(data),
|
||||
time: firstText(data.messageDeliveryTime, data.clientSubmitTime, data.creationTime, data.lastModificationTime, headerFields.date, new Date().toLocaleString("ru-RU")),
|
||||
@@ -453,7 +456,8 @@ export function buildEmlSource(message: MailMessage): string {
|
||||
function optionalAddressHeaders(message: MailMessage): string[] {
|
||||
return [
|
||||
...(message.cc?.trim() ? [`Cc: ${sanitizeHeaderValue(message.cc)}`] : []),
|
||||
...(message.bcc?.trim() ? [`Bcc: ${sanitizeHeaderValue(message.bcc)}`] : [])
|
||||
...(message.bcc?.trim() ? [`Bcc: ${sanitizeHeaderValue(message.bcc)}`] : []),
|
||||
...(message.replyTo?.trim() ? [`Reply-To: ${sanitizeHeaderValue(message.replyTo)}`] : [])
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user