[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
This commit is contained in:
Christine Spang 2016-12-23 10:03:56 -08:00
parent 0644d2663d
commit 6dcc12843c

View file

@ -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 // Make sure we use the date from the headers because we use the header date
// for generating message ids. // for generating message ids.
// `attributes.date` is the server generated date and might differ from the // `attributes.date` is the server generated date and might differ from the
// header // header across accounts
date: parsedHeaders.date[0], // 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, folderImapUID: attributes.uid,
folderId: folder.id, folderId: folder.id,
folder: null, folder: null,