Preserve QOutlook threading headers in EML

This commit is contained in:
Курнат Андрей
2026-06-01 19:56:44 +03:00
parent 0a75ec7b1a
commit 9bd8827549
5 changed files with 69 additions and 3 deletions
+28 -1
View File
@@ -177,6 +177,9 @@ describe("outlookMail helpers", () => {
"Cc: copy@example.com",
"Bcc: hidden@example.com",
"Reply-To: support@example.com",
"Message-ID: <message-1@example.com>",
"In-Reply-To: <parent@example.com>",
"References: <root@example.com> <parent@example.com>",
"Subject: =?UTF-8?B?0JzRg9C70YzRgtC40L/QsNGA0YI=?=",
"Date: Mon, 01 Jun 2026 10:00:00 +0300",
'Content-Type: multipart/alternative; boundary="alt"',
@@ -202,6 +205,9 @@ describe("outlookMail helpers", () => {
expect(imported.cc).toBe("copy@example.com");
expect(imported.bcc).toBe("hidden@example.com");
expect(imported.replyTo).toBe("support@example.com");
expect(imported.messageId).toBe("<message-1@example.com>");
expect(imported.inReplyTo).toBe("<parent@example.com>");
expect(imported.references).toBe("<root@example.com> <parent@example.com>");
});
it("импортирует multipart/mixed EML с вложением", async () => {
@@ -251,7 +257,13 @@ describe("outlookMail helpers", () => {
{
senderSmtpAddress: "sender@example.com",
subject: "MSG отчет",
headers: "Reply-To: support@example.com\r\nFrom: sender@example.com",
headers: [
"Reply-To: support@example.com",
"Message-ID: <msg-1@example.com>",
"In-Reply-To: <msg-parent@example.com>",
"References: <msg-root@example.com> <msg-parent@example.com>",
"From: sender@example.com"
].join("\r\n"),
bodyHtml: "<p>HTML&nbsp;текст</p>",
messageDeliveryTime: "Mon, 01 Jun 2026 10:00:00 GMT",
recipients: [
@@ -270,6 +282,9 @@ describe("outlookMail helpers", () => {
cc: "copy@example.com",
bcc: "hidden@example.com",
replyTo: "support@example.com",
messageId: "<msg-1@example.com>",
inReplyTo: "<msg-parent@example.com>",
references: "<msg-root@example.com> <msg-parent@example.com>",
subject: "MSG отчет",
body: "HTML текст",
time: "Mon, 01 Jun 2026 10:00:00 GMT",
@@ -299,6 +314,9 @@ describe("outlookMail helpers", () => {
cc: "copy@example.com",
bcc: "hidden@example.com",
replyTo: "support@example.com",
messageId: "<message-1@example.com>",
inReplyTo: "<parent@example.com>",
references: "<root@example.com> <parent@example.com>",
subject: "Тема",
body: "Текст",
time: "Mon, 01 Jan 2024 10:00:00 +0000",
@@ -312,6 +330,9 @@ describe("outlookMail helpers", () => {
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("Message-ID: <message-1@example.com>");
expect(eml).toContain("In-Reply-To: <parent@example.com>");
expect(eml).toContain("References: <root@example.com> <parent@example.com>");
expect(eml).toContain("Subject: =?UTF-8?B?");
expect(eml.endsWith("Текст")).toBe(true);
});
@@ -325,6 +346,9 @@ describe("outlookMail helpers", () => {
cc: "copy@example.com",
bcc: "hidden@example.com",
replyTo: "support@example.com",
messageId: "<message-1@example.com>",
inReplyTo: "<parent@example.com>",
references: "<root@example.com> <parent@example.com>",
subject: "Тема",
body: "Текст",
time: "Mon, 01 Jan 2024 10:00:00 +0000",
@@ -350,6 +374,9 @@ describe("outlookMail helpers", () => {
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("Message-ID: <message-1@example.com>");
expect(eml).toContain("In-Reply-To: <parent@example.com>");
expect(eml).toContain("References: <root@example.com> <parent@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({