Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gmail.ts to support parsed date #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions ndc-duckduckapi/src/services/gmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ CREATE TABLE IF NOT EXISTS gmail_messages (
message_id VARCHAR,
subject VARCHAR,
from_address VARCHAR,
to_addresses JSON,
cc_addresses JSON,
bcc_addresses JSON,
date VARCHAR,
to_addresses TEXT,
cc_addresses TEXT,
bcc_addresses TEXT,
date TIMESTAMP WITH TIME ZONE,
body_plain TEXT,
body_html TEXT,
attachment_count INTEGER,
attachments JSON,
headers JSON,
attachments TEXT,
headers TEXT,
sync_status VARCHAR,
last_synced TIMESTAMP WITH TIME ZONE,
is_draft BOOLEAN,
Expand Down Expand Up @@ -385,7 +385,11 @@ export class SyncManager {
const to = headers.find(h => h.name?.toLowerCase() === 'to')?.value;
const cc = headers.find(h => h.name?.toLowerCase() === 'cc')?.value;
const bcc = headers.find(h => h.name?.toLowerCase() === 'bcc')?.value;
const date = headers.find(h => h.name?.toLowerCase() === 'date')?.value;
const headerDate = headers.find(h => h.name?.toLowerCase() === 'date')?.value;
let date: string | null = null;
if (headerDate) {
date = new Date(headerDate).toISOString();
}

const labelIds = message.labelIds || [];
const attachments = this.extractAttachments(message.payload);
Expand Down Expand Up @@ -658,3 +662,4 @@ last_synced: new Date().toISOString(),
await db.close();
}
}