-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Love your module and have been using it for a while. In my app, very rarely, I have noticed messages come in sorted lower in date order than they should be.
I just received an email at 8am this morning, for example, but the parser gave it a timestamp of Friday night. I pulled the raw gmail api data for this email and noticed the 'x-received' header had the date I wanted - the date we actually received the email.
My suspicion is the sender drafted the email friday night, but hit Send on Monday morning. I threw together a crude bit of code to pull the date out of the 'x-received' header:
NOTE: this uses the parse method from the date-fns module.
let re: RegExp = new RegExp('(Mon|Tue|Wed|Thu|Fri|Sat|Sun)([^\(]*)\\(');
let matches: any[] = parsedMsg.headers['x-received'].match(re);
if (matches?.length) {
let d: Date = parse(matches[0], 'EEE\, d LLL yyyy hh\:mm\:ss XX \(', new Date());
if (d.toString() !== 'Invalid Date') {
timestamp = d.valueOf();
}
}
Metadata
Metadata
Assignees
Labels
No labels