style(13-03): apply Prettier formatting across repo
Mechanical reformat — no logic changes. 398 files changed, 19125 insertions(+), 16457 deletions(-). Prettier 3.8.4 with .prettierrc (singleQuote:true, semi:true, tabWidth:2, trailingComma:all, printWidth:100). Isolated per D-13-08 for reviewability.
This commit is contained in:
@@ -14,13 +14,13 @@
|
||||
* (node-cron 4.2.1 silently skipped scheduled executions in the long-running server process;
|
||||
* setInterval fires reliably in the same process — replaced to fix the silent skip.)
|
||||
*/
|
||||
import { and, eq } from 'drizzle-orm'
|
||||
import { db } from '../db/client.js'
|
||||
import { memberCredentials, calendars } from '../db/schema.js'
|
||||
import { decryptPassword } from './crypto.js'
|
||||
import { createFastmailClient } from './client.js'
|
||||
import { syncCalendar } from './sync.js'
|
||||
import { dispatchEventChange } from '../lib/eventChangeDispatcher.js'
|
||||
import { and, eq } from 'drizzle-orm';
|
||||
import { db } from '../db/client.js';
|
||||
import { memberCredentials, calendars } from '../db/schema.js';
|
||||
import { decryptPassword } from './crypto.js';
|
||||
import { createFastmailClient } from './client.js';
|
||||
import { syncCalendar } from './sync.js';
|
||||
import { dispatchEventChange } from '../lib/eventChangeDispatcher.js';
|
||||
|
||||
/**
|
||||
* Runs one full poll cycle:
|
||||
@@ -32,15 +32,15 @@ import { dispatchEventChange } from '../lib/eventChangeDispatcher.js'
|
||||
* so one bad credential does not stop processing for others.
|
||||
*/
|
||||
export async function runPoll(): Promise<void> {
|
||||
const creds = await db.select().from(memberCredentials)
|
||||
const creds = await db.select().from(memberCredentials);
|
||||
|
||||
for (const cred of creds) {
|
||||
try {
|
||||
// Decrypt before client creation (T-03-04: never expose decrypted value in logs)
|
||||
const appPassword = decryptPassword(cred.encryptedPassword)
|
||||
const appPassword = decryptPassword(cred.encryptedPassword);
|
||||
|
||||
const client = await createFastmailClient(cred.fastmailEmail, appPassword)
|
||||
const davCalendars = await client.fetchCalendars()
|
||||
const client = await createFastmailClient(cred.fastmailEmail, appPassword);
|
||||
const davCalendars = await client.fetchCalendars();
|
||||
|
||||
for (const davCal of davCalendars) {
|
||||
// Look up the stored calendar row to get the known ctag (D-13).
|
||||
@@ -52,15 +52,15 @@ export async function runPoll(): Promise<void> {
|
||||
.select()
|
||||
.from(calendars)
|
||||
.where(and(eq(calendars.userId, cred.userId), eq(calendars.url, davCal.url)))
|
||||
.limit(1)
|
||||
.limit(1);
|
||||
|
||||
// ctag/syncToken: defensive null handling (Pitfall #6)
|
||||
const knownCtag = stored?.ctag ?? null
|
||||
const currentCtag = davCal.ctag ?? davCal.syncToken ?? null
|
||||
const knownCtag = stored?.ctag ?? null;
|
||||
const currentCtag = davCal.ctag ?? davCal.syncToken ?? null;
|
||||
|
||||
// Skip if ctag is present on both sides and unchanged
|
||||
if (currentCtag !== null && currentCtag === knownCtag) {
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
|
||||
// NOTIF-03: pass onChanges so external event changes push to non-actor members.
|
||||
@@ -71,17 +71,17 @@ export async function runPoll(): Promise<void> {
|
||||
console.error(
|
||||
'[broker/poller] dispatchEventChange error:',
|
||||
err instanceof Error ? err.message : String(err),
|
||||
)
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
// Log the error but do NOT log the app password or key (T-03-04)
|
||||
console.error(
|
||||
`[broker/poller] Error processing credential id=${cred.id} (${cred.fastmailEmail}):`,
|
||||
err instanceof Error ? err.message : String(err),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,9 +93,12 @@ export async function runPoll(): Promise<void> {
|
||||
* in the long-running server process; setInterval fires reliably.
|
||||
*/
|
||||
export function startBrokerPoller(): void {
|
||||
setInterval(() => {
|
||||
runPoll().catch((err: unknown) => {
|
||||
console.error('[broker/poller] Unhandled runPoll error:', err)
|
||||
})
|
||||
}, 5 * 60 * 1000)
|
||||
setInterval(
|
||||
() => {
|
||||
runPoll().catch((err: unknown) => {
|
||||
console.error('[broker/poller] Unhandled runPoll error:', err);
|
||||
});
|
||||
},
|
||||
5 * 60 * 1000,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user