From d77bbf3c167b28d9ba94c4f2b7f0b990c03107fa Mon Sep 17 00:00:00 2001 From: alma Date: Wed, 14 Jan 2026 21:36:48 +0100 Subject: [PATCH] Agenda refactor --- lib/services/microsoft-calendar-sync.ts | 54 ++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/lib/services/microsoft-calendar-sync.ts b/lib/services/microsoft-calendar-sync.ts index 2294ab7..ab17bb9 100644 --- a/lib/services/microsoft-calendar-sync.ts +++ b/lib/services/microsoft-calendar-sync.ts @@ -343,7 +343,7 @@ export async function syncMicrosoftCalendar( endDate ); - // Log all events, not just first 10 + // Log all events with full details logger.info('Fetched Microsoft events', { calendarSyncId, eventCount: microsoftEvents.length, @@ -353,13 +353,38 @@ export async function syncMicrosoftCalendar( }, allEvents: microsoftEvents.map(e => ({ id: e.id, - subject: e.subject, + subject: e.subject || '(sans titre)', start: e.start.dateTime || e.start.date, isAllDay: e.isAllDay, - end: e.end.dateTime || e.end.date + end: e.end.dateTime || e.end.date, + // Log full start/end objects to debug + startObj: e.start, + endObj: e.end })), }); + // Check if "Test" event is in the list + const testEvent = microsoftEvents.find(e => + e.subject && e.subject.toLowerCase().includes('test') + ); + if (testEvent) { + logger.info('Found "Test" event in Microsoft response', { + calendarSyncId, + testEvent: { + id: testEvent.id, + subject: testEvent.subject, + start: testEvent.start.dateTime || testEvent.start.date, + isAllDay: testEvent.isAllDay, + } + }); + } else { + logger.warn('"Test" event NOT found in Microsoft response', { + calendarSyncId, + totalEvents: microsoftEvents.length, + eventSubjects: microsoftEvents.map(e => e.subject || '(sans titre)'), + }); + } + if (microsoftEvents.length === 0) { logger.warn('No Microsoft events found in date range', { calendarSyncId, @@ -377,12 +402,31 @@ export async function syncMicrosoftCalendar( logger.info('Microsoft events in the future', { calendarSyncId, futureEventCount: futureEvents.length, - futureEvents: futureEvents.slice(0, 5).map(e => ({ + totalEvents: microsoftEvents.length, + futureEvents: futureEvents.map(e => ({ id: e.id, - subject: e.subject, + subject: e.subject || '(sans titre)', start: e.start.dateTime || e.start.date, + isAllDay: e.isAllDay, })), }); + + // Also log events in the past to see all events + const pastEvents = microsoftEvents.filter(e => { + const eventStart = e.start.dateTime || e.start.date; + return new Date(eventStart) <= now; + }); + if (pastEvents.length > 0) { + logger.info('Microsoft events in the past', { + calendarSyncId, + pastEventCount: pastEvents.length, + pastEvents: pastEvents.map(e => ({ + id: e.id, + subject: e.subject || '(sans titre)', + start: e.start.dateTime || e.start.date, + })), + }); + } } // Convert Microsoft events to CalDAV-like format