From 6dcc12843c8b6ac26fc06575d9fd62b9cefa629a Mon Sep 17 00:00:00 2001 From: Christine Spang Date: Fri, 23 Dec 2016 10:03:56 -0800 Subject: [PATCH] [local-sync] Fix message parsing when no Date header present Summary: When the Date: header is not present, use the INTERNALDATE from the IMAP server instead. Test Plan: manual for now - will add a regression test for this though Reviewers: juan, jackie Reviewed By: jackie Differential Revision: https://phab.nylas.com/D3556 --- packages/local-sync/src/shared/message-factory.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/local-sync/src/shared/message-factory.js b/packages/local-sync/src/shared/message-factory.js index 8e276a7de..4050f514f 100644 --- a/packages/local-sync/src/shared/message-factory.js +++ b/packages/local-sync/src/shared/message-factory.js @@ -205,8 +205,13 @@ async function parseFromImap(imapMessage, desiredParts, {db, accountId, folder}) // Make sure we use the date from the headers because we use the header date // for generating message ids. // `attributes.date` is the server generated date and might differ from the - // header - date: parsedHeaders.date[0], + // header across accounts + // TODO: how to exclude the date header from the hash if there is no + // Date: header and we have to use the IMAP server date for message sort + // & display? seems like it should be OK within an account, but might + // generate different message IDs across different accounts (which I + // don't think is a problem we're intending to solve...) + date: parsedHeaders.date ? parsedHeaders.date[0] : imapMessage.attributes.date, folderImapUID: attributes.uid, folderId: folder.id, folder: null,