feat(18-03): route all-day reminder TZ through stored household_timezone
- reminderScheduler.ts: add import { getHouseholdTimezone } from '../lib/householdTimezone.js'
and replace bare process.env.TZ ?? Intl... at line 247 with await getHouseholdTimezone(db)
- outboxWorker.ts: add same import and replace BOTH bare tz lookups at the update-branch
(~line 501) and create-branch (~line 607) with await getHouseholdTimezone(db)
- D-05 satisfied: all three all-day sites now read from the single stored accessor
- D-06 satisfied: getHouseholdTimezone falls back to process.env.TZ → Intl when unset;
existing process.env.TZ-pinned tests pass unchanged
- D-07 satisfied: eventDateTime.ts and hydrateEvents.ts are not modified
- outboxWorker.test.ts: update wireMockChain() to handle app_config table with where().limit()
chain returning empty rows (D-06 fallback), so existing CAL-13 all-day test stays green
- reminderScheduler.test.ts: update mockTwoQueries to mock the new third db.select() call
(getHouseholdTimezone) returning no row (D-06 fallback), keeping all 37 existing tests green
- All 76 broker tests pass; tsc --noEmit clean
This commit is contained in:
@@ -43,6 +43,7 @@ import {
|
||||
} from './vevent.js';
|
||||
import type { FastmailClient } from './client.js';
|
||||
import { dispatchEventChange } from '../lib/eventChangeDispatcher.js';
|
||||
import { getHouseholdTimezone } from '../lib/householdTimezone.js';
|
||||
import { onOutboxDrain } from '../lib/outboxTrigger.js';
|
||||
|
||||
// ── Constants (D-07) ────────────────────────────────────────────────────────
|
||||
@@ -498,7 +499,9 @@ async function dispatchRow(row: OutboxRow): Promise<DispatchResult> {
|
||||
fields.allDay &&
|
||||
fields.start
|
||||
) {
|
||||
const tz = process.env.TZ ?? Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
// D-05: route through the single stored-TZ accessor (no inline fallback duplicated here).
|
||||
// D-06: getHouseholdTimezone falls back to process.env.TZ → Intl when no row is stored.
|
||||
const tz = await getHouseholdTimezone(db);
|
||||
const leadDays = fields.reminderLeadMinutes / 1440;
|
||||
allDayAlertInstantUtcUpdate = computeAlertInstantUtc(fields.start, leadDays, tz);
|
||||
}
|
||||
@@ -604,7 +607,9 @@ async function dispatchRow(row: OutboxRow): Promise<DispatchResult> {
|
||||
// carries an explicit picker value or no reminder at all; no preserve path needed).
|
||||
let allDayAlertInstantUtcCreate: Date | undefined;
|
||||
if (fields.reminderLeadMinutes != null && fields.allDay && fields.start) {
|
||||
const tz = process.env.TZ ?? Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
// D-05: route through the single stored-TZ accessor (no inline fallback duplicated here).
|
||||
// D-06: getHouseholdTimezone falls back to process.env.TZ → Intl when no row is stored.
|
||||
const tz = await getHouseholdTimezone(db);
|
||||
const leadDays = fields.reminderLeadMinutes / 1440;
|
||||
allDayAlertInstantUtcCreate = computeAlertInstantUtc(fields.start, leadDays, tz);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user