From edb68d396d40a5171db325577457cb2b44038ec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Thu, 23 Jul 2026 16:57:32 +0000 Subject: [PATCH] email: route gmail app-password accounts over IMAP (Gmail API only for oauth) Co-Authored-By: Claude Opus 4.8 --- src/servers/api/email/accounts.ts | 5 +++-- src/servers/api/email/resync.ts | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/servers/api/email/accounts.ts b/src/servers/api/email/accounts.ts index 6457c0e4..13e10d8c 100644 --- a/src/servers/api/email/accounts.ts +++ b/src/servers/api/email/accounts.ts @@ -140,7 +140,7 @@ accountsRouter.post('/:id/sync', async (ctx) => { // Determine if this is a first sync or resync let isFirstSync = true; - if (account.provider === 'gmail') { + if (account.provider === 'gmail' && account.authType === 'oauth') { const db = openEmailDb(user.email); try { isFirstSync = !getSyncMeta(db, 'last_sync_at'); @@ -176,7 +176,8 @@ accountsRouter.post('/:id/sync', async (ctx) => { await updateEmailAccountStatus(id, 'queued'); - const jobType = account.provider === 'gmail' ? 'gmail-sync' : 'email-sync'; + // Gmail API sync needs OAuth; a gmail account with an app password syncs over IMAP instead. + const jobType = account.provider === 'gmail' && account.authType === 'oauth' ? 'gmail-sync' : 'email-sync'; const job = await enqueueJob({ lane: 'email', diff --git a/src/servers/api/email/resync.ts b/src/servers/api/email/resync.ts index 7333fb8e..5438a815 100644 --- a/src/servers/api/email/resync.ts +++ b/src/servers/api/email/resync.ts @@ -275,7 +275,8 @@ export async function performResync({ accountId, userEmail, userId }: ResyncPara const account = await getEmailAccount(accountId); if (!account || account.userId !== userId) throw new Error('Account not found'); - if (account.provider === 'gmail') { + // Gmail API resync needs OAuth; a gmail account authed with an app password resyncs over IMAP. + if (account.provider === 'gmail' && account.authType === 'oauth') { return gmailResync(userEmail); }