wip: email sync via imap with status tracking and auto cron

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 04:57:30 +00:00
co-authored by Claude Opus 4.6
parent 5925ac49a1
commit 170bd6d41b
20 changed files with 1929 additions and 373 deletions
@@ -259,11 +259,16 @@ export const googleCallbackHandler = async (ctx: any) => {
const serverIntegration = await getServerIntegration('google');
// Merge with existing config to preserve fields like imapAppPassword
const existingIntegration = await getUserIntegration(dbUser.id, 'google');
const existingConfig = (existingIntegration?.config as Record<string, unknown>) ?? {};
await upsertUserIntegration({
userId: dbUser.id,
provider: 'google',
serverIntegrationId: serverIntegration?.id,
config: {
...existingConfig,
accessToken: tokens.access_token,
refreshToken: tokens.refresh_token,
expiresAt: Date.now() + tokens.expires_in * 1000,