Preserve QOutlook Reply-To in EML
This commit is contained in:
@@ -42,10 +42,11 @@ export function QOutlook({ mail, onChange, onFolderChange }: QOutlookProps) {
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const draftAttachmentInputRef = useRef<HTMLInputElement>(null);
|
||||
const [query, setQuery] = useState("");
|
||||
const [draft, setDraft] = useState<{ to: string; cc: string; bcc: string; subject: string; body: string; attachments: MailAttachment[] }>({
|
||||
const [draft, setDraft] = useState<{ to: string; cc: string; bcc: string; replyTo: string; subject: string; body: string; attachments: MailAttachment[] }>({
|
||||
to: "",
|
||||
cc: "",
|
||||
bcc: "",
|
||||
replyTo: "",
|
||||
subject: "",
|
||||
body: "",
|
||||
attachments: []
|
||||
@@ -63,6 +64,7 @@ export function QOutlook({ mail, onChange, onFolderChange }: QOutlookProps) {
|
||||
message.to,
|
||||
message.cc ?? "",
|
||||
message.bcc ?? "",
|
||||
message.replyTo ?? "",
|
||||
message.subject,
|
||||
message.body,
|
||||
...(message.attachments ?? []).map((attachment) => attachment.fileName)
|
||||
@@ -91,6 +93,7 @@ export function QOutlook({ mail, onChange, onFolderChange }: QOutlookProps) {
|
||||
to: draft.to.trim(),
|
||||
...(draft.cc.trim() ? { cc: draft.cc.trim() } : {}),
|
||||
...(draft.bcc.trim() ? { bcc: draft.bcc.trim() } : {}),
|
||||
...(draft.replyTo.trim() ? { replyTo: draft.replyTo.trim() } : {}),
|
||||
subject: draft.subject.trim(),
|
||||
body: draft.body.trim(),
|
||||
time: new Date().toLocaleTimeString("ru-RU", { hour: "2-digit", minute: "2-digit" }),
|
||||
@@ -105,7 +108,7 @@ export function QOutlook({ mail, onChange, onFolderChange }: QOutlookProps) {
|
||||
activeMessageId: id,
|
||||
messages: [message, ...current.messages]
|
||||
}));
|
||||
setDraft({ to: "", cc: "", bcc: "", subject: "", body: "", attachments: [] });
|
||||
setDraft({ to: "", cc: "", bcc: "", replyTo: "", subject: "", body: "", attachments: [] });
|
||||
}
|
||||
|
||||
async function openMailFile(file: File | undefined) {
|
||||
@@ -313,6 +316,7 @@ export function QOutlook({ mail, onChange, onFolderChange }: QOutlookProps) {
|
||||
{activeMessage.bcc ? `Скрытая копия: ${activeMessage.bcc}` : ""}
|
||||
</p>
|
||||
) : null}
|
||||
{activeMessage.replyTo ? <p className="muted">Ответить на: {activeMessage.replyTo}</p> : null}
|
||||
<p>{activeMessage.body}</p>
|
||||
{activeAttachments.length > 0 ? (
|
||||
<section className="attachments-panel" aria-label="Вложения письма">
|
||||
@@ -359,6 +363,12 @@ export function QOutlook({ mail, onChange, onFolderChange }: QOutlookProps) {
|
||||
placeholder="Скрытая копия"
|
||||
aria-label="Скрытая копия"
|
||||
/>
|
||||
<input
|
||||
value={draft.replyTo}
|
||||
onChange={(event) => setDraft({ ...draft, replyTo: event.target.value })}
|
||||
placeholder="Ответить на"
|
||||
aria-label="Ответить на"
|
||||
/>
|
||||
<input
|
||||
value={draft.subject}
|
||||
onChange={(event) => setDraft({ ...draft, subject: event.target.value })}
|
||||
|
||||
@@ -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)}`] : [])
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -125,6 +125,7 @@ export interface MailMessage {
|
||||
to: string;
|
||||
cc?: string;
|
||||
bcc?: string;
|
||||
replyTo?: string;
|
||||
subject: string;
|
||||
body: string;
|
||||
time: string;
|
||||
|
||||
Reference in New Issue
Block a user