Agenda refactor
This commit is contained in:
parent
35799463f5
commit
df21ed0c4a
@ -138,28 +138,22 @@ export async function fetchMicrosoftEvents(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Add date filter if provided
|
// Add date filter if provided
|
||||||
// Note: Microsoft Graph API filter syntax
|
// Note: Microsoft Graph API filter syntax is limited
|
||||||
// For timed events: start/dateTime
|
// We can't easily filter both dateTime and date in one query
|
||||||
// For all-day events: start/date
|
// So we'll filter by dateTime and handle all-day events separately if needed
|
||||||
// We need to handle both cases
|
|
||||||
if (startDate && endDate) {
|
if (startDate && endDate) {
|
||||||
// Format dates for Microsoft Graph API
|
// Format dates for Microsoft Graph API
|
||||||
// For dateTime: ISO 8601 format (e.g., 2026-01-14T21:00:00Z)
|
// Use ISO 8601 format for dateTime filter
|
||||||
// For date: YYYY-MM-DD format
|
|
||||||
const startDateStr = startDate.toISOString().split('T')[0];
|
|
||||||
const endDateStr = endDate.toISOString().split('T')[0];
|
|
||||||
const startDateTimeStr = startDate.toISOString();
|
const startDateTimeStr = startDate.toISOString();
|
||||||
const endDateTimeStr = endDate.toISOString();
|
const endDateTimeStr = endDate.toISOString();
|
||||||
|
|
||||||
// Microsoft Graph API filter: match events where start is within range
|
// Microsoft Graph API filter: filter by start/dateTime
|
||||||
// This handles both timed events (dateTime) and all-day events (date)
|
// This will match timed events. All-day events might need separate handling
|
||||||
// The filter checks if either dateTime OR date is within range
|
// but Microsoft Graph usually returns all-day events with dateTime set to start of day
|
||||||
params.$filter = `(start/dateTime ge '${startDateTimeStr}' or start/date ge '${startDateStr}') and (start/dateTime le '${endDateTimeStr}' or start/date le '${endDateStr}')`;
|
params.$filter = `start/dateTime ge '${startDateTimeStr}' and start/dateTime le '${endDateTimeStr}'`;
|
||||||
|
|
||||||
logger.debug('Microsoft Graph API filter', {
|
logger.debug('Microsoft Graph API filter', {
|
||||||
filter: params.$filter,
|
filter: params.$filter,
|
||||||
startDate: startDateStr,
|
|
||||||
endDate: endDateStr,
|
|
||||||
startDateTime: startDateTimeStr,
|
startDateTime: startDateTimeStr,
|
||||||
endDateTime: endDateTimeStr,
|
endDateTime: endDateTimeStr,
|
||||||
});
|
});
|
||||||
@ -214,13 +208,24 @@ export async function fetchMicrosoftEvents(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return events;
|
return events;
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
logger.error('Error fetching Microsoft events', {
|
// Log detailed error information for debugging
|
||||||
|
const errorDetails: any = {
|
||||||
userId,
|
userId,
|
||||||
email,
|
email,
|
||||||
calendarId,
|
calendarId,
|
||||||
error: error instanceof Error ? error.message : String(error),
|
error: error instanceof Error ? error.message : String(error),
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (error.response) {
|
||||||
|
errorDetails.status = error.response.status;
|
||||||
|
errorDetails.statusText = error.response.statusText;
|
||||||
|
errorDetails.data = error.response.data;
|
||||||
|
errorDetails.url = error.config?.url;
|
||||||
|
errorDetails.params = error.config?.params;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.error('Error fetching Microsoft events', errorDetails);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user